Personal fork

Dependencies:   MODSERIAL

Dependents:   rosserial_mbed

Fork of rosserial_mbed_lib by nucho

Committer:
nucho
Date:
Sun Oct 16 07:19:36 2011 +0000
Revision:
1:ff0ec969dad1
Parent:
0:77afd7560544
Child:
3:1cf99502f396
This program supported the revision of 143 of rosserial.
And the bug fix of receive of array data.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 1:ff0ec969dad1 1 #ifndef ros_nav_msgs_GridCells_h
nucho 1:ff0ec969dad1 2 #define ros_nav_msgs_GridCells_h
nucho 0:77afd7560544 3
nucho 0:77afd7560544 4 #include <stdint.h>
nucho 0:77afd7560544 5 #include <string.h>
nucho 0:77afd7560544 6 #include <stdlib.h>
nucho 0:77afd7560544 7 #include "../ros/msg.h"
nucho 0:77afd7560544 8 #include "std_msgs/Header.h"
nucho 0:77afd7560544 9 #include "geometry_msgs/Point.h"
nucho 0:77afd7560544 10
nucho 0:77afd7560544 11 namespace nav_msgs
nucho 0:77afd7560544 12 {
nucho 0:77afd7560544 13
nucho 0:77afd7560544 14 class GridCells : public ros::Msg
nucho 0:77afd7560544 15 {
nucho 0:77afd7560544 16 public:
nucho 0:77afd7560544 17 std_msgs::Header header;
nucho 0:77afd7560544 18 float cell_width;
nucho 0:77afd7560544 19 float cell_height;
nucho 0:77afd7560544 20 unsigned char cells_length;
nucho 0:77afd7560544 21 geometry_msgs::Point st_cells;
nucho 0:77afd7560544 22 geometry_msgs::Point * cells;
nucho 0:77afd7560544 23
nucho 0:77afd7560544 24 virtual int serialize(unsigned char *outbuffer)
nucho 0:77afd7560544 25 {
nucho 0:77afd7560544 26 int offset = 0;
nucho 0:77afd7560544 27 offset += this->header.serialize(outbuffer + offset);
nucho 0:77afd7560544 28 union {
nucho 0:77afd7560544 29 float real;
nucho 0:77afd7560544 30 unsigned long base;
nucho 0:77afd7560544 31 } u_cell_width;
nucho 0:77afd7560544 32 u_cell_width.real = this->cell_width;
nucho 0:77afd7560544 33 *(outbuffer + offset + 0) = (u_cell_width.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 34 *(outbuffer + offset + 1) = (u_cell_width.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 35 *(outbuffer + offset + 2) = (u_cell_width.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 36 *(outbuffer + offset + 3) = (u_cell_width.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 37 offset += sizeof(this->cell_width);
nucho 0:77afd7560544 38 union {
nucho 0:77afd7560544 39 float real;
nucho 0:77afd7560544 40 unsigned long base;
nucho 0:77afd7560544 41 } u_cell_height;
nucho 0:77afd7560544 42 u_cell_height.real = this->cell_height;
nucho 0:77afd7560544 43 *(outbuffer + offset + 0) = (u_cell_height.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 44 *(outbuffer + offset + 1) = (u_cell_height.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 45 *(outbuffer + offset + 2) = (u_cell_height.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 46 *(outbuffer + offset + 3) = (u_cell_height.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 47 offset += sizeof(this->cell_height);
nucho 0:77afd7560544 48 *(outbuffer + offset++) = cells_length;
nucho 0:77afd7560544 49 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 50 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 51 *(outbuffer + offset++) = 0;
nucho 0:77afd7560544 52 for( unsigned char i = 0; i < cells_length; i++){
nucho 0:77afd7560544 53 offset += this->cells[i].serialize(outbuffer + offset);
nucho 0:77afd7560544 54 }
nucho 0:77afd7560544 55 return offset;
nucho 0:77afd7560544 56 }
nucho 0:77afd7560544 57
nucho 0:77afd7560544 58 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 59 {
nucho 0:77afd7560544 60 int offset = 0;
nucho 0:77afd7560544 61 offset += this->header.deserialize(inbuffer + offset);
nucho 0:77afd7560544 62 union {
nucho 0:77afd7560544 63 float real;
nucho 0:77afd7560544 64 unsigned long base;
nucho 0:77afd7560544 65 } u_cell_width;
nucho 0:77afd7560544 66 u_cell_width.base = 0;
nucho 0:77afd7560544 67 u_cell_width.base |= ((typeof(u_cell_width.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 68 u_cell_width.base |= ((typeof(u_cell_width.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 69 u_cell_width.base |= ((typeof(u_cell_width.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 70 u_cell_width.base |= ((typeof(u_cell_width.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 71 this->cell_width = u_cell_width.real;
nucho 0:77afd7560544 72 offset += sizeof(this->cell_width);
nucho 0:77afd7560544 73 union {
nucho 0:77afd7560544 74 float real;
nucho 0:77afd7560544 75 unsigned long base;
nucho 0:77afd7560544 76 } u_cell_height;
nucho 0:77afd7560544 77 u_cell_height.base = 0;
nucho 0:77afd7560544 78 u_cell_height.base |= ((typeof(u_cell_height.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 79 u_cell_height.base |= ((typeof(u_cell_height.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 80 u_cell_height.base |= ((typeof(u_cell_height.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 81 u_cell_height.base |= ((typeof(u_cell_height.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 82 this->cell_height = u_cell_height.real;
nucho 0:77afd7560544 83 offset += sizeof(this->cell_height);
nucho 0:77afd7560544 84 unsigned char cells_lengthT = *(inbuffer + offset++);
nucho 0:77afd7560544 85 if(cells_lengthT > cells_length)
nucho 0:77afd7560544 86 this->cells = (geometry_msgs::Point*)realloc(this->cells, cells_lengthT * sizeof(geometry_msgs::Point));
nucho 0:77afd7560544 87 offset += 3;
nucho 0:77afd7560544 88 cells_length = cells_lengthT;
nucho 0:77afd7560544 89 for( unsigned char i = 0; i < cells_length; i++){
nucho 0:77afd7560544 90 offset += this->st_cells.deserialize(inbuffer + offset);
nucho 0:77afd7560544 91 memcpy( &(this->cells[i]), &(this->st_cells), sizeof(geometry_msgs::Point));
nucho 0:77afd7560544 92 }
nucho 0:77afd7560544 93 return offset;
nucho 0:77afd7560544 94 }
nucho 0:77afd7560544 95
nucho 0:77afd7560544 96 virtual const char * getType(){ return "nav_msgs/GridCells"; };
nucho 0:77afd7560544 97
nucho 0:77afd7560544 98 };
nucho 0:77afd7560544 99
nucho 0:77afd7560544 100 }
nucho 0:77afd7560544 101 #endif