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