Go to the documentation of this file.00001 #ifndef _ROS_sensor_msgs_ChannelFloat32_h
00002 #define _ROS_sensor_msgs_ChannelFloat32_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008
00009 namespace sensor_msgs
00010 {
00011
00012 class ChannelFloat32 : public ros::Msg
00013 {
00014 public:
00015 char * name;
00016 uint8_t values_length;
00017 float st_values;
00018 float * values;
00019
00020 virtual int serialize(unsigned char *outbuffer) const
00021 {
00022 int offset = 0;
00023 uint32_t length_name = strlen( (const char*) this->name);
00024 memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
00025 offset += 4;
00026 memcpy(outbuffer + offset, this->name, length_name);
00027 offset += length_name;
00028 *(outbuffer + offset++) = values_length;
00029 *(outbuffer + offset++) = 0;
00030 *(outbuffer + offset++) = 0;
00031 *(outbuffer + offset++) = 0;
00032 for( uint8_t i = 0; i < values_length; i++){
00033 union {
00034 float real;
00035 uint32_t base;
00036 } u_valuesi;
00037 u_valuesi.real = this->values[i];
00038 *(outbuffer + offset + 0) = (u_valuesi.base >> (8 * 0)) & 0xFF;
00039 *(outbuffer + offset + 1) = (u_valuesi.base >> (8 * 1)) & 0xFF;
00040 *(outbuffer + offset + 2) = (u_valuesi.base >> (8 * 2)) & 0xFF;
00041 *(outbuffer + offset + 3) = (u_valuesi.base >> (8 * 3)) & 0xFF;
00042 offset += sizeof(this->values[i]);
00043 }
00044 return offset;
00045 }
00046
00047 virtual int deserialize(unsigned char *inbuffer)
00048 {
00049 int offset = 0;
00050 uint32_t length_name;
00051 memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
00052 offset += 4;
00053 for(unsigned int k= offset; k< offset+length_name; ++k){
00054 inbuffer[k-1]=inbuffer[k];
00055 }
00056 inbuffer[offset+length_name-1]=0;
00057 this->name = (char *)(inbuffer + offset-1);
00058 offset += length_name;
00059 uint8_t values_lengthT = *(inbuffer + offset++);
00060 if(values_lengthT > values_length)
00061 this->values = (float*)realloc(this->values, values_lengthT * sizeof(float));
00062 offset += 3;
00063 values_length = values_lengthT;
00064 for( uint8_t i = 0; i < values_length; i++){
00065 union {
00066 float real;
00067 uint32_t base;
00068 } u_st_values;
00069 u_st_values.base = 0;
00070 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00071 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00072 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00073 u_st_values.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00074 this->st_values = u_st_values.real;
00075 offset += sizeof(this->st_values);
00076 memcpy( &(this->values[i]), &(this->st_values), sizeof(float));
00077 }
00078 return offset;
00079 }
00080
00081 const char * getType(){ return "sensor_msgs/ChannelFloat32"; };
00082 const char * getMD5(){ return "3d40139cdd33dfedcb71ffeeeb42ae7f"; };
00083
00084 };
00085
00086 }
00087 #endif