kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
PointCloud2.h
Go to the documentation of this file.
1 #ifndef _ROS_sensor_msgs_PointCloud2_h
2 #define _ROS_sensor_msgs_PointCloud2_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"
10 
11 namespace sensor_msgs
12 {
13 
14  class PointCloud2 : public ros::Msg
15  {
16  public:
18  uint32_t height;
19  uint32_t width;
20  uint8_t fields_length;
24  uint32_t point_step;
25  uint32_t row_step;
26  uint8_t data_length;
27  uint8_t st_data;
28  uint8_t * data;
29  bool is_dense;
30 
32  header(),
33  height(0),
34  width(0),
35  fields_length(0), fields(NULL),
36  is_bigendian(0),
37  point_step(0),
38  row_step(0),
39  data_length(0), data(NULL),
40  is_dense(0)
41  {
42  }
43 
44  virtual int serialize(unsigned char *outbuffer) const
45  {
46  int offset = 0;
47  offset += this->header.serialize(outbuffer + offset);
48  *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
49  *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
50  *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
51  *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
52  offset += sizeof(this->height);
53  *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
54  *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
55  *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
56  *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
57  offset += sizeof(this->width);
58  *(outbuffer + offset++) = fields_length;
59  *(outbuffer + offset++) = 0;
60  *(outbuffer + offset++) = 0;
61  *(outbuffer + offset++) = 0;
62  for( uint8_t i = 0; i < fields_length; i++){
63  offset += this->fields[i].serialize(outbuffer + offset);
64  }
65  union {
66  bool real;
67  uint8_t base;
68  } u_is_bigendian;
69  u_is_bigendian.real = this->is_bigendian;
70  *(outbuffer + offset + 0) = (u_is_bigendian.base >> (8 * 0)) & 0xFF;
71  offset += sizeof(this->is_bigendian);
72  *(outbuffer + offset + 0) = (this->point_step >> (8 * 0)) & 0xFF;
73  *(outbuffer + offset + 1) = (this->point_step >> (8 * 1)) & 0xFF;
74  *(outbuffer + offset + 2) = (this->point_step >> (8 * 2)) & 0xFF;
75  *(outbuffer + offset + 3) = (this->point_step >> (8 * 3)) & 0xFF;
76  offset += sizeof(this->point_step);
77  *(outbuffer + offset + 0) = (this->row_step >> (8 * 0)) & 0xFF;
78  *(outbuffer + offset + 1) = (this->row_step >> (8 * 1)) & 0xFF;
79  *(outbuffer + offset + 2) = (this->row_step >> (8 * 2)) & 0xFF;
80  *(outbuffer + offset + 3) = (this->row_step >> (8 * 3)) & 0xFF;
81  offset += sizeof(this->row_step);
82  *(outbuffer + offset++) = data_length;
83  *(outbuffer + offset++) = 0;
84  *(outbuffer + offset++) = 0;
85  *(outbuffer + offset++) = 0;
86  for( uint8_t i = 0; i < data_length; i++){
87  *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF;
88  offset += sizeof(this->data[i]);
89  }
90  union {
91  bool real;
92  uint8_t base;
93  } u_is_dense;
94  u_is_dense.real = this->is_dense;
95  *(outbuffer + offset + 0) = (u_is_dense.base >> (8 * 0)) & 0xFF;
96  offset += sizeof(this->is_dense);
97  return offset;
98  }
99 
100  virtual int deserialize(unsigned char *inbuffer)
101  {
102  int offset = 0;
103  offset += this->header.deserialize(inbuffer + offset);
104  this->height = ((uint32_t) (*(inbuffer + offset)));
105  this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
106  this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
107  this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
108  offset += sizeof(this->height);
109  this->width = ((uint32_t) (*(inbuffer + offset)));
110  this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
111  this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
112  this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
113  offset += sizeof(this->width);
114  uint8_t fields_lengthT = *(inbuffer + offset++);
115  if(fields_lengthT > fields_length)
116  this->fields = (sensor_msgs::PointField*)realloc(this->fields, fields_lengthT * sizeof(sensor_msgs::PointField));
117  offset += 3;
118  fields_length = fields_lengthT;
119  for( uint8_t i = 0; i < fields_length; i++){
120  offset += this->st_fields.deserialize(inbuffer + offset);
121  memcpy( &(this->fields[i]), &(this->st_fields), sizeof(sensor_msgs::PointField));
122  }
123  union {
124  bool real;
125  uint8_t base;
126  } u_is_bigendian;
127  u_is_bigendian.base = 0;
128  u_is_bigendian.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
129  this->is_bigendian = u_is_bigendian.real;
130  offset += sizeof(this->is_bigendian);
131  this->point_step = ((uint32_t) (*(inbuffer + offset)));
132  this->point_step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
133  this->point_step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
134  this->point_step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
135  offset += sizeof(this->point_step);
136  this->row_step = ((uint32_t) (*(inbuffer + offset)));
137  this->row_step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
138  this->row_step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
139  this->row_step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
140  offset += sizeof(this->row_step);
141  uint8_t data_lengthT = *(inbuffer + offset++);
142  if(data_lengthT > data_length)
143  this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t));
144  offset += 3;
145  data_length = data_lengthT;
146  for( uint8_t i = 0; i < data_length; i++){
147  this->st_data = ((uint8_t) (*(inbuffer + offset)));
148  offset += sizeof(this->st_data);
149  memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t));
150  }
151  union {
152  bool real;
153  uint8_t base;
154  } u_is_dense;
155  u_is_dense.base = 0;
156  u_is_dense.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
157  this->is_dense = u_is_dense.real;
158  offset += sizeof(this->is_dense);
159  return offset;
160  }
161 
162  const char * getType(){ return "sensor_msgs/PointCloud2"; };
163  const char * getMD5(){ return "1158d486dd51d683ce2f1be655c3c181"; };
164 
165  };
166 
167 }
168 #endif
uint8_t st_data
Definition: PointCloud2.h:27
virtual int deserialize(unsigned char *inbuffer)
Definition: Header.h:53
uint32_t row_step
Definition: PointCloud2.h:25
bool is_dense
Definition: PointCloud2.h:29
Definition: PointCloud2.h:14
uint32_t width
Definition: PointCloud2.h:19
virtual int serialize(unsigned char *outbuffer) const
Definition: PointCloud2.h:44
virtual int serialize(unsigned char *outbuffer) const
Definition: Header.h:27
virtual int serialize(unsigned char *outbuffer) const
Definition: PointField.h:36
uint8_t * data
Definition: PointCloud2.h:28
Definition: PointField.h:12
Definition: Header.h:13
virtual int deserialize(unsigned char *inbuffer)
Definition: PointField.h:59
bool is_bigendian
Definition: PointCloud2.h:23
sensor_msgs::PointField st_fields
Definition: PointCloud2.h:21
uint32_t height
Definition: PointCloud2.h:18
const char * getType()
Definition: PointCloud2.h:162
uint8_t data_length
Definition: PointCloud2.h:26
PointCloud2()
Definition: PointCloud2.h:31
sensor_msgs::PointField * fields
Definition: PointCloud2.h:22
uint8_t fields_length
Definition: PointCloud2.h:20
virtual int deserialize(unsigned char *inbuffer)
Definition: PointCloud2.h:100
const char * getMD5()
Definition: PointCloud2.h:163
std_msgs::Header header
Definition: PointCloud2.h:17
Definition: msg.h:43
uint32_t point_step
Definition: PointCloud2.h:24