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       char * format;
00018       unsigned char data_length;
00019       unsigned char st_data;
00020       unsigned char * data;
00021 
00022     virtual int serialize(unsigned char *outbuffer)
00023     {
00024       int offset = 0;
00025       offset += this->header.serialize(outbuffer + offset);
00026       long * length_format = (long *)(outbuffer + offset);
00027       *length_format = strlen( (const char*) this->format);
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( unsigned char i = 0; i < data_length; i++){
00036       union {
00037         unsigned char real;
00038         unsigned char base;
00039       } u_datai;
00040       u_datai.real = this->data[i];
00041       *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF;
00042       offset += sizeof(this->data[i]);
00043       }
00044       return offset;
00045     }
00046 
00047     virtual int deserialize(unsigned char *inbuffer)
00048     {
00049       int offset = 0;
00050       offset += this->header.deserialize(inbuffer + offset);
00051       uint32_t length_format = *(uint32_t *)(inbuffer + offset);
00052       offset += 4;
00053       for(unsigned int k= offset; k< offset+length_format; ++k){
00054           inbuffer[k-1]=inbuffer[k];
00055            }
00056       inbuffer[offset+length_format-1]=0;
00057       this->format = (char *)(inbuffer + offset-1);
00058       offset += length_format;
00059       unsigned char data_lengthT = *(inbuffer + offset++);
00060       if(data_lengthT > data_length)
00061         this->data = (unsigned char*)realloc(this->data, data_lengthT * sizeof(unsigned char));
00062       offset += 3;
00063       data_length = data_lengthT;
00064       for( unsigned char i = 0; i < data_length; i++){
00065       union {
00066         unsigned char real;
00067         unsigned char base;
00068       } u_st_data;
00069       u_st_data.base = 0;
00070       u_st_data.base |= ((typeof(u_st_data.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00071       this->st_data = u_st_data.real;
00072       offset += sizeof(this->st_data);
00073         memcpy( &(this->data[i]), &(this->st_data), sizeof(unsigned char));
00074       }
00075      return offset;
00076     }
00077 
00078     const char * getType(){ return "sensor_msgs/CompressedImage"; };
00079 
00080   };
00081 
00082 }
00083 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


traxbot_robot
Author(s): André Gonçalves Araújo
autogenerated on Fri Feb 1 2013 13:21:12