17 #ifndef MSF_IMUHANDLER_ROS_H_
18 #define MSF_IMUHANDLER_ROS_H_
24 template<
typename EKFState_T>
32 const std::string& topic_namespace,
33 const std::string& parameternamespace)
34 :
IMUHandler<EKFState_T>(mng, topic_namespace, parameternamespace) {
36 ros::NodeHandle nh(topic_namespace);
42 subState_ = nh.subscribe(
"hl_state_input", 10,
53 .setHLStateBuffer(*msg);
56 msf_core::Vector3 linacc;
57 linacc << msg->linear_acceleration.x, msg->linear_acceleration.y, msg
58 ->linear_acceleration.z;
60 msf_core::Vector3 angvel;
61 angvel << msg->angular_velocity.x, msg->angular_velocity.y, msg
64 int32_t flag = msg->flag;
67 flag = sensor_fusion_comm::ExtEkf::ignore_state;
69 bool isnumeric =
true;
70 if (flag == sensor_fusion_comm::ExtEkf::current_state) {
72 Eigen::Map<
const Eigen::Matrix<float, 10, 1> >(msg->state.data()),
73 "before prediction p,v,q");
77 msf_core::Vector3
p,
v;
80 p = Eigen::Matrix<double, 3, 1>(msg->state[0], msg->state[1],
82 v = Eigen::Matrix<double, 3, 1>(msg->state[3], msg->state[4],
84 q = Eigen::Quaternion<double>(msg->state[6], msg->state[7], msg->state[8],
88 bool is_already_propagated =
false;
89 if (flag == sensor_fusion_comm::ExtEkf::current_state && isnumeric) {
90 is_already_propagated =
true;
93 this->
process_state(linacc, angvel, p, v, q, is_already_propagated,
94 msg->header.stamp.toSec(), msg->header.seq);
99 msf_core::Vector3 linacc;
100 linacc << msg->acceleration.x, msg->acceleration.y, msg->acceleration.z;
102 msf_core::Vector3 angvel;
103 angvel << msg->angular_velocity.x, msg->angular_velocity.y, msg
104 ->angular_velocity.z;
106 this->
process_imu(linacc, angvel, msg->header.stamp.toSec(),
112 static int lastseq = -1;
113 if ((
int) msg->header.seq != lastseq + 1 && lastseq != -1) {
115 "msf_core: imu message drop curr seq:" << msg->header.seq
116 <<
" expected: " << lastseq + 1);
118 lastseq = msg->header.seq;
120 msf_core::Vector3 linacc;
121 linacc << msg->linear_acceleration.x, msg->linear_acceleration.y, msg
122 ->linear_acceleration.z;
124 msf_core::Vector3 angvel;
125 angvel << msg->angular_velocity.x, msg->angular_velocity.y, msg
126 ->angular_velocity.z;
128 this->
process_imu(linacc, angvel, msg->header.stamp.toSec(),