30 #include <gtest/gtest.h> 34 static const double EPS = 1.0e-6;
36 TEST(TestMotionPredictionModelDifferentialDrive, predictWithoutNoise)
43 odom_prev.
rot_ * relative_quat);
54 predictor.
setOdoms(odom_prev, odom_current, 1.0);
57 const auto expected_state_pos = state_trans + state_quat * relative_trans;
58 EXPECT_NEAR(state.
pos_.
x_, expected_state_pos.x_,
EPS);
59 EXPECT_NEAR(state.
pos_.
y_, expected_state_pos.y_,
EPS);
60 EXPECT_NEAR(state.
pos_.
z_, expected_state_pos.z_,
EPS);
62 const mcl_3dl::Quat expected_state_rot = state_quat * relative_quat;
63 EXPECT_NEAR(state.
rot_.
x_, expected_state_rot.
x_,
EPS);
64 EXPECT_NEAR(state.
rot_.
y_, expected_state_rot.
y_,
EPS);
65 EXPECT_NEAR(state.
rot_.
z_, expected_state_rot.
z_,
EPS);
66 EXPECT_NEAR(state.
rot_.
w_, expected_state_rot.
w_,
EPS);
77 TEST(TestMotionPredictionModelDifferentialDrive, predictWithoutRotation)
80 const float relative_trans_norm = relative_trans.
norm();
86 const float state_yaw_angle = 0.3;
94 const float err_integ_multiply = 0.9;
96 predictor.
setOdoms(odom_prev, odom_current, 1.0);
99 const auto expected_state_pos = state_trans + state_quat * relative_trans * (1.0 + state.
noise_ll_);
100 EXPECT_NEAR(state.
pos_.
x_, expected_state_pos.x_,
EPS);
101 EXPECT_NEAR(state.
pos_.
y_, expected_state_pos.y_,
EPS);
102 EXPECT_NEAR(state.
pos_.
z_, expected_state_pos.z_,
EPS);
104 const float yaw_diff = state.
noise_la_ * relative_trans_norm;
106 EXPECT_NEAR(state.
rot_.
x_, expected_state_quat.
x_,
EPS);
107 EXPECT_NEAR(state.
rot_.
y_, expected_state_quat.
y_,
EPS);
108 EXPECT_NEAR(state.
rot_.
z_, expected_state_quat.
z_,
EPS);
109 EXPECT_NEAR(state.
rot_.
w_, expected_state_quat.
w_,
EPS);
111 const auto expected_odom_err_integ_lin = (relative_trans * state.
noise_ll_) * err_integ_multiply;
116 const float expected_odom_err_integ_acc_z = yaw_diff * err_integ_multiply;
122 TEST(TestMotionPredictionModelDifferentialDrive, predictWithoutTranslationAndRollPitch)
124 const float relative_yaw_angle = 0.2;
131 const float state_yaw_angle = 0.3;
139 const float err_integ_multiply = 1.0 - (1.0 / 10.0);
141 predictor.
setOdoms(odom_prev, odom_current, 1.0);
144 const auto expected_state_pos =
146 EXPECT_NEAR(state.
pos_.
x_, expected_state_pos.x_,
EPS);
147 EXPECT_NEAR(state.
pos_.
y_, expected_state_pos.y_,
EPS);
148 EXPECT_NEAR(state.
pos_.
z_, expected_state_pos.z_,
EPS);
150 const float yaw_diff = state.
noise_aa_ * relative_yaw_angle;
151 const mcl_3dl::Quat expected_state_quat(mcl_3dl::Vec3(0.0, 0.0, relative_yaw_angle + state_yaw_angle + yaw_diff));
152 EXPECT_NEAR(state.
rot_.
x_, expected_state_quat.
x_,
EPS);
153 EXPECT_NEAR(state.
rot_.
y_, expected_state_quat.
y_,
EPS);
154 EXPECT_NEAR(state.
rot_.
z_, expected_state_quat.
z_,
EPS);
155 EXPECT_NEAR(state.
rot_.
w_, expected_state_quat.
w_,
EPS);
157 const auto expected_odom_err_integ_lin =
158 mcl_3dl::Vec3(state.
noise_al_ * relative_yaw_angle, 0.0, 0.0) * err_integ_multiply;
163 const float expected_odom_err_integ_acc_z = yaw_diff * err_integ_multiply;
169 TEST(TestMotionPredictionModelDifferentialDrive, predictWithoutRollPitch)
172 const float relative_trans_norm = relative_trans.
norm();
173 const float relative_yaw_angle = 0.2;
178 odom_prev.
rot_ * relative_quat);
181 const float state_yaw_angle = 0.3;
189 const float err_integ_multiply = 1.0 - (1.0 / 10.0);
191 predictor.
setOdoms(odom_prev, odom_current, 1.0);
194 const auto expected_state_pos = state_trans +
195 state_quat * (relative_trans * (1.0 + state.
noise_ll_) +
197 EXPECT_NEAR(state.
pos_.
x_, expected_state_pos.x_,
EPS);
198 EXPECT_NEAR(state.
pos_.
y_, expected_state_pos.y_,
EPS);
199 EXPECT_NEAR(state.
pos_.
z_, expected_state_pos.z_,
EPS);
201 const double yaw_diff = state.
noise_la_ * relative_trans_norm + state.
noise_aa_ * relative_yaw_angle;
203 EXPECT_NEAR(state.
rot_.
x_, expected_state_quat.
x_,
EPS);
204 EXPECT_NEAR(state.
rot_.
y_, expected_state_quat.
y_,
EPS);
205 EXPECT_NEAR(state.
rot_.
z_, expected_state_quat.
z_,
EPS);
206 EXPECT_NEAR(state.
rot_.
w_, expected_state_quat.
w_,
EPS);
208 const auto expected_odom_err_integ_lin =
215 const float expected_odom_err_integ_acc_z = yaw_diff * err_integ_multiply;
221 int main(
int argc,
char** argv)
223 testing::InitGoogleTest(&argc, argv);
225 return RUN_ALL_TESTS();
int main(int argc, char **argv)
TEST(TestMotionPredictionModelDifferentialDrive, predictWithoutNoise)
mcl_3dl::Vec3 odom_err_integ_ang_
mcl_3dl::Vec3 odom_err_integ_lin_
void setOdoms(const State6DOF &odom_prev, const State6DOF &odom_current, const float time_diff) final
void predict(State6DOF &s) const final