kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
JointState.h
Go to the documentation of this file.
1 #ifndef _ROS_sensor_msgs_JointState_h
2 #define _ROS_sensor_msgs_JointState_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"
9 
10 namespace sensor_msgs
11 {
12 
13  class JointState : public ros::Msg
14  {
15  public:
17  uint8_t name_length;
18  char* st_name;
19  char* * name;
20  uint8_t position_length;
21  float st_position;
22  float * position;
23  uint8_t velocity_length;
24  float st_velocity;
25  float * velocity;
26  uint8_t effort_length;
27  float st_effort;
28  float * effort;
29 
31  header(),
32  name_length(0), name(NULL),
33  position_length(0), position(NULL),
34  velocity_length(0), velocity(NULL),
35  effort_length(0), effort(NULL)
36  {
37  }
38 
39  virtual int serialize(unsigned char *outbuffer) const
40  {
41  int offset = 0;
42  offset += this->header.serialize(outbuffer + offset);
43  *(outbuffer + offset++) = name_length;
44  *(outbuffer + offset++) = 0;
45  *(outbuffer + offset++) = 0;
46  *(outbuffer + offset++) = 0;
47  for( uint8_t i = 0; i < name_length; i++){
48  uint32_t length_namei = strlen(this->name[i]);
49  memcpy(outbuffer + offset, &length_namei, sizeof(uint32_t));
50  offset += 4;
51  memcpy(outbuffer + offset, this->name[i], length_namei);
52  offset += length_namei;
53  }
54  *(outbuffer + offset++) = position_length;
55  *(outbuffer + offset++) = 0;
56  *(outbuffer + offset++) = 0;
57  *(outbuffer + offset++) = 0;
58  for( uint8_t i = 0; i < position_length; i++){
59  offset += serializeAvrFloat64(outbuffer + offset, this->position[i]);
60  }
61  *(outbuffer + offset++) = velocity_length;
62  *(outbuffer + offset++) = 0;
63  *(outbuffer + offset++) = 0;
64  *(outbuffer + offset++) = 0;
65  for( uint8_t i = 0; i < velocity_length; i++){
66  offset += serializeAvrFloat64(outbuffer + offset, this->velocity[i]);
67  }
68  *(outbuffer + offset++) = effort_length;
69  *(outbuffer + offset++) = 0;
70  *(outbuffer + offset++) = 0;
71  *(outbuffer + offset++) = 0;
72  for( uint8_t i = 0; i < effort_length; i++){
73  offset += serializeAvrFloat64(outbuffer + offset, this->effort[i]);
74  }
75  return offset;
76  }
77 
78  virtual int deserialize(unsigned char *inbuffer)
79  {
80  int offset = 0;
81  offset += this->header.deserialize(inbuffer + offset);
82  uint8_t name_lengthT = *(inbuffer + offset++);
83  if(name_lengthT > name_length)
84  this->name = (char**)realloc(this->name, name_lengthT * sizeof(char*));
85  offset += 3;
86  name_length = name_lengthT;
87  for( uint8_t i = 0; i < name_length; i++){
88  uint32_t length_st_name;
89  memcpy(&length_st_name, (inbuffer + offset), sizeof(uint32_t));
90  offset += 4;
91  for(unsigned int k= offset; k< offset+length_st_name; ++k){
92  inbuffer[k-1]=inbuffer[k];
93  }
94  inbuffer[offset+length_st_name-1]=0;
95  this->st_name = (char *)(inbuffer + offset-1);
96  offset += length_st_name;
97  memcpy( &(this->name[i]), &(this->st_name), sizeof(char*));
98  }
99  uint8_t position_lengthT = *(inbuffer + offset++);
100  if(position_lengthT > position_length)
101  this->position = (float*)realloc(this->position, position_lengthT * sizeof(float));
102  offset += 3;
103  position_length = position_lengthT;
104  for( uint8_t i = 0; i < position_length; i++){
105  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_position));
106  memcpy( &(this->position[i]), &(this->st_position), sizeof(float));
107  }
108  uint8_t velocity_lengthT = *(inbuffer + offset++);
109  if(velocity_lengthT > velocity_length)
110  this->velocity = (float*)realloc(this->velocity, velocity_lengthT * sizeof(float));
111  offset += 3;
112  velocity_length = velocity_lengthT;
113  for( uint8_t i = 0; i < velocity_length; i++){
114  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_velocity));
115  memcpy( &(this->velocity[i]), &(this->st_velocity), sizeof(float));
116  }
117  uint8_t effort_lengthT = *(inbuffer + offset++);
118  if(effort_lengthT > effort_length)
119  this->effort = (float*)realloc(this->effort, effort_lengthT * sizeof(float));
120  offset += 3;
121  effort_length = effort_lengthT;
122  for( uint8_t i = 0; i < effort_length; i++){
123  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_effort));
124  memcpy( &(this->effort[i]), &(this->st_effort), sizeof(float));
125  }
126  return offset;
127  }
128 
129  const char * getType(){ return "sensor_msgs/JointState"; };
130  const char * getMD5(){ return "3066dcd76a6cfaef579bd0f34173e9fd"; };
131 
132  };
133 
134 }
135 #endif
float st_effort
Definition: JointState.h:27
virtual int deserialize(unsigned char *inbuffer)
Definition: Header.h:53
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
uint8_t position_length
Definition: JointState.h:20
const char * getMD5()
Definition: JointState.h:130
float * velocity
Definition: JointState.h:25
uint8_t name_length
Definition: JointState.h:17
std_msgs::Header header
Definition: JointState.h:16
virtual int serialize(unsigned char *outbuffer) const
Definition: JointState.h:39
virtual int serialize(unsigned char *outbuffer) const
Definition: Header.h:27
virtual int deserialize(unsigned char *inbuffer)
Definition: JointState.h:78
float st_position
Definition: JointState.h:21
char ** name
Definition: JointState.h:19
float * position
Definition: JointState.h:22
Definition: Header.h:13
Definition: JointState.h:13
uint8_t effort_length
Definition: JointState.h:26
const char * getType()
Definition: JointState.h:129
JointState()
Definition: JointState.h:30
uint8_t velocity_length
Definition: JointState.h:23
float st_velocity
Definition: JointState.h:24
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
char * st_name
Definition: JointState.h:18
float * effort
Definition: JointState.h:28