Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit c19f40e

Browse files
kamilritzbresch
authored andcommitted
Add reset position test for GPS and VISION
1 parent 78a6b9f commit c19f40e

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

test/test_EKF_externalVision.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
165203
TEST_F(EkfExternalVisionTest, visionVarianceCheck)
166204
{
167205
const Vector3f velVar_init = _ekf->getVelocityVariance();

test/test_EKF_gps.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,26 @@ TEST_F(EkfGpsTest, resetToGpsVelocity)
117117
EXPECT_TRUE(reset_logging_checker.isVerticalVelocityResetCounterIncreasedBy(1));
118118
EXPECT_TRUE(reset_logging_checker.isVelocityDeltaLoggedCorrectly(1e-2f));
119119
}
120+
121+
TEST_F(EkfGpsTest, resetToGpsPosition)
122+
{
123+
// GIVEN:EKF that fuses GPS
124+
// and has gps checks already passed
125+
const Vector3f previous_position = _ekf->getPosition();
126+
127+
// WHEN: stopping GPS fusion
128+
_sensor_simulator.stopGps();
129+
_sensor_simulator.runSeconds(11);
130+
131+
// AND: simulate jump in position
132+
_sensor_simulator.startGps();
133+
const Vector3f simulated_position_change(2.0f, -1.0f, 0.f);
134+
_sensor_simulator._gps.stepHorizontalPositionByMeters(
135+
Vector2f(simulated_position_change));
136+
_sensor_simulator.runMicroseconds(1e5);
137+
138+
// THEN: a reset to the new GPS position should be done
139+
const Vector3f estimated_position = _ekf->getPosition();
140+
EXPECT_TRUE(isEqual(estimated_position,
141+
previous_position + simulated_position_change, 1e-2f));
142+
}

0 commit comments

Comments
 (0)