ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

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