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 }
00042
00043
00044
00045
00046 bool imu::mrpt2ros(const CObservationIMU &obj, const std_msgs::Header &msg_header, sensor_msgs::Imu &msg)
00047 {
00048 msg.header = msg_header;
00049
00050 vector<double> measurements = obj.rawMeasurements;
00051 msg.orientation.x = measurements.at(IMU_ORI_QUAT_X);
00052 msg.orientation.y = measurements.at(IMU_ORI_QUAT_Y);
00053 msg.orientation.z = measurements.at(IMU_ORI_QUAT_Z);
00054 msg.orientation.w = measurements.at(IMU_ORI_QUAT_W);
00055
00056
00058 msg.linear_acceleration.x = measurements.at(IMU_X_ACC_GLOBAL);
00059 msg.linear_acceleration.y = measurements.at(IMU_Y_ACC_GLOBAL);
00060 msg.linear_acceleration.z = measurements.at(IMU_Z_ACC_GLOBAL);
00061
00062 msg.angular_velocity.x = measurements.at(IMU_X_VEL);
00063 msg.angular_velocity.y = measurements.at(IMU_Y_VEL);
00064 msg.angular_velocity.z = measurements.at(IMU_Z_VEL);
00065
00067 msg.angular_velocity_covariance[0,0] = measurements.at(IMU_X_VEL);
00068 msg.angular_velocity_covariance[1,1] = measurements.at(IMU_Y_VEL);
00069 msg.angular_velocity_covariance[2,2] = measurements.at(IMU_Z_VEL);
00070
00071 msg.linear_acceleration_covariance[0,0] = measurements.at(IMU_X_ACC_GLOBAL);
00072 msg.linear_acceleration_covariance[1,1] = measurements.at(IMU_Y_ACC_GLOBAL);
00073 msg.linear_acceleration_covariance[2,2] = measurements.at(IMU_Z_ACC_GLOBAL);
00074
00075
00076
00077
00078
00079 }
00080
00081 }
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092