kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
PointField.h
Go to the documentation of this file.
1 #ifndef _ROS_sensor_msgs_PointField_h
2 #define _ROS_sensor_msgs_PointField_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 
9 namespace sensor_msgs
10 {
11 
12  class PointField : public ros::Msg
13  {
14  public:
15  const char* name;
16  uint32_t offset;
17  uint8_t datatype;
18  uint32_t count;
19  enum { INT8 = 1 };
20  enum { UINT8 = 2 };
21  enum { INT16 = 3 };
22  enum { UINT16 = 4 };
23  enum { INT32 = 5 };
24  enum { UINT32 = 6 };
25  enum { FLOAT32 = 7 };
26  enum { FLOAT64 = 8 };
27 
29  name(""),
30  offset(0),
31  datatype(0),
32  count(0)
33  {
34  }
35 
36  virtual int serialize(unsigned char *outbuffer) const
37  {
38  int offset = 0;
39  uint32_t length_name = strlen(this->name);
40  memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
41  offset += 4;
42  memcpy(outbuffer + offset, this->name, length_name);
43  offset += length_name;
44  *(outbuffer + offset + 0) = (this->offset >> (8 * 0)) & 0xFF;
45  *(outbuffer + offset + 1) = (this->offset >> (8 * 1)) & 0xFF;
46  *(outbuffer + offset + 2) = (this->offset >> (8 * 2)) & 0xFF;
47  *(outbuffer + offset + 3) = (this->offset >> (8 * 3)) & 0xFF;
48  offset += sizeof(this->offset);
49  *(outbuffer + offset + 0) = (this->datatype >> (8 * 0)) & 0xFF;
50  offset += sizeof(this->datatype);
51  *(outbuffer + offset + 0) = (this->count >> (8 * 0)) & 0xFF;
52  *(outbuffer + offset + 1) = (this->count >> (8 * 1)) & 0xFF;
53  *(outbuffer + offset + 2) = (this->count >> (8 * 2)) & 0xFF;
54  *(outbuffer + offset + 3) = (this->count >> (8 * 3)) & 0xFF;
55  offset += sizeof(this->count);
56  return offset;
57  }
58 
59  virtual int deserialize(unsigned char *inbuffer)
60  {
61  int offset = 0;
62  uint32_t length_name;
63  memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
64  offset += 4;
65  for(unsigned int k= offset; k< offset+length_name; ++k){
66  inbuffer[k-1]=inbuffer[k];
67  }
68  inbuffer[offset+length_name-1]=0;
69  this->name = (char *)(inbuffer + offset-1);
70  offset += length_name;
71  this->offset = ((uint32_t) (*(inbuffer + offset)));
72  this->offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
73  this->offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
74  this->offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
75  offset += sizeof(this->offset);
76  this->datatype = ((uint8_t) (*(inbuffer + offset)));
77  offset += sizeof(this->datatype);
78  this->count = ((uint32_t) (*(inbuffer + offset)));
79  this->count |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
80  this->count |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
81  this->count |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
82  offset += sizeof(this->count);
83  return offset;
84  }
85 
86  const char * getType(){ return "sensor_msgs/PointField"; };
87  const char * getMD5(){ return "268eacb2962780ceac86cbd17e328150"; };
88 
89  };
90 
91 }
92 #endif
const char * getType()
Definition: PointField.h:86
Definition: PointField.h:22
uint32_t count
Definition: PointField.h:18
Definition: PointField.h:20
PointField()
Definition: PointField.h:28
const char * getMD5()
Definition: PointField.h:87
Definition: PointField.h:24
virtual int serialize(unsigned char *outbuffer) const
Definition: PointField.h:36
Definition: PointField.h:12
Definition: PointField.h:19
Definition: PointField.h:25
virtual int deserialize(unsigned char *inbuffer)
Definition: PointField.h:59
uint32_t offset
Definition: PointField.h:16
const char * name
Definition: PointField.h:15
Definition: PointField.h:23
Definition: PointField.h:21
Definition: msg.h:43
Definition: PointField.h:26
uint8_t datatype
Definition: PointField.h:17