CompressedImage.h
Go to the documentation of this file.
00001 #ifndef _ROS_sensor_msgs_CompressedImage_h
00002 #define _ROS_sensor_msgs_CompressedImage_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 
00010 namespace sensor_msgs
00011 {
00012 
00013   class CompressedImage : public ros::Msg
00014   {
00015     public:
00016       std_msgs::Header header;
00017       const char* format;
00018       uint8_t data_length;
00019       uint8_t st_data;
00020       uint8_t * data;
00021 
00022     virtual int serialize(unsigned char *outbuffer) const
00023     {
00024       int offset = 0;
00025       offset += this->header.serialize(outbuffer + offset);
00026       uint32_t length_format = strlen(this->format);
00027       memcpy(outbuffer + offset, &length_format, sizeof(uint32_t));
00028       offset += 4;
00029       memcpy(outbuffer + offset, this->format, length_format);
00030       offset += length_format;
00031       *(outbuffer + offset++) = data_length;
00032       *(outbuffer + offset++) = 0;
00033       *(outbuffer + offset++) = 0;
00034       *(outbuffer + offset++) = 0;
00035       for( uint8_t i = 0; i < data_length; i++){
00036       *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF;
00037       offset += sizeof(this->data[i]);
00038       }
00039       return offset;
00040     }
00041 
00042     virtual int deserialize(unsigned char *inbuffer)
00043     {
00044       int offset = 0;
00045       offset += this->header.deserialize(inbuffer + offset);
00046       uint32_t length_format;
00047       memcpy(&length_format, (inbuffer + offset), sizeof(uint32_t));
00048       offset += 4;
00049       for(unsigned int k= offset; k< offset+length_format; ++k){
00050           inbuffer[k-1]=inbuffer[k];
00051       }
00052       inbuffer[offset+length_format-1]=0;
00053       this->format = (char *)(inbuffer + offset-1);
00054       offset += length_format;
00055       uint8_t data_lengthT = *(inbuffer + offset++);
00056       if(data_lengthT > data_length)
00057         this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t));
00058       offset += 3;
00059       data_length = data_lengthT;
00060       for( uint8_t i = 0; i < data_length; i++){
00061       this->st_data =  ((uint8_t) (*(inbuffer + offset)));
00062       offset += sizeof(this->st_data);
00063         memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t));
00064       }
00065      return offset;
00066     }
00067 
00068     const char * getType(){ return "sensor_msgs/CompressedImage"; };
00069     const char * getMD5(){ return "8f7a12909da2c9d3332d540a0977563f"; };
00070 
00071   };
00072 
00073 }
00074 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Fri May 20 2016 03:48:55