Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / geometry_msgs / Polygon.h @ c1426757

History | View | Annotate | Download (1.47 KB)

1
#ifndef _ROS_geometry_msgs_Polygon_h
2
#define _ROS_geometry_msgs_Polygon_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8
#include "geometry_msgs/Point32.h"
9

    
10
namespace geometry_msgs
11
{
12

    
13
  class Polygon : public ros::Msg
14
  {
15
    public:
16
      uint8_t points_length;
17
      geometry_msgs::Point32 st_points;
18
      geometry_msgs::Point32 * points;
19

    
20
    virtual int serialize(unsigned char *outbuffer) const
21
    {
22
      int offset = 0;
23
      *(outbuffer + offset++) = points_length;
24
      *(outbuffer + offset++) = 0;
25
      *(outbuffer + offset++) = 0;
26
      *(outbuffer + offset++) = 0;
27
      for( uint8_t i = 0; i < points_length; i++){
28
      offset += this->points[i].serialize(outbuffer + offset);
29
      }
30
      return offset;
31
    }
32

    
33
    virtual int deserialize(unsigned char *inbuffer)
34
    {
35
      int offset = 0;
36
      uint8_t points_lengthT = *(inbuffer + offset++);
37
      if(points_lengthT > points_length)
38
        this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32));
39
      offset += 3;
40
      points_length = points_lengthT;
41
      for( uint8_t i = 0; i < points_length; i++){
42
      offset += this->st_points.deserialize(inbuffer + offset);
43
        memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32));
44
      }
45
     return offset;
46
    }
47

    
48
    const char * getType(){ return "geometry_msgs/Polygon"; };
49
    const char * getMD5(){ return "cd60a26494a087f577976f0329fa120e"; };
50

    
51
  };
52

    
53
}
54
#endif