Go to the documentation of this file.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 std_msgs::Header header;
00018 geometry_msgs::Vector3 magnetic_field;
00019 float magnetic_field_covariance[9];
00020
00021 virtual int serialize(unsigned char *outbuffer) const
00022 {
00023 int offset = 0;
00024 offset += this->header.serialize(outbuffer + offset);
00025 offset += this->magnetic_field.serialize(outbuffer + offset);
00026 for( uint8_t i = 0; i < 9; i++){
00027 int32_t * val_magnetic_field_covariancei = (int32_t *) &(this->magnetic_field_covariance[i]);
00028 int32_t exp_magnetic_field_covariancei = (((*val_magnetic_field_covariancei)>>23)&255);
00029 if(exp_magnetic_field_covariancei != 0)
00030 exp_magnetic_field_covariancei += 1023-127;
00031 int32_t sig_magnetic_field_covariancei = *val_magnetic_field_covariancei;
00032 *(outbuffer + offset++) = 0;
00033 *(outbuffer + offset++) = 0;
00034 *(outbuffer + offset++) = 0;
00035 *(outbuffer + offset++) = (sig_magnetic_field_covariancei<<5) & 0xff;
00036 *(outbuffer + offset++) = (sig_magnetic_field_covariancei>>3) & 0xff;
00037 *(outbuffer + offset++) = (sig_magnetic_field_covariancei>>11) & 0xff;
00038 *(outbuffer + offset++) = ((exp_magnetic_field_covariancei<<4) & 0xF0) | ((sig_magnetic_field_covariancei>>19)&0x0F);
00039 *(outbuffer + offset++) = (exp_magnetic_field_covariancei>>4) & 0x7F;
00040 if(this->magnetic_field_covariance[i] < 0) *(outbuffer + offset -1) |= 0x80;
00041 }
00042 return offset;
00043 }
00044
00045 virtual int deserialize(unsigned char *inbuffer)
00046 {
00047 int offset = 0;
00048 offset += this->header.deserialize(inbuffer + offset);
00049 offset += this->magnetic_field.deserialize(inbuffer + offset);
00050 for( uint8_t i = 0; i < 9; i++){
00051 uint32_t * val_magnetic_field_covariancei = (uint32_t*) &(this->magnetic_field_covariance[i]);
00052 offset += 3;
00053 *val_magnetic_field_covariancei = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00054 *val_magnetic_field_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00055 *val_magnetic_field_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00056 *val_magnetic_field_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00057 uint32_t exp_magnetic_field_covariancei = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00058 exp_magnetic_field_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00059 if(exp_magnetic_field_covariancei !=0)
00060 *val_magnetic_field_covariancei |= ((exp_magnetic_field_covariancei)-1023+127)<<23;
00061 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->magnetic_field_covariance[i] = -this->magnetic_field_covariance[i];
00062 }
00063 return offset;
00064 }
00065
00066 const char * getType(){ return "sensor_msgs/MagneticField"; };
00067 const char * getMD5(){ return "2f3b0b43eed0c9501de0fa3ff89a45aa"; };
00068
00069 };
00070
00071 }
00072 #endif