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