22 #ifndef OV_TYPE_TYPE_IMU_H
23 #define OV_TYPE_TYPE_IMU_H
44 _v = std::shared_ptr<Vec>(
new Vec(3));
45 _bg = std::shared_ptr<Vec>(
new Vec(3));
46 _ba = std::shared_ptr<Vec>(
new Vec(3));
49 Eigen::VectorXd imu0 = Eigen::VectorXd::Zero(16, 1);
66 _pose->set_local_id(new_id);
67 _v->set_local_id(
_pose->id() + ((new_id != -1) ?
_pose->size() : 0));
68 _bg->set_local_id(
_v->id() + ((new_id != -1) ?
_v->size() : 0));
69 _ba->set_local_id(
_bg->id() + ((new_id != -1) ?
_bg->size() : 0));
78 void update(
const Eigen::VectorXd &dx)
override {
80 assert(dx.rows() ==
_size);
82 Eigen::Matrix<double, 16, 1> newX =
_value;
84 Eigen::Matrix<double, 4, 1> dq;
85 dq << .5 * dx.block(0, 0, 3, 1), 1.0;
89 newX.block(4, 0, 3, 1) += dx.block(3, 0, 3, 1);
91 newX.block(7, 0, 3, 1) += dx.block(6, 0, 3, 1);
92 newX.block(10, 0, 3, 1) += dx.block(9, 0, 3, 1);
93 newX.block(13, 0, 3, 1) += dx.block(12, 0, 3, 1);
110 std::shared_ptr<Type>
clone()
override {
111 auto Clone = std::shared_ptr<Type>(
new IMU());
112 Clone->set_value(
value());
113 Clone->set_fej(
fej());
133 Eigen::Matrix<double, 3, 3>
Rot()
const {
return _pose->Rot(); }
136 Eigen::Matrix<double, 3, 3>
Rot_fej()
const {
return _pose->Rot_fej(); }
139 Eigen::Matrix<double, 4, 1>
quat()
const {
return _pose->quat(); }
145 Eigen::Matrix<double, 3, 1>
pos()
const {
return _pose->pos(); }
148 Eigen::Matrix<double, 3, 1>
pos_fej()
const {
return _pose->pos_fej(); }
151 Eigen::Matrix<double, 3, 1>
vel()
const {
return _v->value(); }
154 Eigen::Matrix<double, 3, 1>
vel_fej()
const {
return _v->fej(); }
157 Eigen::Matrix<double, 3, 1>
bias_g()
const {
return _bg->value(); }
163 Eigen::Matrix<double, 3, 1>
bias_a()
const {
return _ba->value(); }
172 std::shared_ptr<JPLQuat>
q() {
return _pose->q(); }
175 std::shared_ptr<Vec>
p() {
return _pose->p(); }
178 std::shared_ptr<Vec>
v() {
return _v; }
181 std::shared_ptr<Vec>
bg() {
return _bg; }
184 std::shared_ptr<Vec>
ba() {
return _ba; }
191 std::shared_ptr<Vec>
_v;
205 assert(new_value.rows() == 16);
206 assert(new_value.cols() == 1);
208 _pose->set_value(new_value.block(0, 0, 7, 1));
209 _v->set_value(new_value.block(7, 0, 3, 1));
210 _bg->set_value(new_value.block(10, 0, 3, 1));
211 _ba->set_value(new_value.block(13, 0, 3, 1));
222 assert(new_value.rows() == 16);
223 assert(new_value.cols() == 1);
225 _pose->set_fej(new_value.block(0, 0, 7, 1));
226 _v->set_fej(new_value.block(7, 0, 3, 1));
227 _bg->set_fej(new_value.block(10, 0, 3, 1));
228 _ba->set_fej(new_value.block(13, 0, 3, 1));
236 #endif // OV_TYPE_TYPE_IMU_H