36 #include <sciplot/sciplot.hpp>
60 state1.
pose = manif::SE3<T>::Random();
62 state2.
pose = manif::SE3<T>::Random();
70 10000 * std::numeric_limits<T>::epsilon())
71 << (state2.
pose - state3.
pose).coeffs().norm();
75 ARMARX_CHECK((sigma2 - sigma).
norm() < 10000 * std::numeric_limits<T>::epsilon())
76 << (sigma2 - sigma).
norm();
88 manif::SO3<T> rot = manif::SO3<T>(0, 0,
angle);
90 manif::SE3<T> pose(pos, rot);
92 manif::SE3Tangent<T> tangent = pose.log();
93 ARMARX_CHECK((tangent.coeffs().segment(0, 3) - pos).norm() < 1e-6);
100 std::vector<SystemModelT::ControlT>& omegas)
105 states.push_back(state);
109 const T t_prev =
dt * (i - 1);
116 manif::SE3Tangent<T> tangent(states.at(i - 1).pose.log());
117 ARMARX_CHECK((states.at(i - 1).pose.translation() - pos).norm() < 0.1);
121 const Vector acc_prev(-std::sin(t_prev *
c) * (
c *
c), -std::cos(t_prev *
c) * (
c *
c), 0);
124 manif::SO3<T> rot = manif::SO3<T>(roll, pitch, yaw);
132 control.velocity.coeffs() << state.
pose.asSO3().inverse().act(vel), angular_velocity;
135 state,
control, SystemModelT::ControlNoiseT::Zero(),
dt);
136 manif::SE3Tangent<T> pro_tangent = propagated.
pose.log();
137 T pos_diff1 = (propagated.
pose.translation() - pos).
norm();
140 <<
"Position is not the same: " << pos <<
" vs " << propagated.
pose.translation();
144 state.
pose = manif::SE3<T>(pos, rot);
145 states.push_back(propagated);
147 tangent = state.
pose.log();
160 std::vector<SystemModelT::ObsT>& observations)
162 for (
const auto& state : states)
166 true_obs = state.pose.log().coeffs();
170 observations.push_back(obs +
obs_noise_std * SystemModelT::ObsT::Random());
182 std::vector<SystemModelT::StateT> states;
183 std::vector<SystemModelT::ControlT> omegas;
184 std::vector<SystemModelT::ObsT> observations;
188 ARMARX_INFO <<
"Num States: " << states.size() <<
" Num Controls: " << omegas.size()
189 <<
" Num Obs: " << observations.size();
211 std::vector<SystemModelT::StateT> ukf_states;
212 std::vector<UnscentedKalmanFilter<SystemModelT>::StateCovT> ukf_Ps;
213 ukf_states.push_back(state0);
214 ukf_Ps.push_back(P0);
216 std::vector<T> x_true, y_true, z_true, x_obs, y_obs, z_obs, x_ukf, y_ukf, z_ukf;
217 std::vector<T> vx_true, vy_true, vz_true, vx_ukf, vy_ukf, vz_ukf;
218 std::vector<T> a_true, b_true, c_true, a_obs, b_obs, c_obs, a_ukf, b_ukf, c_ukf;
227 if ((i - 1) % 100 == 0)
230 ukf.
update(observations.at(i));
236 << (states.at(i).pose - current_state.
pose).coeffs().norm();
244 x_true.push_back(states.at(i).pose.log().coeffs()(0));
245 y_true.push_back(states.at(i).pose.log().coeffs()(1));
246 z_true.push_back(states.at(i).pose.log().coeffs()(2));
248 x_obs.push_back(observations.at(i)(0));
249 y_obs.push_back(observations.at(i)(1));
250 z_obs.push_back(observations.at(i)(2));
264 a_true.push_back(states.at(i).pose.log().coeffs()(3));
265 b_true.push_back(states.at(i).pose.log().coeffs()(4));
266 c_true.push_back(states.at(i).pose.log().coeffs()(5));
268 a_obs.push_back(observations.at(i)(3, 0));
269 b_obs.push_back(observations.at(i)(4, 0));
270 c_obs.push_back(observations.at(i)(5, 0));
284 sciplot::Plot3D position_plot;
285 sciplot::Plot pos_plot;
287 position_plot.drawCurve(x_true, y_true, z_true).label(
"True").lineWidth(1);
288 position_plot.drawCurve(x_obs, y_obs, z_obs).label(
"Obs").lineWidth(1);
289 position_plot.drawCurve(x_ukf, y_ukf, z_ukf).label(
"UKF").lineWidth(1);
291 pos_plot.drawCurve(x_true, y_true).label(
"True");
292 pos_plot.drawCurve(x_obs, y_obs).label(
"Obs");
293 pos_plot.drawCurve(x_ukf, y_ukf).label(
"UKF");
301 sciplot::Plot3D orientation_plot;
303 orientation_plot.drawCurve(a_true, b_true, c_true).label(
"True").lineWidth(1);
304 orientation_plot.drawCurve(a_obs, b_obs, c_obs).label(
"Obs").lineWidth(1);
305 orientation_plot.drawCurve(a_ukf, b_ukf, c_ukf).label(
"UKF").lineWidth(1);
308 position_plot.show();
310 orientation_plot.show();