@@ -24,16 +24,39 @@ TEST(TestPseudorangeFactor, Constructor) {
2424 factor.evaluateError (Point3::Zero (), 0.0 , Hpos, Hbias)[0 ];
2525 EXPECT_DOUBLES_EQUAL (0.0 , error, 1e-9 );
2626
27- // Jacobians are technically undefined if the receiver and satellite positions
28- // are the same. So make sure this corner-case does not numerically explode:
29- CHECK (!Hpos.array ().isNaN ().any ());
30- CHECK (!Hbias.array ().isNaN ().any ());
27+ // Derivatives are technically undefined if the receiver and satellite
28+ // positions are the same (hopefully that's never the case in reality). But
29+ // for all intents and purposes, zero-valued derivatives can substitute for
30+ // undefined gradient at that singularity. So make sure this corner-case does
31+ // not numerically explode:
32+ EXPECT (!Hpos.array ().isNaN ().any ());
33+ EXPECT (!Hbias.array ().isNaN ().any ());
3134 EXPECT_DOUBLES_EQUAL (Hpos.norm (), 0.0 , 1e-9 );
32- // Clock bias should always be speed-of-light in vacuum:
35+ // Clock bias derivative should always be speed-of-light in vacuum:
3336 EXPECT_DOUBLES_EQUAL (Hbias.norm (), 299792458.0 , 1e-9 );
3437}
3538
36- TEST (TestPseudorangeFactor, Jacobians) {
39+ // *************************************************************************
40+ TEST (TestPseudorangeFactor, Jacobians1) {
41+ // Synthetic example with exact error/derivatives:
42+ const auto factor = PseudorangeFactor (
43+ Key (0 ), Key (1 ), // Receiver position and clock bias keys.
44+ 4.0 , // Measured pseudorange.
45+ // Satellite position:
46+ Vector3 (0.0 , 0.0 , 3.0 ),
47+ 0.0 // Sat clock drift bias.
48+ );
49+ const double error = factor.evaluateError (Vector3::Zero (), 0.0 )[0 ];
50+ EXPECT_DOUBLES_EQUAL (-1.0 , error, 1e-6 );
51+
52+ Values values;
53+ values.insert (Key (0 ), Vector3 (1.0 , 2.0 , 3.0 ));
54+ values.insert (Key (1 ), 0.0 );
55+ EXPECT_CORRECT_FACTOR_JACOBIANS (factor, values, 1e-3 , 1e-5 );
56+ }
57+
58+ // *************************************************************************
59+ TEST (TestPseudorangeFactor, Jacobians2) {
3760 // Example values borrowed from `SinglePointPositioningExample.ipynb`:
3861 const auto factor = PseudorangeFactor (
3962 Key (0 ), Key (1 ), // Receiver position and clock bias keys.
@@ -50,6 +73,30 @@ TEST(TestPseudorangeFactor, Jacobians) {
5073 EXPECT_CORRECT_FACTOR_JACOBIANS (factor, values, 1e-3 , 1e-5 );
5174}
5275
76+ // *************************************************************************
77+ TEST (TestPseudorangeFactor, print) {
78+ // Just make sure `print()` doesn't throw errors
79+ // since there's no elegant way to check stdout.
80+ const auto factor = PseudorangeFactor ();
81+ factor.print ();
82+ }
83+
84+ // *************************************************************************
85+ TEST (TestPseudorangeFactor, equals) {
86+ const auto factor1 = PseudorangeFactor ();
87+ const auto factor2 = PseudorangeFactor (1 , 2 , 0.0 , Point3::Zero (), 0.0 );
88+ const auto factor3 =
89+ PseudorangeFactor (1 , 2 , 10.0 , Point3 (1.0 , 2.0 , 3.0 ), 20.0 );
90+
91+ CHECK (factor1.equals (factor1));
92+ CHECK (factor2.equals (factor2));
93+ CHECK (!factor1.equals (factor2));
94+ CHECK (factor2.equals (factor3, 1e99 ));
95+
96+ // Test print:
97+ factor2.print (" factor2" );
98+ }
99+
53100// *************************************************************************
54101int main () {
55102 TestResult tr;
0 commit comments