kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
TeensyDebug.h
Go to the documentation of this file.
1 #ifndef _ROS_kitt_debug_msgs_TeensyDebug_h
2 #define _ROS_kitt_debug_msgs_TeensyDebug_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 #include "ros/time.h"
9 
10 namespace kitt_debug_msgs
11 {
12 
13  class TeensyDebug : public ros::Msg
14  {
15  public:
16  bool imu_err;
17  bool mag_err;
23  int64_t encoder_left;
24  int64_t encoder_right;
26  float w_left;
27  float w_right;
28  int16_t bumper_left;
29  int16_t bumper_right;
30  bool e_stop;
31  int8_t fob_mode;
32  bool fob_stop_1;
33  bool fob_stop_2;
34  bool fob_stop_3;
35  bool fob_stop_4;
36 
38  imu_err(0),
39  mag_err(0),
45  encoder_left(0),
46  encoder_right(0),
48  w_left(0),
49  w_right(0),
50  bumper_left(0),
51  bumper_right(0),
52  e_stop(0),
53  fob_mode(0),
54  fob_stop_1(0),
55  fob_stop_2(0),
56  fob_stop_3(0),
57  fob_stop_4(0)
58  {
59  }
60 
61  virtual int serialize(unsigned char *outbuffer) const
62  {
63  int offset = 0;
64  union {
65  bool real;
66  uint8_t base;
67  } u_imu_err;
68  u_imu_err.real = this->imu_err;
69  *(outbuffer + offset + 0) = (u_imu_err.base >> (8 * 0)) & 0xFF;
70  offset += sizeof(this->imu_err);
71  union {
72  bool real;
73  uint8_t base;
74  } u_mag_err;
75  u_mag_err.real = this->mag_err;
76  *(outbuffer + offset + 0) = (u_mag_err.base >> (8 * 0)) & 0xFF;
77  offset += sizeof(this->mag_err);
78  offset += serializeAvrFloat64(outbuffer + offset, this->motor_speed_left);
79  offset += serializeAvrFloat64(outbuffer + offset, this->motor_speed_right);
80  *(outbuffer + offset + 0) = (this->last_cmd_vel_time.sec >> (8 * 0)) & 0xFF;
81  *(outbuffer + offset + 1) = (this->last_cmd_vel_time.sec >> (8 * 1)) & 0xFF;
82  *(outbuffer + offset + 2) = (this->last_cmd_vel_time.sec >> (8 * 2)) & 0xFF;
83  *(outbuffer + offset + 3) = (this->last_cmd_vel_time.sec >> (8 * 3)) & 0xFF;
84  offset += sizeof(this->last_cmd_vel_time.sec);
85  *(outbuffer + offset + 0) = (this->last_cmd_vel_time.nsec >> (8 * 0)) & 0xFF;
86  *(outbuffer + offset + 1) = (this->last_cmd_vel_time.nsec >> (8 * 1)) & 0xFF;
87  *(outbuffer + offset + 2) = (this->last_cmd_vel_time.nsec >> (8 * 2)) & 0xFF;
88  *(outbuffer + offset + 3) = (this->last_cmd_vel_time.nsec >> (8 * 3)) & 0xFF;
89  offset += sizeof(this->last_cmd_vel_time.nsec);
90  union {
91  bool real;
92  uint8_t base;
93  } u_cmd_vel_timeout_exceeded;
94  u_cmd_vel_timeout_exceeded.real = this->cmd_vel_timeout_exceeded;
95  *(outbuffer + offset + 0) = (u_cmd_vel_timeout_exceeded.base >> (8 * 0)) & 0xFF;
96  offset += sizeof(this->cmd_vel_timeout_exceeded);
97  *(outbuffer + offset + 0) = (this->last_raw_odom_publish_time.sec >> (8 * 0)) & 0xFF;
98  *(outbuffer + offset + 1) = (this->last_raw_odom_publish_time.sec >> (8 * 1)) & 0xFF;
99  *(outbuffer + offset + 2) = (this->last_raw_odom_publish_time.sec >> (8 * 2)) & 0xFF;
100  *(outbuffer + offset + 3) = (this->last_raw_odom_publish_time.sec >> (8 * 3)) & 0xFF;
101  offset += sizeof(this->last_raw_odom_publish_time.sec);
102  *(outbuffer + offset + 0) = (this->last_raw_odom_publish_time.nsec >> (8 * 0)) & 0xFF;
103  *(outbuffer + offset + 1) = (this->last_raw_odom_publish_time.nsec >> (8 * 1)) & 0xFF;
104  *(outbuffer + offset + 2) = (this->last_raw_odom_publish_time.nsec >> (8 * 2)) & 0xFF;
105  *(outbuffer + offset + 3) = (this->last_raw_odom_publish_time.nsec >> (8 * 3)) & 0xFF;
106  offset += sizeof(this->last_raw_odom_publish_time.nsec);
107  union {
108  int64_t real;
109  uint64_t base;
110  } u_encoder_left;
111  u_encoder_left.real = this->encoder_left;
112  *(outbuffer + offset + 0) = (u_encoder_left.base >> (8 * 0)) & 0xFF;
113  *(outbuffer + offset + 1) = (u_encoder_left.base >> (8 * 1)) & 0xFF;
114  *(outbuffer + offset + 2) = (u_encoder_left.base >> (8 * 2)) & 0xFF;
115  *(outbuffer + offset + 3) = (u_encoder_left.base >> (8 * 3)) & 0xFF;
116  *(outbuffer + offset + 4) = (u_encoder_left.base >> (8 * 4)) & 0xFF;
117  *(outbuffer + offset + 5) = (u_encoder_left.base >> (8 * 5)) & 0xFF;
118  *(outbuffer + offset + 6) = (u_encoder_left.base >> (8 * 6)) & 0xFF;
119  *(outbuffer + offset + 7) = (u_encoder_left.base >> (8 * 7)) & 0xFF;
120  offset += sizeof(this->encoder_left);
121  union {
122  int64_t real;
123  uint64_t base;
124  } u_encoder_right;
125  u_encoder_right.real = this->encoder_right;
126  *(outbuffer + offset + 0) = (u_encoder_right.base >> (8 * 0)) & 0xFF;
127  *(outbuffer + offset + 1) = (u_encoder_right.base >> (8 * 1)) & 0xFF;
128  *(outbuffer + offset + 2) = (u_encoder_right.base >> (8 * 2)) & 0xFF;
129  *(outbuffer + offset + 3) = (u_encoder_right.base >> (8 * 3)) & 0xFF;
130  *(outbuffer + offset + 4) = (u_encoder_right.base >> (8 * 4)) & 0xFF;
131  *(outbuffer + offset + 5) = (u_encoder_right.base >> (8 * 5)) & 0xFF;
132  *(outbuffer + offset + 6) = (u_encoder_right.base >> (8 * 6)) & 0xFF;
133  *(outbuffer + offset + 7) = (u_encoder_right.base >> (8 * 7)) & 0xFF;
134  offset += sizeof(this->encoder_right);
135  *(outbuffer + offset + 0) = (this->last_encoder_read_time.sec >> (8 * 0)) & 0xFF;
136  *(outbuffer + offset + 1) = (this->last_encoder_read_time.sec >> (8 * 1)) & 0xFF;
137  *(outbuffer + offset + 2) = (this->last_encoder_read_time.sec >> (8 * 2)) & 0xFF;
138  *(outbuffer + offset + 3) = (this->last_encoder_read_time.sec >> (8 * 3)) & 0xFF;
139  offset += sizeof(this->last_encoder_read_time.sec);
140  *(outbuffer + offset + 0) = (this->last_encoder_read_time.nsec >> (8 * 0)) & 0xFF;
141  *(outbuffer + offset + 1) = (this->last_encoder_read_time.nsec >> (8 * 1)) & 0xFF;
142  *(outbuffer + offset + 2) = (this->last_encoder_read_time.nsec >> (8 * 2)) & 0xFF;
143  *(outbuffer + offset + 3) = (this->last_encoder_read_time.nsec >> (8 * 3)) & 0xFF;
144  offset += sizeof(this->last_encoder_read_time.nsec);
145  offset += serializeAvrFloat64(outbuffer + offset, this->w_left);
146  offset += serializeAvrFloat64(outbuffer + offset, this->w_right);
147  union {
148  int16_t real;
149  uint16_t base;
150  } u_bumper_left;
151  u_bumper_left.real = this->bumper_left;
152  *(outbuffer + offset + 0) = (u_bumper_left.base >> (8 * 0)) & 0xFF;
153  *(outbuffer + offset + 1) = (u_bumper_left.base >> (8 * 1)) & 0xFF;
154  offset += sizeof(this->bumper_left);
155  union {
156  int16_t real;
157  uint16_t base;
158  } u_bumper_right;
159  u_bumper_right.real = this->bumper_right;
160  *(outbuffer + offset + 0) = (u_bumper_right.base >> (8 * 0)) & 0xFF;
161  *(outbuffer + offset + 1) = (u_bumper_right.base >> (8 * 1)) & 0xFF;
162  offset += sizeof(this->bumper_right);
163  union {
164  bool real;
165  uint8_t base;
166  } u_e_stop;
167  u_e_stop.real = this->e_stop;
168  *(outbuffer + offset + 0) = (u_e_stop.base >> (8 * 0)) & 0xFF;
169  offset += sizeof(this->e_stop);
170  union {
171  int8_t real;
172  uint8_t base;
173  } u_fob_mode;
174  u_fob_mode.real = this->fob_mode;
175  *(outbuffer + offset + 0) = (u_fob_mode.base >> (8 * 0)) & 0xFF;
176  offset += sizeof(this->fob_mode);
177  union {
178  bool real;
179  uint8_t base;
180  } u_fob_stop_1;
181  u_fob_stop_1.real = this->fob_stop_1;
182  *(outbuffer + offset + 0) = (u_fob_stop_1.base >> (8 * 0)) & 0xFF;
183  offset += sizeof(this->fob_stop_1);
184  union {
185  bool real;
186  uint8_t base;
187  } u_fob_stop_2;
188  u_fob_stop_2.real = this->fob_stop_2;
189  *(outbuffer + offset + 0) = (u_fob_stop_2.base >> (8 * 0)) & 0xFF;
190  offset += sizeof(this->fob_stop_2);
191  union {
192  bool real;
193  uint8_t base;
194  } u_fob_stop_3;
195  u_fob_stop_3.real = this->fob_stop_3;
196  *(outbuffer + offset + 0) = (u_fob_stop_3.base >> (8 * 0)) & 0xFF;
197  offset += sizeof(this->fob_stop_3);
198  union {
199  bool real;
200  uint8_t base;
201  } u_fob_stop_4;
202  u_fob_stop_4.real = this->fob_stop_4;
203  *(outbuffer + offset + 0) = (u_fob_stop_4.base >> (8 * 0)) & 0xFF;
204  offset += sizeof(this->fob_stop_4);
205  return offset;
206  }
207 
208  virtual int deserialize(unsigned char *inbuffer)
209  {
210  int offset = 0;
211  union {
212  bool real;
213  uint8_t base;
214  } u_imu_err;
215  u_imu_err.base = 0;
216  u_imu_err.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
217  this->imu_err = u_imu_err.real;
218  offset += sizeof(this->imu_err);
219  union {
220  bool real;
221  uint8_t base;
222  } u_mag_err;
223  u_mag_err.base = 0;
224  u_mag_err.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
225  this->mag_err = u_mag_err.real;
226  offset += sizeof(this->mag_err);
227  offset += deserializeAvrFloat64(inbuffer + offset, &(this->motor_speed_left));
228  offset += deserializeAvrFloat64(inbuffer + offset, &(this->motor_speed_right));
229  this->last_cmd_vel_time.sec = ((uint32_t) (*(inbuffer + offset)));
230  this->last_cmd_vel_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
231  this->last_cmd_vel_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
232  this->last_cmd_vel_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
233  offset += sizeof(this->last_cmd_vel_time.sec);
234  this->last_cmd_vel_time.nsec = ((uint32_t) (*(inbuffer + offset)));
235  this->last_cmd_vel_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
236  this->last_cmd_vel_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
237  this->last_cmd_vel_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
238  offset += sizeof(this->last_cmd_vel_time.nsec);
239  union {
240  bool real;
241  uint8_t base;
242  } u_cmd_vel_timeout_exceeded;
243  u_cmd_vel_timeout_exceeded.base = 0;
244  u_cmd_vel_timeout_exceeded.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
245  this->cmd_vel_timeout_exceeded = u_cmd_vel_timeout_exceeded.real;
246  offset += sizeof(this->cmd_vel_timeout_exceeded);
247  this->last_raw_odom_publish_time.sec = ((uint32_t) (*(inbuffer + offset)));
248  this->last_raw_odom_publish_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
249  this->last_raw_odom_publish_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
250  this->last_raw_odom_publish_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
251  offset += sizeof(this->last_raw_odom_publish_time.sec);
252  this->last_raw_odom_publish_time.nsec = ((uint32_t) (*(inbuffer + offset)));
253  this->last_raw_odom_publish_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
254  this->last_raw_odom_publish_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
255  this->last_raw_odom_publish_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
256  offset += sizeof(this->last_raw_odom_publish_time.nsec);
257  union {
258  int64_t real;
259  uint64_t base;
260  } u_encoder_left;
261  u_encoder_left.base = 0;
262  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
263  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
264  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
265  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
266  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
267  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
268  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
269  u_encoder_left.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
270  this->encoder_left = u_encoder_left.real;
271  offset += sizeof(this->encoder_left);
272  union {
273  int64_t real;
274  uint64_t base;
275  } u_encoder_right;
276  u_encoder_right.base = 0;
277  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
278  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
279  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
280  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
281  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
282  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
283  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
284  u_encoder_right.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
285  this->encoder_right = u_encoder_right.real;
286  offset += sizeof(this->encoder_right);
287  this->last_encoder_read_time.sec = ((uint32_t) (*(inbuffer + offset)));
288  this->last_encoder_read_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
289  this->last_encoder_read_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
290  this->last_encoder_read_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
291  offset += sizeof(this->last_encoder_read_time.sec);
292  this->last_encoder_read_time.nsec = ((uint32_t) (*(inbuffer + offset)));
293  this->last_encoder_read_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
294  this->last_encoder_read_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
295  this->last_encoder_read_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
296  offset += sizeof(this->last_encoder_read_time.nsec);
297  offset += deserializeAvrFloat64(inbuffer + offset, &(this->w_left));
298  offset += deserializeAvrFloat64(inbuffer + offset, &(this->w_right));
299  union {
300  int16_t real;
301  uint16_t base;
302  } u_bumper_left;
303  u_bumper_left.base = 0;
304  u_bumper_left.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
305  u_bumper_left.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
306  this->bumper_left = u_bumper_left.real;
307  offset += sizeof(this->bumper_left);
308  union {
309  int16_t real;
310  uint16_t base;
311  } u_bumper_right;
312  u_bumper_right.base = 0;
313  u_bumper_right.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
314  u_bumper_right.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
315  this->bumper_right = u_bumper_right.real;
316  offset += sizeof(this->bumper_right);
317  union {
318  bool real;
319  uint8_t base;
320  } u_e_stop;
321  u_e_stop.base = 0;
322  u_e_stop.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
323  this->e_stop = u_e_stop.real;
324  offset += sizeof(this->e_stop);
325  union {
326  int8_t real;
327  uint8_t base;
328  } u_fob_mode;
329  u_fob_mode.base = 0;
330  u_fob_mode.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
331  this->fob_mode = u_fob_mode.real;
332  offset += sizeof(this->fob_mode);
333  union {
334  bool real;
335  uint8_t base;
336  } u_fob_stop_1;
337  u_fob_stop_1.base = 0;
338  u_fob_stop_1.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
339  this->fob_stop_1 = u_fob_stop_1.real;
340  offset += sizeof(this->fob_stop_1);
341  union {
342  bool real;
343  uint8_t base;
344  } u_fob_stop_2;
345  u_fob_stop_2.base = 0;
346  u_fob_stop_2.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
347  this->fob_stop_2 = u_fob_stop_2.real;
348  offset += sizeof(this->fob_stop_2);
349  union {
350  bool real;
351  uint8_t base;
352  } u_fob_stop_3;
353  u_fob_stop_3.base = 0;
354  u_fob_stop_3.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
355  this->fob_stop_3 = u_fob_stop_3.real;
356  offset += sizeof(this->fob_stop_3);
357  union {
358  bool real;
359  uint8_t base;
360  } u_fob_stop_4;
361  u_fob_stop_4.base = 0;
362  u_fob_stop_4.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
363  this->fob_stop_4 = u_fob_stop_4.real;
364  offset += sizeof(this->fob_stop_4);
365  return offset;
366  }
367 
368  const char * getType(){ return "kitt_debug_msgs/TeensyDebug"; };
369  const char * getMD5(){ return "f2054d2711de041c0f25b17204dbe68e"; };
370 
371  };
372 
373 }
374 #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
bool fob_stop_2
Definition: TeensyDebug.h:33
bool imu_err
Definition: TeensyDebug.h:16
uint32_t nsec
Definition: time.h:50
uint32_t sec
Definition: time.h:50
Definition: time.h:47
bool mag_err
Definition: TeensyDebug.h:17
ros::Time last_encoder_read_time
Definition: TeensyDebug.h:25
float motor_speed_right
Definition: TeensyDebug.h:19
float w_right
Definition: TeensyDebug.h:27
ros::Time last_raw_odom_publish_time
Definition: TeensyDebug.h:22
int64_t encoder_right
Definition: TeensyDebug.h:24
int16_t bumper_right
Definition: TeensyDebug.h:29
int8_t fob_mode
Definition: TeensyDebug.h:31
bool fob_stop_4
Definition: TeensyDebug.h:35
Definition: TeensyDebug.h:13
float motor_speed_left
Definition: TeensyDebug.h:18
bool fob_stop_1
Definition: TeensyDebug.h:32
bool e_stop
Definition: TeensyDebug.h:30
float w_left
Definition: TeensyDebug.h:26
const char * getType()
Definition: TeensyDebug.h:368
virtual int serialize(unsigned char *outbuffer) const
Definition: TeensyDebug.h:61
bool fob_stop_3
Definition: TeensyDebug.h:34
int16_t bumper_left
Definition: TeensyDebug.h:28
ros::Time last_cmd_vel_time
Definition: TeensyDebug.h:20
virtual int deserialize(unsigned char *inbuffer)
Definition: TeensyDebug.h:208
const char * getMD5()
Definition: TeensyDebug.h:369
bool cmd_vel_timeout_exceeded
Definition: TeensyDebug.h:21
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
TeensyDebug()
Definition: TeensyDebug.h:37
int64_t encoder_left
Definition: TeensyDebug.h:23