kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
SolidPrimitive.h
Go to the documentation of this file.
1 #ifndef _ROS_shape_msgs_SolidPrimitive_h
2 #define _ROS_shape_msgs_SolidPrimitive_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 
9 namespace shape_msgs
10 {
11 
12  class SolidPrimitive : public ros::Msg
13  {
14  public:
15  uint8_t type;
18  float * dimensions;
19  enum { BOX = 1 };
20  enum { SPHERE = 2 };
21  enum { CYLINDER = 3 };
22  enum { CONE = 4 };
23  enum { BOX_X = 0 };
24  enum { BOX_Y = 1 };
25  enum { BOX_Z = 2 };
26  enum { SPHERE_RADIUS = 0 };
27  enum { CYLINDER_HEIGHT = 0 };
28  enum { CYLINDER_RADIUS = 1 };
29  enum { CONE_HEIGHT = 0 };
30  enum { CONE_RADIUS = 1 };
31 
33  type(0),
35  {
36  }
37 
38  virtual int serialize(unsigned char *outbuffer) const
39  {
40  int offset = 0;
41  *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
42  offset += sizeof(this->type);
43  *(outbuffer + offset++) = dimensions_length;
44  *(outbuffer + offset++) = 0;
45  *(outbuffer + offset++) = 0;
46  *(outbuffer + offset++) = 0;
47  for( uint8_t i = 0; i < dimensions_length; i++){
48  offset += serializeAvrFloat64(outbuffer + offset, this->dimensions[i]);
49  }
50  return offset;
51  }
52 
53  virtual int deserialize(unsigned char *inbuffer)
54  {
55  int offset = 0;
56  this->type = ((uint8_t) (*(inbuffer + offset)));
57  offset += sizeof(this->type);
58  uint8_t dimensions_lengthT = *(inbuffer + offset++);
59  if(dimensions_lengthT > dimensions_length)
60  this->dimensions = (float*)realloc(this->dimensions, dimensions_lengthT * sizeof(float));
61  offset += 3;
62  dimensions_length = dimensions_lengthT;
63  for( uint8_t i = 0; i < dimensions_length; i++){
64  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_dimensions));
65  memcpy( &(this->dimensions[i]), &(this->st_dimensions), sizeof(float));
66  }
67  return offset;
68  }
69 
70  const char * getType(){ return "shape_msgs/SolidPrimitive"; };
71  const char * getMD5(){ return "d8f8cbc74c5ff283fca29569ccefb45d"; };
72 
73  };
74 
75 }
76 #endif
Definition: SolidPrimitive.h:24
Definition: SolidPrimitive.h:22
static int serializeAvrFloat64(unsigned char *outbuffer, const float f)
This tricky function handles promoting a 32bit float to a 64bit double, so that AVR can publish messa...
Definition: msg.h:62
virtual int deserialize(unsigned char *inbuffer)
Definition: SolidPrimitive.h:53
Definition: SolidPrimitive.h:23
uint8_t type
Definition: SolidPrimitive.h:15
Definition: SolidPrimitive.h:26
Definition: SolidPrimitive.h:27
Definition: SolidPrimitive.h:29
Definition: SolidPrimitive.h:25
Definition: SolidPrimitive.h:12
float * dimensions
Definition: SolidPrimitive.h:18
Definition: SolidPrimitive.h:21
uint8_t dimensions_length
Definition: SolidPrimitive.h:16
Definition: SolidPrimitive.h:19
const char * getType()
Definition: SolidPrimitive.h:70
float st_dimensions
Definition: SolidPrimitive.h:17
const char * getMD5()
Definition: SolidPrimitive.h:71
Definition: SolidPrimitive.h:30
SolidPrimitive()
Definition: SolidPrimitive.h:32
Definition: SolidPrimitive.h:20
Definition: SolidPrimitive.h:28
virtual int serialize(unsigned char *outbuffer) const
Definition: SolidPrimitive.h:38
Definition: msg.h:43
static int deserializeAvrFloat64(const unsigned char *inbuffer, float *f)
This tricky function handles demoting a 64bit double to a 32bit float, so that AVR can understand mes...
Definition: msg.h:100