@@ -162,6 +162,44 @@ TEST_F(EkfExternalVisionTest, visionVelocityResetWithAlignment)
162162 EXPECT_TRUE (reset_logging_checker.isVelocityDeltaLoggedCorrectly (0 .01f ));
163163}
164164
165+ TEST_F (EkfExternalVisionTest, visionHorizontalPositionReset)
166+ {
167+ const Vector3f simulated_position (8 .3f , -1 .0f , 0 .0f );
168+
169+ _sensor_simulator._vio .setPosition (simulated_position);
170+ _ekf_wrapper.enableExternalVisionPositionFusion ();
171+ _sensor_simulator.startExternalVision ();
172+ _sensor_simulator.runMicroseconds (2e5 );
173+
174+ // THEN: a reset to Vision velocity should be done
175+ const Vector3f estimated_position = _ekf->getPosition ();
176+ EXPECT_TRUE (isEqual (estimated_position, simulated_position, 1e-5f ));
177+ }
178+
179+ TEST_F (EkfExternalVisionTest, visionHorizontalPositionResetWithAlignment)
180+ {
181+ // GIVEN: Drone is pointing north, and we use mag (ROTATE_EV)
182+ // Heading of drone in EKF frame is 0°
183+
184+ // WHEN: Vision frame is rotate +90°. The reported heading is -90°
185+ Quatf vision_to_ekf (Eulerf (0 .0f ,0 .0f ,math::radians (-90 .0f )));
186+ _sensor_simulator._vio .setOrientation (vision_to_ekf.inversed ());
187+ _ekf_wrapper.enableExternalVisionAlignment ();
188+
189+ const Vector3f simulated_position_in_vision_frame (8 .3f , -1 .0f , 0 .0f );
190+ const Vector3f simulated_position_in_ekf_frame =
191+ Dcmf (vision_to_ekf) * simulated_position_in_vision_frame;
192+ _sensor_simulator._vio .setPosition (simulated_position_in_vision_frame);
193+ _ekf_wrapper.enableExternalVisionPositionFusion ();
194+ _sensor_simulator.startExternalVision ();
195+ _sensor_simulator.runMicroseconds (2e5 );
196+
197+ // THEN: a reset to Vision velocity should be done
198+ const Vector3f estimated_position_in_ekf_frame = _ekf->getPosition ();
199+ EXPECT_TRUE (isEqual (estimated_position_in_ekf_frame, simulated_position_in_ekf_frame, 1e-2f ));
200+ }
201+
202+
165203TEST_F (EkfExternalVisionTest, visionVarianceCheck)
166204{
167205 const Vector3f velVar_init = _ekf->getVelocityVariance ();
0 commit comments