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 GridCells.h Source File

GridCells.h

00001 #ifndef _ROS_nav_msgs_GridCells_h
00002 #define _ROS_nav_msgs_GridCells_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 #include "geometry_msgs/Point.h"
00010 
00011 namespace nav_msgs
00012 {
00013 
00014   class GridCells : public ros::Msg
00015   {
00016     public:
00017       std_msgs::Header header;
00018       float cell_width;
00019       float cell_height;
00020       uint8_t cells_length;
00021       geometry_msgs::Point st_cells;
00022       geometry_msgs::Point * cells;
00023 
00024     GridCells():
00025       header(),
00026       cell_width(0),
00027       cell_height(0),
00028       cells_length(0), cells(NULL)
00029     {
00030     }
00031 
00032     virtual int serialize(unsigned char *outbuffer) const
00033     {
00034       int offset = 0;
00035       offset += this->header.serialize(outbuffer + offset);
00036       union {
00037         float real;
00038         uint32_t base;
00039       } u_cell_width;
00040       u_cell_width.real = this->cell_width;
00041       *(outbuffer + offset + 0) = (u_cell_width.base >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (u_cell_width.base >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (u_cell_width.base >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (u_cell_width.base >> (8 * 3)) & 0xFF;
00045       offset += sizeof(this->cell_width);
00046       union {
00047         float real;
00048         uint32_t base;
00049       } u_cell_height;
00050       u_cell_height.real = this->cell_height;
00051       *(outbuffer + offset + 0) = (u_cell_height.base >> (8 * 0)) & 0xFF;
00052       *(outbuffer + offset + 1) = (u_cell_height.base >> (8 * 1)) & 0xFF;
00053       *(outbuffer + offset + 2) = (u_cell_height.base >> (8 * 2)) & 0xFF;
00054       *(outbuffer + offset + 3) = (u_cell_height.base >> (8 * 3)) & 0xFF;
00055       offset += sizeof(this->cell_height);
00056       *(outbuffer + offset++) = cells_length;
00057       *(outbuffer + offset++) = 0;
00058       *(outbuffer + offset++) = 0;
00059       *(outbuffer + offset++) = 0;
00060       for( uint8_t i = 0; i < cells_length; i++){
00061       offset += this->cells[i].serialize(outbuffer + offset);
00062       }
00063       return offset;
00064     }
00065 
00066     virtual int deserialize(unsigned char *inbuffer)
00067     {
00068       int offset = 0;
00069       offset += this->header.deserialize(inbuffer + offset);
00070       union {
00071         float real;
00072         uint32_t base;
00073       } u_cell_width;
00074       u_cell_width.base = 0;
00075       u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00076       u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00077       u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00078       u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00079       this->cell_width = u_cell_width.real;
00080       offset += sizeof(this->cell_width);
00081       union {
00082         float real;
00083         uint32_t base;
00084       } u_cell_height;
00085       u_cell_height.base = 0;
00086       u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00087       u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00088       u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00089       u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00090       this->cell_height = u_cell_height.real;
00091       offset += sizeof(this->cell_height);
00092       uint8_t cells_lengthT = *(inbuffer + offset++);
00093       if(cells_lengthT > cells_length)
00094         this->cells = (geometry_msgs::Point*)realloc(this->cells, cells_lengthT * sizeof(geometry_msgs::Point));
00095       offset += 3;
00096       cells_length = cells_lengthT;
00097       for( uint8_t i = 0; i < cells_length; i++){
00098       offset += this->st_cells.deserialize(inbuffer + offset);
00099         memcpy( &(this->cells[i]), &(this->st_cells), sizeof(geometry_msgs::Point));
00100       }
00101      return offset;
00102     }
00103 
00104     const char * getType(){ return "nav_msgs/GridCells"; };
00105     const char * getMD5(){ return "b9e4f5df6d28e272ebde00a3994830f5"; };
00106 
00107   };
00108 
00109 }
00110 #endif