annop niponsiritham / ros_lib_kinetic

Dependencies:   BufferedSerial

Dependents:   mobile_robot mobile_robot_ver2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MagneticField.h Source File

MagneticField.h

00001 #ifndef _ROS_sensor_msgs_MagneticField_h
00002 #define _ROS_sensor_msgs_MagneticField_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 #include "geometry_msgs/Vector3.h"
00010 
00011 namespace sensor_msgs
00012 {
00013 
00014   class MagneticField : public ros::Msg
00015   {
00016     public:
00017       typedef std_msgs::Header _header_type;
00018       _header_type header;
00019       typedef geometry_msgs::Vector3 _magnetic_field_type;
00020       _magnetic_field_type magnetic_field;
00021       double magnetic_field_covariance[9];
00022 
00023     MagneticField():
00024       header(),
00025       magnetic_field(),
00026       magnetic_field_covariance()
00027     {
00028     }
00029 
00030     virtual int serialize(unsigned char *outbuffer) const
00031     {
00032       int offset = 0;
00033       offset += this->header.serialize(outbuffer + offset);
00034       offset += this->magnetic_field.serialize(outbuffer + offset);
00035       for( uint32_t i = 0; i < 9; i++){
00036       union {
00037         double real;
00038         uint64_t base;
00039       } u_magnetic_field_covariancei;
00040       u_magnetic_field_covariancei.real = this->magnetic_field_covariance[i];
00041       *(outbuffer + offset + 0) = (u_magnetic_field_covariancei.base >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (u_magnetic_field_covariancei.base >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (u_magnetic_field_covariancei.base >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (u_magnetic_field_covariancei.base >> (8 * 3)) & 0xFF;
00045       *(outbuffer + offset + 4) = (u_magnetic_field_covariancei.base >> (8 * 4)) & 0xFF;
00046       *(outbuffer + offset + 5) = (u_magnetic_field_covariancei.base >> (8 * 5)) & 0xFF;
00047       *(outbuffer + offset + 6) = (u_magnetic_field_covariancei.base >> (8 * 6)) & 0xFF;
00048       *(outbuffer + offset + 7) = (u_magnetic_field_covariancei.base >> (8 * 7)) & 0xFF;
00049       offset += sizeof(this->magnetic_field_covariance[i]);
00050       }
00051       return offset;
00052     }
00053 
00054     virtual int deserialize(unsigned char *inbuffer)
00055     {
00056       int offset = 0;
00057       offset += this->header.deserialize(inbuffer + offset);
00058       offset += this->magnetic_field.deserialize(inbuffer + offset);
00059       for( uint32_t i = 0; i < 9; i++){
00060       union {
00061         double real;
00062         uint64_t base;
00063       } u_magnetic_field_covariancei;
00064       u_magnetic_field_covariancei.base = 0;
00065       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00066       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00067       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00068       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00069       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00070       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00071       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00072       u_magnetic_field_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00073       this->magnetic_field_covariance[i] = u_magnetic_field_covariancei.real;
00074       offset += sizeof(this->magnetic_field_covariance[i]);
00075       }
00076      return offset;
00077     }
00078 
00079     const char * getType(){ return "sensor_msgs/MagneticField"; };
00080     const char * getMD5(){ return "2f3b0b43eed0c9501de0fa3ff89a45aa"; };
00081 
00082   };
00083 
00084 }
00085 #endif