catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SparseImage.h Source File

SparseImage.h

00001 #ifndef _ROS_jsk_recognition_msgs_SparseImage_h
00002 #define _ROS_jsk_recognition_msgs_SparseImage_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 jsk_recognition_msgs
00011 {
00012 
00013   class SparseImage : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       typedef uint32_t _width_type;
00019       _width_type width;
00020       typedef uint32_t _height_type;
00021       _height_type height;
00022       uint32_t data16_length;
00023       typedef uint16_t _data16_type;
00024       _data16_type st_data16;
00025       _data16_type * data16;
00026       uint32_t data32_length;
00027       typedef uint32_t _data32_type;
00028       _data32_type st_data32;
00029       _data32_type * data32;
00030 
00031     SparseImage():
00032       header(),
00033       width(0),
00034       height(0),
00035       data16_length(0), data16(NULL),
00036       data32_length(0), data32(NULL)
00037     {
00038     }
00039 
00040     virtual int serialize(unsigned char *outbuffer) const
00041     {
00042       int offset = 0;
00043       offset += this->header.serialize(outbuffer + offset);
00044       *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
00045       *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
00046       *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
00047       *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
00048       offset += sizeof(this->width);
00049       *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
00050       *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
00051       *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
00052       *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
00053       offset += sizeof(this->height);
00054       *(outbuffer + offset + 0) = (this->data16_length >> (8 * 0)) & 0xFF;
00055       *(outbuffer + offset + 1) = (this->data16_length >> (8 * 1)) & 0xFF;
00056       *(outbuffer + offset + 2) = (this->data16_length >> (8 * 2)) & 0xFF;
00057       *(outbuffer + offset + 3) = (this->data16_length >> (8 * 3)) & 0xFF;
00058       offset += sizeof(this->data16_length);
00059       for( uint32_t i = 0; i < data16_length; i++){
00060       *(outbuffer + offset + 0) = (this->data16[i] >> (8 * 0)) & 0xFF;
00061       *(outbuffer + offset + 1) = (this->data16[i] >> (8 * 1)) & 0xFF;
00062       offset += sizeof(this->data16[i]);
00063       }
00064       *(outbuffer + offset + 0) = (this->data32_length >> (8 * 0)) & 0xFF;
00065       *(outbuffer + offset + 1) = (this->data32_length >> (8 * 1)) & 0xFF;
00066       *(outbuffer + offset + 2) = (this->data32_length >> (8 * 2)) & 0xFF;
00067       *(outbuffer + offset + 3) = (this->data32_length >> (8 * 3)) & 0xFF;
00068       offset += sizeof(this->data32_length);
00069       for( uint32_t i = 0; i < data32_length; i++){
00070       *(outbuffer + offset + 0) = (this->data32[i] >> (8 * 0)) & 0xFF;
00071       *(outbuffer + offset + 1) = (this->data32[i] >> (8 * 1)) & 0xFF;
00072       *(outbuffer + offset + 2) = (this->data32[i] >> (8 * 2)) & 0xFF;
00073       *(outbuffer + offset + 3) = (this->data32[i] >> (8 * 3)) & 0xFF;
00074       offset += sizeof(this->data32[i]);
00075       }
00076       return offset;
00077     }
00078 
00079     virtual int deserialize(unsigned char *inbuffer)
00080     {
00081       int offset = 0;
00082       offset += this->header.deserialize(inbuffer + offset);
00083       this->width =  ((uint32_t) (*(inbuffer + offset)));
00084       this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00085       this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00086       this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00087       offset += sizeof(this->width);
00088       this->height =  ((uint32_t) (*(inbuffer + offset)));
00089       this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00090       this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00091       this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00092       offset += sizeof(this->height);
00093       uint32_t data16_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00094       data16_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00095       data16_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00096       data16_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00097       offset += sizeof(this->data16_length);
00098       if(data16_lengthT > data16_length)
00099         this->data16 = (uint16_t*)realloc(this->data16, data16_lengthT * sizeof(uint16_t));
00100       data16_length = data16_lengthT;
00101       for( uint32_t i = 0; i < data16_length; i++){
00102       this->st_data16 =  ((uint16_t) (*(inbuffer + offset)));
00103       this->st_data16 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00104       offset += sizeof(this->st_data16);
00105         memcpy( &(this->data16[i]), &(this->st_data16), sizeof(uint16_t));
00106       }
00107       uint32_t data32_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00108       data32_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00109       data32_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00110       data32_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00111       offset += sizeof(this->data32_length);
00112       if(data32_lengthT > data32_length)
00113         this->data32 = (uint32_t*)realloc(this->data32, data32_lengthT * sizeof(uint32_t));
00114       data32_length = data32_lengthT;
00115       for( uint32_t i = 0; i < data32_length; i++){
00116       this->st_data32 =  ((uint32_t) (*(inbuffer + offset)));
00117       this->st_data32 |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00118       this->st_data32 |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00119       this->st_data32 |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00120       offset += sizeof(this->st_data32);
00121         memcpy( &(this->data32[i]), &(this->st_data32), sizeof(uint32_t));
00122       }
00123      return offset;
00124     }
00125 
00126     virtual const char * getType(){ return "jsk_recognition_msgs/SparseImage"; };
00127     virtual const char * getMD5(){ return "7c361d829424bc5984fc0a1831f84751"; };
00128 
00129   };
00130 
00131 }
00132 #endif