Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / sensor_msgs / PointField.h @ c1426757

History | View | Annotate | Download (2.89 KB)

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
      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

    
28
    virtual int serialize(unsigned char *outbuffer) const
29
    {
30
      int offset = 0;
31
      uint32_t * length_name = (uint32_t *)(outbuffer + offset);
32
      *length_name = strlen( (const char*) this->name);
33
      offset += 4;
34
      memcpy(outbuffer + offset, this->name, *length_name);
35
      offset += *length_name;
36
      *(outbuffer + offset + 0) = (this->offset >> (8 * 0)) & 0xFF;
37
      *(outbuffer + offset + 1) = (this->offset >> (8 * 1)) & 0xFF;
38
      *(outbuffer + offset + 2) = (this->offset >> (8 * 2)) & 0xFF;
39
      *(outbuffer + offset + 3) = (this->offset >> (8 * 3)) & 0xFF;
40
      offset += sizeof(this->offset);
41
      *(outbuffer + offset + 0) = (this->datatype >> (8 * 0)) & 0xFF;
42
      offset += sizeof(this->datatype);
43
      *(outbuffer + offset + 0) = (this->count >> (8 * 0)) & 0xFF;
44
      *(outbuffer + offset + 1) = (this->count >> (8 * 1)) & 0xFF;
45
      *(outbuffer + offset + 2) = (this->count >> (8 * 2)) & 0xFF;
46
      *(outbuffer + offset + 3) = (this->count >> (8 * 3)) & 0xFF;
47
      offset += sizeof(this->count);
48
      return offset;
49
    }
50

    
51
    virtual int deserialize(unsigned char *inbuffer)
52
    {
53
      int offset = 0;
54
      uint32_t length_name = *(uint32_t *)(inbuffer + offset);
55
      offset += 4;
56
      for(unsigned int k= offset; k< offset+length_name; ++k){
57
          inbuffer[k-1]=inbuffer[k];
58
      }
59
      inbuffer[offset+length_name-1]=0;
60
      this->name = (char *)(inbuffer + offset-1);
61
      offset += length_name;
62
      this->offset |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
63
      this->offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
64
      this->offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
65
      this->offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
66
      offset += sizeof(this->offset);
67
      this->datatype |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
68
      offset += sizeof(this->datatype);
69
      this->count |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
70
      this->count |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
71
      this->count |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
72
      this->count |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
73
      offset += sizeof(this->count);
74
     return offset;
75
    }
76

    
77
    const char * getType(){ return "sensor_msgs/PointField"; };
78
    const char * getMD5(){ return "268eacb2962780ceac86cbd17e328150"; };
79

    
80
  };
81

    
82
}
83
#endif