Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OccupancyGridUpdate.h Source File

OccupancyGridUpdate.h

00001 #ifndef _ROS_map_msgs_OccupancyGridUpdate_h
00002 #define _ROS_map_msgs_OccupancyGridUpdate_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 map_msgs
00011 {
00012 
00013   class OccupancyGridUpdate : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       typedef int32_t _x_type;
00019       _x_type x;
00020       typedef int32_t _y_type;
00021       _y_type y;
00022       typedef uint32_t _width_type;
00023       _width_type width;
00024       typedef uint32_t _height_type;
00025       _height_type height;
00026       uint32_t data_length;
00027       typedef int8_t _data_type;
00028       _data_type st_data;
00029       _data_type * data;
00030 
00031     OccupancyGridUpdate():
00032       header(),
00033       x(0),
00034       y(0),
00035       width(0),
00036       height(0),
00037       data_length(0), data(NULL)
00038     {
00039     }
00040 
00041     virtual int serialize(unsigned char *outbuffer) const
00042     {
00043       int offset = 0;
00044       offset += this->header.serialize(outbuffer + offset);
00045       union {
00046         int32_t real;
00047         uint32_t base;
00048       } u_x;
00049       u_x.real = this->x;
00050       *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
00051       *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
00052       *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
00053       *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
00054       offset += sizeof(this->x);
00055       union {
00056         int32_t real;
00057         uint32_t base;
00058       } u_y;
00059       u_y.real = this->y;
00060       *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
00061       *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
00062       *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
00063       *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
00064       offset += sizeof(this->y);
00065       *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
00066       *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
00067       *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
00068       *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
00069       offset += sizeof(this->width);
00070       *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
00071       *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
00072       *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
00073       *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
00074       offset += sizeof(this->height);
00075       *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF;
00076       *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF;
00077       *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF;
00078       *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF;
00079       offset += sizeof(this->data_length);
00080       for( uint32_t i = 0; i < data_length; i++){
00081       union {
00082         int8_t real;
00083         uint8_t base;
00084       } u_datai;
00085       u_datai.real = this->data[i];
00086       *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF;
00087       offset += sizeof(this->data[i]);
00088       }
00089       return offset;
00090     }
00091 
00092     virtual int deserialize(unsigned char *inbuffer)
00093     {
00094       int offset = 0;
00095       offset += this->header.deserialize(inbuffer + offset);
00096       union {
00097         int32_t real;
00098         uint32_t base;
00099       } u_x;
00100       u_x.base = 0;
00101       u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00102       u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00103       u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00104       u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00105       this->x = u_x.real;
00106       offset += sizeof(this->x);
00107       union {
00108         int32_t real;
00109         uint32_t base;
00110       } u_y;
00111       u_y.base = 0;
00112       u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00113       u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00114       u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00115       u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00116       this->y = u_y.real;
00117       offset += sizeof(this->y);
00118       this->width =  ((uint32_t) (*(inbuffer + offset)));
00119       this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00120       this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00121       this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00122       offset += sizeof(this->width);
00123       this->height =  ((uint32_t) (*(inbuffer + offset)));
00124       this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00125       this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00126       this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00127       offset += sizeof(this->height);
00128       uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00129       data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00130       data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00131       data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00132       offset += sizeof(this->data_length);
00133       if(data_lengthT > data_length)
00134         this->data = (int8_t*)realloc(this->data, data_lengthT * sizeof(int8_t));
00135       data_length = data_lengthT;
00136       for( uint32_t i = 0; i < data_length; i++){
00137       union {
00138         int8_t real;
00139         uint8_t base;
00140       } u_st_data;
00141       u_st_data.base = 0;
00142       u_st_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00143       this->st_data = u_st_data.real;
00144       offset += sizeof(this->st_data);
00145         memcpy( &(this->data[i]), &(this->st_data), sizeof(int8_t));
00146       }
00147      return offset;
00148     }
00149 
00150     const char * getType(){ return "map_msgs/OccupancyGridUpdate"; };
00151     const char * getMD5(){ return "b295be292b335c34718bd939deebe1c9"; };
00152 
00153   };
00154 
00155 }
00156 #endif