35 #include <multisense_ros/RawImuData.h>
36 #include <std_msgs/Time.h>
47 void imuCB(
const imu::Header& header,
void* userDataP)
48 {
reinterpret_cast<Imu*
>(userDataP)->imuCallback(header); }
53 Imu::Imu(
Channel* driver, std::string tf_prefix) :
56 imu_nh_(device_nh_,
"imu"),
61 accelerometer_vector_pub_(),
62 gyroscope_vector_pub_(),
63 magnetometer_vector_pub_(),
66 total_subscribers_(0),
67 tf_prefix_(tf_prefix),
68 accel_frameId_(tf_prefix_ +
"/accel"),
69 gyro_frameId_(tf_prefix_ +
"/gyro"),
70 mag_frameId_(tf_prefix_ +
"/mag"),
71 next_gen_camera_(false)
80 imu_message_.linear_acceleration_covariance[0] = 6.98179077e-04;
81 imu_message_.linear_acceleration_covariance[1] = 2.46789341e-06;
82 imu_message_.linear_acceleration_covariance[2] =-2.50549745e-06;
83 imu_message_.linear_acceleration_covariance[3] = 2.46789341e-06;
84 imu_message_.linear_acceleration_covariance[4] = 5.02177646e-04;
85 imu_message_.linear_acceleration_covariance[5] = 5.26265558e-05;
86 imu_message_.linear_acceleration_covariance[6] =-2.50549745e-06;
87 imu_message_.linear_acceleration_covariance[7] = 5.26265558e-05;
88 imu_message_.linear_acceleration_covariance[8] = 9.22796937e-04;
90 imu_message_.angular_velocity_covariance[0] = 8.79376936e-06;
91 imu_message_.angular_velocity_covariance[1] = -3.56007627e-07;
92 imu_message_.angular_velocity_covariance[2] = 2.22611968e-07;
93 imu_message_.angular_velocity_covariance[3] = -3.56007627e-07;
94 imu_message_.angular_velocity_covariance[4] = 8.78939245e-06;
95 imu_message_.angular_velocity_covariance[5] = -8.08367486e-07;
96 imu_message_.angular_velocity_covariance[6] = 1.33981577e-05;
97 imu_message_.angular_velocity_covariance[7] = 2.22611968e-07;
98 imu_message_.angular_velocity_covariance[8] = -8.08367486e-07;
105 if (Status_Ok != status) {
106 ROS_ERROR(
"IMU: failed to query device info: %s",
107 Channel::statusString(status));
112 ROS_INFO(
"hardware does not support an IMU");
118 if (Status_Ok != status) {
119 ROS_ERROR(
"IMU: Unable to query sensor firmware version: %s",
120 Channel::statusString(status));
130 ROS_WARN(
"IMU support requires sensor firmware v2.3 or greater (sensor is running v%d.%d)",
200 std::vector<imu::Sample>::const_iterator it =
header.samples.begin();
210 for(; it !=
header.samples.end(); ++it) {
214 multisense_ros::RawImuData
msg;
215 geometry_msgs::Vector3Stamped vector_msg;
218 1000 *
s.timeMicroSeconds);
223 vector_msg.header.stamp =
msg.time_stamp;
224 vector_msg.vector.x =
s.x;
225 vector_msg.vector.y =
s.y;
226 vector_msg.vector.z =
s.z;
233 const bool publish_previous_imu_message = (
s.type == imu::Sample::Type_Accelerometer ||
234 s.type == imu::Sample::Type_Gyroscope) &&
237 if (publish_previous_imu_message && imu_subscribers > 0)
243 case imu::Sample::Type_Accelerometer:
251 if (accel_subscribers > 0)
254 if (accel_vector_subscribers > 0) {
260 case imu::Sample::Type_Gyroscope:
280 if (gyro_subscribers > 0)
283 if (gyro_vector_subscribers > 0) {
289 case imu::Sample::Type_Magnetometer:
292 if (mag_subscribers > 0)
295 if (mag_vector_subscribers > 0) {
311 if (Status_Ok != status)
312 ROS_ERROR(
"IMU: failed to start streams: %s",
313 Channel::statusString(status));
331 if (Status_Ok != status)
332 ROS_ERROR(
"IMU: failed to stop streams: %s",
333 Channel::statusString(status));