kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
JointTrajectoryPoint.h
Go to the documentation of this file.
1 #ifndef _ROS_trajectory_msgs_JointTrajectoryPoint_h
2 #define _ROS_trajectory_msgs_JointTrajectoryPoint_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 #include "ros/duration.h"
9 
10 namespace trajectory_msgs
11 {
12 
14  {
15  public:
17  float st_positions;
18  float * positions;
21  float * velocities;
24  float * accelerations;
25  uint8_t effort_length;
26  float st_effort;
27  float * effort;
29 
31  positions_length(0), positions(NULL),
32  velocities_length(0), velocities(NULL),
34  effort_length(0), effort(NULL),
36  {
37  }
38 
39  virtual int serialize(unsigned char *outbuffer) const
40  {
41  int offset = 0;
42  *(outbuffer + offset++) = positions_length;
43  *(outbuffer + offset++) = 0;
44  *(outbuffer + offset++) = 0;
45  *(outbuffer + offset++) = 0;
46  for( uint8_t i = 0; i < positions_length; i++){
47  offset += serializeAvrFloat64(outbuffer + offset, this->positions[i]);
48  }
49  *(outbuffer + offset++) = velocities_length;
50  *(outbuffer + offset++) = 0;
51  *(outbuffer + offset++) = 0;
52  *(outbuffer + offset++) = 0;
53  for( uint8_t i = 0; i < velocities_length; i++){
54  offset += serializeAvrFloat64(outbuffer + offset, this->velocities[i]);
55  }
56  *(outbuffer + offset++) = accelerations_length;
57  *(outbuffer + offset++) = 0;
58  *(outbuffer + offset++) = 0;
59  *(outbuffer + offset++) = 0;
60  for( uint8_t i = 0; i < accelerations_length; i++){
61  offset += serializeAvrFloat64(outbuffer + offset, this->accelerations[i]);
62  }
63  *(outbuffer + offset++) = effort_length;
64  *(outbuffer + offset++) = 0;
65  *(outbuffer + offset++) = 0;
66  *(outbuffer + offset++) = 0;
67  for( uint8_t i = 0; i < effort_length; i++){
68  offset += serializeAvrFloat64(outbuffer + offset, this->effort[i]);
69  }
70  *(outbuffer + offset + 0) = (this->time_from_start.sec >> (8 * 0)) & 0xFF;
71  *(outbuffer + offset + 1) = (this->time_from_start.sec >> (8 * 1)) & 0xFF;
72  *(outbuffer + offset + 2) = (this->time_from_start.sec >> (8 * 2)) & 0xFF;
73  *(outbuffer + offset + 3) = (this->time_from_start.sec >> (8 * 3)) & 0xFF;
74  offset += sizeof(this->time_from_start.sec);
75  *(outbuffer + offset + 0) = (this->time_from_start.nsec >> (8 * 0)) & 0xFF;
76  *(outbuffer + offset + 1) = (this->time_from_start.nsec >> (8 * 1)) & 0xFF;
77  *(outbuffer + offset + 2) = (this->time_from_start.nsec >> (8 * 2)) & 0xFF;
78  *(outbuffer + offset + 3) = (this->time_from_start.nsec >> (8 * 3)) & 0xFF;
79  offset += sizeof(this->time_from_start.nsec);
80  return offset;
81  }
82 
83  virtual int deserialize(unsigned char *inbuffer)
84  {
85  int offset = 0;
86  uint8_t positions_lengthT = *(inbuffer + offset++);
87  if(positions_lengthT > positions_length)
88  this->positions = (float*)realloc(this->positions, positions_lengthT * sizeof(float));
89  offset += 3;
90  positions_length = positions_lengthT;
91  for( uint8_t i = 0; i < positions_length; i++){
92  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_positions));
93  memcpy( &(this->positions[i]), &(this->st_positions), sizeof(float));
94  }
95  uint8_t velocities_lengthT = *(inbuffer + offset++);
96  if(velocities_lengthT > velocities_length)
97  this->velocities = (float*)realloc(this->velocities, velocities_lengthT * sizeof(float));
98  offset += 3;
99  velocities_length = velocities_lengthT;
100  for( uint8_t i = 0; i < velocities_length; i++){
101  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_velocities));
102  memcpy( &(this->velocities[i]), &(this->st_velocities), sizeof(float));
103  }
104  uint8_t accelerations_lengthT = *(inbuffer + offset++);
105  if(accelerations_lengthT > accelerations_length)
106  this->accelerations = (float*)realloc(this->accelerations, accelerations_lengthT * sizeof(float));
107  offset += 3;
108  accelerations_length = accelerations_lengthT;
109  for( uint8_t i = 0; i < accelerations_length; i++){
110  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_accelerations));
111  memcpy( &(this->accelerations[i]), &(this->st_accelerations), sizeof(float));
112  }
113  uint8_t effort_lengthT = *(inbuffer + offset++);
114  if(effort_lengthT > effort_length)
115  this->effort = (float*)realloc(this->effort, effort_lengthT * sizeof(float));
116  offset += 3;
117  effort_length = effort_lengthT;
118  for( uint8_t i = 0; i < effort_length; i++){
119  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_effort));
120  memcpy( &(this->effort[i]), &(this->st_effort), sizeof(float));
121  }
122  this->time_from_start.sec = ((uint32_t) (*(inbuffer + offset)));
123  this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
124  this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
125  this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
126  offset += sizeof(this->time_from_start.sec);
127  this->time_from_start.nsec = ((uint32_t) (*(inbuffer + offset)));
128  this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
129  this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
130  this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
131  offset += sizeof(this->time_from_start.nsec);
132  return offset;
133  }
134 
135  const char * getType(){ return "trajectory_msgs/JointTrajectoryPoint"; };
136  const char * getMD5(){ return "f3cd1e1c4d320c79d6985c904ae5dcd3"; };
137 
138  };
139 
140 }
141 #endif
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: JointTrajectoryPoint.h:83
uint8_t accelerations_length
Definition: JointTrajectoryPoint.h:22
uint8_t velocities_length
Definition: JointTrajectoryPoint.h:19
int32_t sec
Definition: duration.h:48
float * velocities
Definition: JointTrajectoryPoint.h:21
float st_accelerations
Definition: JointTrajectoryPoint.h:23
float st_velocities
Definition: JointTrajectoryPoint.h:20
const char * getMD5()
Definition: JointTrajectoryPoint.h:136
uint8_t positions_length
Definition: JointTrajectoryPoint.h:16
float * effort
Definition: JointTrajectoryPoint.h:27
JointTrajectoryPoint()
Definition: JointTrajectoryPoint.h:30
Definition: JointTrajectoryPoint.h:13
float st_effort
Definition: JointTrajectoryPoint.h:26
const char * getType()
Definition: JointTrajectoryPoint.h:135
uint8_t effort_length
Definition: JointTrajectoryPoint.h:25
float * positions
Definition: JointTrajectoryPoint.h:18
Definition: duration.h:45
virtual int serialize(unsigned char *outbuffer) const
Definition: JointTrajectoryPoint.h:39
int32_t nsec
Definition: duration.h:48
Definition: msg.h:43
float * accelerations
Definition: JointTrajectoryPoint.h:24
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
ros::Duration time_from_start
Definition: JointTrajectoryPoint.h:28
float st_positions
Definition: JointTrajectoryPoint.h:17