Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "mrpt_bridge/imu.h"
00017
00018 using namespace std;
00019
00020 namespace mrpt_bridge
00021 {
00022
00023
00024
00025 bool imu::ros2mrpt(const sensor_msgs::Imu &msg, CObservationIMU obj)
00026 {
00027 obj.rawMeasurements.at(IMU_ORI_QUAT_X) = msg.orientation.x;
00028 obj.rawMeasurements.at(IMU_ORI_QUAT_Y) = msg.orientation.y;
00029 obj.rawMeasurements.at(IMU_ORI_QUAT_Z) = msg.orientation.z;
00030 obj.rawMeasurements.at(IMU_ORI_QUAT_W) = msg.orientation.w;
00031
00032 obj.rawMeasurements.at(IMU_X_ACC_GLOBAL) = msg.linear_acceleration.x;
00033 obj.rawMeasurements.at(IMU_Y_ACC_GLOBAL) = msg.linear_acceleration.y;
00034 obj.rawMeasurements.at(IMU_Z_ACC_GLOBAL) = msg.linear_acceleration.z;
00035
00036 obj.rawMeasurements.at(IMU_X_VEL) = msg.angular_velocity.x;
00037 obj.rawMeasurements.at(IMU_Y_VEL) = msg.angular_velocity.y;
00038 obj.rawMeasurements.at(IMU_Z_VEL) = msg.angular_velocity.z;
00039
00040
00041 return true;
00042 }
00043
00044
00045
00046
00047 bool imu::mrpt2ros(const CObservationIMU &obj, const std_msgs::Header &msg_header, sensor_msgs::Imu &msg)
00048 {
00049 msg.header = msg_header;
00050
00051 vector<double> measurements = obj.rawMeasurements;
00052 msg.orientation.x = measurements.at(IMU_ORI_QUAT_X);
00053 msg.orientation.y = measurements.at(IMU_ORI_QUAT_Y);
00054 msg.orientation.z = measurements.at(IMU_ORI_QUAT_Z);
00055 msg.orientation.w = measurements.at(IMU_ORI_QUAT_W);
00056
00057
00059 msg.linear_acceleration.x = measurements.at(IMU_X_ACC_GLOBAL);
00060 msg.linear_acceleration.y = measurements.at(IMU_Y_ACC_GLOBAL);
00061 msg.linear_acceleration.z = measurements.at(IMU_Z_ACC_GLOBAL);
00062
00063 msg.angular_velocity.x = measurements.at(IMU_X_VEL);
00064 msg.angular_velocity.y = measurements.at(IMU_Y_VEL);
00065 msg.angular_velocity.z = measurements.at(IMU_Z_VEL);
00066
00067
00068 return true;
00069 }
00070
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082