imu.cpp
Go to the documentation of this file.
00001 /* +------------------------------------------------------------------------+
00002    |                     Mobile Robot Programming Toolkit (MRPT)            |
00003    |                          http://www.mrpt.org/                          |
00004    |                                                                        |
00005    | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file     |
00006    | See: http://www.mrpt.org/Authors - All rights reserved.                |
00007    | Released under BSD License. See details in http://www.mrpt.org/License |
00008    +------------------------------------------------------------------------+ */
00009 
00010 /*---------------------------------------------------------------
00011         APPLICATION: mrpt_ros bridge
00012         FILE: imu.cpp
00013         AUTHOR: Raghavender Sahdev <raghavendersahdev@gmail.com>
00014   ---------------------------------------------------------------*/
00015 
00016 #include "mrpt_bridge/imu.h"
00017 
00018 using namespace std;
00019 
00020 namespace mrpt_bridge
00021 {
00022     /************************************************************************
00023     *                                           ros2mrpt                                                                *
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         // NEED TO WRITE CODE FOR COVARIANCE
00041         return true;
00042     }
00043 
00044     /************************************************************************
00045     *                                           mrpt2ros                                                                *
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         // msg.angular_velocity_covariance
00068         return true;
00069     }
00070 
00071 }
00072 
00073 
00074 /*
00075 std_msgs/Header header
00076 geometry_msgs/Quaternion orientation
00077 float64[9] orientation_covariance
00078 geometry_msgs/Vector3 angular_velocity
00079 float64[9] angular_velocity_covariance
00080 geometry_msgs/Vector3 linear_acceleration
00081 float64[9] linear_acceleration_covariance
00082  */


mrpt_bridge
Author(s): Markus Bader , Raphael Zack
autogenerated on Fri Apr 27 2018 05:10:54