|
4 | 4 | #
|
5 | 5 | ############################################################################################
|
6 | 6 |
|
| 7 | +using StableRNGs |
| 8 | + |
| 9 | +# Julia random number generator can change its output with the same seed accross minor |
| 10 | +# versions. Hence, we need to use StableRNGs.jl to ensure that the tests are consistent. For |
| 11 | +# more information, see: |
| 12 | +# |
| 13 | +# https://docs.julialang.org/en/v1/stdlib/Random/#Reproducibility |
| 14 | + |
7 | 15 | # == File: ./src/random.jl =================================================================
|
8 | 16 |
|
9 | 17 | @testset "DCM (Float64)" begin
|
10 | 18 | D_exp = DCM(
|
11 |
| - 0.1770772447942165, |
12 |
| - -0.24937398754945297, |
13 |
| - 0.9520799670772275, |
14 |
| - -0.16371156336807055, |
15 |
| - -0.9613536278168439, |
16 |
| - -0.22135430039413143, |
17 |
| - 0.9704855348719379, |
18 |
| - -0.11666969022448989, |
19 |
| - -0.21105925705178208 |
| 19 | + -0.9855423399595813, |
| 20 | + 0.1610947375575752, |
| 21 | + -0.05248601412042554, |
| 22 | + 0.13225259369505987, |
| 23 | + 0.9250801678356908, |
| 24 | + 0.35599990805900494, |
| 25 | + 0.10590348251083596, |
| 26 | + 0.3439115709137256, |
| 27 | + -0.9330108701316029, |
20 | 28 | )
|
21 | 29 |
|
22 |
| - D = rand(MersenneTwister(1986), DCM) |
| 30 | + D = rand(StableRNG(1986), DCM) |
23 | 31 | @test D ≈ D_exp atol = 1e-15
|
24 | 32 |
|
25 |
| - D = rand(MersenneTwister(1986), DCM{Float64}) |
| 33 | + D = rand(StableRNG(1986), DCM{Float64}) |
26 | 34 | @test D ≈ D_exp atol = 1e-15
|
27 | 35 | end
|
28 | 36 |
|
29 | 37 | @testset "DCM (Float32)" begin
|
30 | 38 | D_exp = DCM(
|
31 |
| - 0.9071183f0, |
32 |
| - -0.38511035f0, |
33 |
| - 0.1697833f0, |
34 |
| - -0.18077055f0, |
35 |
| - 0.0077917147f0, |
36 |
| - 0.98349446f0, |
37 |
| - -0.38007677f0, |
38 |
| - -0.9228377f0, |
39 |
| - -0.06254859f0 |
| 39 | + 0.13128565f0, |
| 40 | + 0.6157909f0, |
| 41 | + 0.77689487f0, |
| 42 | + -0.5353275f0, |
| 43 | + 0.7036309f0, |
| 44 | + -0.4672559f0, |
| 45 | + -0.83437914f0, |
| 46 | + -0.35454917f0, |
| 47 | + 0.4220264f0, |
40 | 48 | )
|
41 | 49 |
|
42 |
| - D = rand(MersenneTwister(1986), DCM{Float32}) |
| 50 | + D = rand(StableRNG(1986), DCM{Float32}) |
43 | 51 |
|
44 | 52 | @test D ≈ D_exp atol = 1e-15
|
45 | 53 | end
|
46 | 54 |
|
47 | 55 | @testset "Euler Angle and Axis (Float64)" begin
|
48 | 56 | aa_exp = EulerAngleAxis(
|
49 |
| - 3.0732832539795845, |
| 57 | + 3.0607810768487105, |
50 | 58 | @SVector [
|
51 |
| - 0.7668495688612252, |
52 |
| - -0.13482690249452656, |
53 |
| - 0.6275057331220841 |
| 59 | + -0.0748748188948659, |
| 60 | + -0.9810600691052008, |
| 61 | + -0.17864742456234697, |
54 | 62 | ]
|
55 | 63 | )
|
56 | 64 |
|
57 |
| - aa = rand(MersenneTwister(1986), EulerAngleAxis) |
| 65 | + aa = rand(StableRNG(1986), EulerAngleAxis) |
58 | 66 | @test aa ≈ aa_exp atol = 1e-15
|
59 | 67 |
|
60 |
| - aa = rand(MersenneTwister(1986), EulerAngleAxis{Float64}) |
| 68 | + aa = rand(StableRNG(1986), EulerAngleAxis{Float64}) |
61 | 69 | @test aa ≈ aa_exp atol = 1e-15
|
62 | 70 | end
|
63 | 71 |
|
64 | 72 | @testset "Euler Angle and Axis (Float32)" begin
|
65 | 73 | aa_exp = EulerAngleAxis(
|
66 |
| - 1.6446829f0, |
| 74 | + 1.4419688f0, |
67 | 75 | @SVector [
|
68 |
| - -0.9557738f0, |
69 |
| - 0.2756822f0, |
70 |
| - 0.102449425f0 |
| 76 | + 0.056824237f0, |
| 77 | + 0.812369f0, |
| 78 | + -0.5803686f0, |
71 | 79 | ]
|
72 | 80 | )
|
73 | 81 |
|
74 |
| - aa = rand(MersenneTwister(1986), EulerAngleAxis{Float32}) |
| 82 | + aa = rand(StableRNG(1986), EulerAngleAxis{Float32}) |
75 | 83 | @test aa ≈ aa_exp atol = 1e-15
|
76 | 84 | end
|
77 | 85 |
|
78 | 86 | @testset "Euler Angles (Float64)" begin
|
79 | 87 | ea_exp = EulerAngles(
|
80 |
| - 2.5852880822263606, |
81 |
| - 3.1861195131389626, |
82 |
| - 2.9299487570635576, |
83 |
| - :YXY |
| 88 | + 6.237765228608508, |
| 89 | + 2.646507063149075, |
| 90 | + 4.53226625968865, |
| 91 | + :YZY |
84 | 92 | )
|
85 | 93 |
|
86 |
| - ea = rand(MersenneTwister(1986), EulerAngles) |
| 94 | + ea = rand(StableRNG(1986), EulerAngles) |
87 | 95 | @test ea ≈ ea_exp atol = 1e-15
|
88 | 96 |
|
89 |
| - ea = rand(MersenneTwister(1986), EulerAngles{Float64}) |
| 97 | + ea = rand(StableRNG(1986), EulerAngles{Float64}) |
90 | 98 | @test ea ≈ ea_exp atol = 1e-15
|
91 | 99 | end
|
92 | 100 |
|
93 | 101 | @testset "Euler Angles (Float32)" begin
|
94 | 102 | ea_exp = EulerAngles(
|
95 |
| - 0.29179642f0, |
96 |
| - 5.512145f0, |
97 |
| - 4.3565836f0, |
98 |
| - :YXY |
| 103 | + 2.7291467f0, |
| 104 | + 1.5209f0, |
| 105 | + 2.1911314f0, |
| 106 | + :YZY |
99 | 107 | )
|
100 | 108 |
|
101 |
| - ea = rand(MersenneTwister(1986), EulerAngles{Float32}) |
| 109 | + ea = rand(StableRNG(1986), EulerAngles{Float32}) |
102 | 110 | @test ea ≈ ea_exp atol = 1e-15
|
103 | 111 | end
|
104 | 112 |
|
105 | 113 | @testset "Quaternion (Float64)" begin
|
106 | 114 | q_exp = Quaternion(
|
107 |
| - -0.03414805970179898, |
108 |
| - -0.7664023306434491, |
109 |
| - 0.1347482694144174, |
110 |
| - -0.6271397623279131 |
| 115 | + 0.04039479466622753, |
| 116 | + -0.07481370585716751, |
| 117 | + -0.9802593251184702, |
| 118 | + -0.17850161203213802, |
111 | 119 | )
|
112 | 120 |
|
113 |
| - q = rand(MersenneTwister(1986), Quaternion) |
| 121 | + q = rand(StableRNG(1986), Quaternion) |
114 | 122 | @test q ≈ q_exp atol = 1e-15
|
115 | 123 |
|
116 |
| - q = rand(MersenneTwister(1986), Quaternion{Float64}) |
| 124 | + q = rand(StableRNG(1986), Quaternion{Float64}) |
117 | 125 | @test q ≈ q_exp atol = 1e-15
|
118 | 126 | end
|
119 | 127 |
|
120 | 128 | @testset "Quaternion (Float32)" begin
|
121 | 129 | q_exp = Quaternion(
|
122 |
| - -0.6805074f0, |
123 |
| - 0.7003348f0, |
124 |
| - -0.2020037f0, |
125 |
| - -0.07506891f0 |
| 130 | + 0.7511563f0, |
| 131 | + 0.037511066f0, |
| 132 | + 0.5362646f0, |
| 133 | + -0.38311547f0, |
126 | 134 | )
|
127 | 135 |
|
128 |
| - q = rand(MersenneTwister(1986), Quaternion{Float32}) |
| 136 | + q = rand(StableRNG(1986), Quaternion{Float32}) |
129 | 137 | @test q ≈ q_exp atol = 1e-15
|
130 | 138 | end
|
0 commit comments