diff options
Diffstat (limited to 'lcmtype/robot_control_t.cpp')
-rw-r--r-- | lcmtype/robot_control_t.cpp | 478 |
1 files changed, 478 insertions, 0 deletions
diff --git a/lcmtype/robot_control_t.cpp b/lcmtype/robot_control_t.cpp new file mode 100644 index 0000000..d633435 --- /dev/null +++ b/lcmtype/robot_control_t.cpp | |||
@@ -0,0 +1,478 @@ | |||
1 | /** THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY | ||
2 | * BY HAND!! | ||
3 | * | ||
4 | * Generated by lcm-gen | ||
5 | **/ | ||
6 | |||
7 | #include "robot_control_t.h" | ||
8 | #include <string.h> | ||
9 | |||
10 | static int __robot_control_t_hash_computed; | ||
11 | static int64_t __robot_control_t_hash; | ||
12 | |||
13 | int64_t __robot_control_t_hash_recursive(const __lcm_hash_ptr *p) { | ||
14 | const __lcm_hash_ptr *fp; | ||
15 | for (fp = p; fp != NULL; fp = fp->parent) | ||
16 | if (fp->v == __robot_control_t_get_hash) | ||
17 | return 0; | ||
18 | |||
19 | const __lcm_hash_ptr cp = {p, (void *)__robot_control_t_get_hash}; | ||
20 | (void)cp; | ||
21 | |||
22 | int64_t hash = 0x38f63251f9863f70LL + __int64_t_hash_recursive(&cp) + | ||
23 | __int8_t_hash_recursive(&cp) + __int8_t_hash_recursive(&cp) + | ||
24 | __int8_t_hash_recursive(&cp) + __double_hash_recursive(&cp) + | ||
25 | __int8_t_hash_recursive(&cp) + __int8_t_hash_recursive(&cp) + | ||
26 | __int8_t_hash_recursive(&cp) + __string_hash_recursive(&cp) + | ||
27 | __int64_t_hash_recursive(&cp) + __byte_hash_recursive(&cp); | ||
28 | |||
29 | return (hash << 1) + ((hash >> 63) & 1); | ||
30 | } | ||
31 | |||
32 | int64_t __robot_control_t_get_hash(void) { | ||
33 | if (!__robot_control_t_hash_computed) { | ||
34 | __robot_control_t_hash = __robot_control_t_hash_recursive(NULL); | ||
35 | __robot_control_t_hash_computed = 1; | ||
36 | } | ||
37 | |||
38 | return __robot_control_t_hash; | ||
39 | } | ||
40 | |||
41 | int __robot_control_t_encode_array(void *buf, int offset, int maxlen, | ||
42 | const robot_control_t *p, int elements) { | ||
43 | int pos = 0, thislen, element; | ||
44 | |||
45 | for (element = 0; element < elements; element++) { | ||
46 | |||
47 | thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, | ||
48 | &(p[element].utime), 1); | ||
49 | if (thislen < 0) | ||
50 | return thislen; | ||
51 | else | ||
52 | pos += thislen; | ||
53 | |||
54 | thislen = __int8_t_encode_array(buf, offset + pos, maxlen - pos, | ||
55 | &(p[element].commandid), 1); | ||
56 | if (thislen < 0) | ||
57 | return thislen; | ||
58 | else | ||
59 | pos += thislen; | ||
60 | |||
61 | thislen = __int8_t_encode_array(buf, offset + pos, maxlen - pos, | ||
62 | &(p[element].robotid), 1); | ||
63 | if (thislen < 0) | ||
64 | return thislen; | ||
65 | else | ||
66 | pos += thislen; | ||
67 | |||
68 | thislen = __int8_t_encode_array(buf, offset + pos, maxlen - pos, | ||
69 | &(p[element].ndparams), 1); | ||
70 | if (thislen < 0) | ||
71 | return thislen; | ||
72 | else | ||
73 | pos += thislen; | ||
74 | |||
75 | thislen = | ||
76 | __double_encode_array(buf, offset + pos, maxlen - pos, | ||
77 | p[element].dparams, p[element].ndparams); | ||
78 | if (thislen < 0) | ||
79 | return thislen; | ||
80 | else | ||
81 | pos += thislen; | ||
82 | |||
83 | thislen = __int8_t_encode_array(buf, offset + pos, maxlen - pos, | ||
84 | &(p[element].niparams), 1); | ||
85 | if (thislen < 0) | ||
86 | return thislen; | ||
87 | else | ||
88 | pos += thislen; | ||
89 | |||
90 | thislen = | ||
91 | __int8_t_encode_array(buf, offset + pos, maxlen - pos, | ||
92 | p[element].iparams, p[element].niparams); | ||
93 | if (thislen < 0) | ||
94 | return thislen; | ||
95 | else | ||
96 | pos += thislen; | ||
97 | |||
98 | thislen = __int8_t_encode_array(buf, offset + pos, maxlen - pos, | ||
99 | &(p[element].nsparams), 1); | ||
100 | if (thislen < 0) | ||
101 | return thislen; | ||
102 | else | ||
103 | pos += thislen; | ||
104 | |||
105 | thislen = | ||
106 | __string_encode_array(buf, offset + pos, maxlen - pos, | ||
107 | p[element].sparams, p[element].nsparams); | ||
108 | if (thislen < 0) | ||
109 | return thislen; | ||
110 | else | ||
111 | pos += thislen; | ||
112 | |||
113 | thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, | ||
114 | &(p[element].nbparams), 1); | ||
115 | if (thislen < 0) | ||
116 | return thislen; | ||
117 | else | ||
118 | pos += thislen; | ||
119 | |||
120 | thislen = __byte_encode_array(buf, offset + pos, maxlen - pos, | ||
121 | p[element].bparams, p[element].nbparams); | ||
122 | if (thislen < 0) | ||
123 | return thislen; | ||
124 | else | ||
125 | pos += thislen; | ||
126 | } | ||
127 | return pos; | ||
128 | } | ||
129 | |||
130 | int robot_control_t_encode(void *buf, int offset, int maxlen, | ||
131 | const robot_control_t *p) { | ||
132 | int pos = 0, thislen; | ||
133 | int64_t hash = __robot_control_t_get_hash(); | ||
134 | |||
135 | thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); | ||
136 | if (thislen < 0) | ||
137 | return thislen; | ||
138 | else | ||
139 | pos += thislen; | ||
140 | |||
141 | thislen = | ||
142 | __robot_control_t_encode_array(buf, offset + pos, maxlen - pos, p, 1); | ||
143 | if (thislen < 0) | ||
144 | return thislen; | ||
145 | else | ||
146 | pos += thislen; | ||
147 | |||
148 | return pos; | ||
149 | } | ||
150 | |||
151 | int __robot_control_t_encoded_array_size(const robot_control_t *p, | ||
152 | int elements) { | ||
153 | int size = 0, element; | ||
154 | for (element = 0; element < elements; element++) { | ||
155 | |||
156 | size += __int64_t_encoded_array_size(&(p[element].utime), 1); | ||
157 | |||
158 | size += __int8_t_encoded_array_size(&(p[element].commandid), 1); | ||
159 | |||
160 | size += __int8_t_encoded_array_size(&(p[element].robotid), 1); | ||
161 | |||
162 | size += __int8_t_encoded_array_size(&(p[element].ndparams), 1); | ||
163 | |||
164 | size += __double_encoded_array_size(p[element].dparams, | ||
165 | p[element].ndparams); | ||
166 | |||
167 | size += __int8_t_encoded_array_size(&(p[element].niparams), 1); | ||
168 | |||
169 | size += __int8_t_encoded_array_size(p[element].iparams, | ||
170 | p[element].niparams); | ||
171 | |||
172 | size += __int8_t_encoded_array_size(&(p[element].nsparams), 1); | ||
173 | |||
174 | size += __string_encoded_array_size(p[element].sparams, | ||
175 | p[element].nsparams); | ||
176 | |||
177 | size += __int64_t_encoded_array_size(&(p[element].nbparams), 1); | ||
178 | |||
179 | size += | ||
180 | __byte_encoded_array_size(p[element].bparams, p[element].nbparams); | ||
181 | } | ||
182 | return size; | ||
183 | } | ||
184 | |||
185 | int robot_control_t_encoded_size(const robot_control_t *p) { | ||
186 | return 8 + __robot_control_t_encoded_array_size(p, 1); | ||
187 | } | ||
188 | |||
189 | int __robot_control_t_decode_array(const void *buf, int offset, int maxlen, | ||
190 | robot_control_t *p, int elements) { | ||
191 | int pos = 0, thislen, element; | ||
192 | |||
193 | for (element = 0; element < elements; element++) { | ||
194 | |||
195 | thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, | ||
196 | &(p[element].utime), 1); | ||
197 | if (thislen < 0) | ||
198 | return thislen; | ||
199 | else | ||
200 | pos += thislen; | ||
201 | |||
202 | thislen = __int8_t_decode_array(buf, offset + pos, maxlen - pos, | ||
203 | &(p[element].commandid), 1); | ||
204 | if (thislen < 0) | ||
205 | return thislen; | ||
206 | else | ||
207 | pos += thislen; | ||
208 | |||
209 | thislen = __int8_t_decode_array(buf, offset + pos, maxlen - pos, | ||
210 | &(p[element].robotid), 1); | ||
211 | if (thislen < 0) | ||
212 | return thislen; | ||
213 | else | ||
214 | pos += thislen; | ||
215 | |||
216 | thislen = __int8_t_decode_array(buf, offset + pos, maxlen - pos, | ||
217 | &(p[element].ndparams), 1); | ||
218 | if (thislen < 0) | ||
219 | return thislen; | ||
220 | else | ||
221 | pos += thislen; | ||
222 | |||
223 | p[element].dparams = | ||
224 | (double *)lcm_malloc(sizeof(double) * p[element].ndparams); | ||
225 | thislen = | ||
226 | __double_decode_array(buf, offset + pos, maxlen - pos, | ||
227 | p[element].dparams, p[element].ndparams); | ||
228 | if (thislen < 0) | ||
229 | return thislen; | ||
230 | else | ||
231 | pos += thislen; | ||
232 | |||
233 | thislen = __int8_t_decode_array(buf, offset + pos, maxlen - pos, | ||
234 | &(p[element].niparams), 1); | ||
235 | if (thislen < 0) | ||
236 | return thislen; | ||
237 | else | ||
238 | pos += thislen; | ||
239 | |||
240 | p[element].iparams = | ||
241 | (int8_t *)lcm_malloc(sizeof(int8_t) * p[element].niparams); | ||
242 | thislen = | ||
243 | __int8_t_decode_array(buf, offset + pos, maxlen - pos, | ||
244 | p[element].iparams, p[element].niparams); | ||
245 | if (thislen < 0) | ||
246 | return thislen; | ||
247 | else | ||
248 | pos += thislen; | ||
249 | |||
250 | thislen = __int8_t_decode_array(buf, offset + pos, maxlen - pos, | ||
251 | &(p[element].nsparams), 1); | ||
252 | if (thislen < 0) | ||
253 | return thislen; | ||
254 | else | ||
255 | pos += thislen; | ||
256 | |||
257 | p[element].sparams = | ||
258 | (char **)lcm_malloc(sizeof(char *) * p[element].nsparams); | ||
259 | thislen = | ||
260 | __string_decode_array(buf, offset + pos, maxlen - pos, | ||
261 | p[element].sparams, p[element].nsparams); | ||
262 | if (thislen < 0) | ||
263 | return thislen; | ||
264 | else | ||
265 | pos += thislen; | ||
266 | |||
267 | thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, | ||
268 | &(p[element].nbparams), 1); | ||
269 | if (thislen < 0) | ||
270 | return thislen; | ||
271 | else | ||
272 | pos += thislen; | ||
273 | |||
274 | p[element].bparams = | ||
275 | (uint8_t *)lcm_malloc(sizeof(uint8_t) * p[element].nbparams); | ||
276 | thislen = __byte_decode_array(buf, offset + pos, maxlen - pos, | ||
277 | p[element].bparams, p[element].nbparams); | ||
278 | if (thislen < 0) | ||
279 | return thislen; | ||
280 | else | ||
281 | pos += thislen; | ||
282 | } | ||
283 | return pos; | ||
284 | } | ||
285 | |||
286 | int __robot_control_t_decode_array_cleanup(robot_control_t *p, int elements) { | ||
287 | int element; | ||
288 | for (element = 0; element < elements; element++) { | ||
289 | |||
290 | __int64_t_decode_array_cleanup(&(p[element].utime), 1); | ||
291 | |||
292 | __int8_t_decode_array_cleanup(&(p[element].commandid), 1); | ||
293 | |||
294 | __int8_t_decode_array_cleanup(&(p[element].robotid), 1); | ||
295 | |||
296 | __int8_t_decode_array_cleanup(&(p[element].ndparams), 1); | ||
297 | |||
298 | __double_decode_array_cleanup(p[element].dparams, p[element].ndparams); | ||
299 | if (p[element].dparams) | ||
300 | free(p[element].dparams); | ||
301 | |||
302 | __int8_t_decode_array_cleanup(&(p[element].niparams), 1); | ||
303 | |||
304 | __int8_t_decode_array_cleanup(p[element].iparams, p[element].niparams); | ||
305 | if (p[element].iparams) | ||
306 | free(p[element].iparams); | ||
307 | |||
308 | __int8_t_decode_array_cleanup(&(p[element].nsparams), 1); | ||
309 | |||
310 | __string_decode_array_cleanup(p[element].sparams, p[element].nsparams); | ||
311 | if (p[element].sparams) | ||
312 | free(p[element].sparams); | ||
313 | |||
314 | __int64_t_decode_array_cleanup(&(p[element].nbparams), 1); | ||
315 | |||
316 | __byte_decode_array_cleanup(p[element].bparams, p[element].nbparams); | ||
317 | if (p[element].bparams) | ||
318 | free(p[element].bparams); | ||
319 | } | ||
320 | return 0; | ||
321 | } | ||
322 | |||
323 | int robot_control_t_decode(const void *buf, int offset, int maxlen, | ||
324 | robot_control_t *p) { | ||
325 | int pos = 0, thislen; | ||
326 | int64_t hash = __robot_control_t_get_hash(); | ||
327 | |||
328 | int64_t this_hash; | ||
329 | thislen = | ||
330 | __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1); | ||
331 | if (thislen < 0) | ||
332 | return thislen; | ||
333 | else | ||
334 | pos += thislen; | ||
335 | if (this_hash != hash) | ||
336 | return -1; | ||
337 | |||
338 | thislen = | ||
339 | __robot_control_t_decode_array(buf, offset + pos, maxlen - pos, p, 1); | ||
340 | if (thislen < 0) | ||
341 | return thislen; | ||
342 | else | ||
343 | pos += thislen; | ||
344 | |||
345 | return pos; | ||
346 | } | ||
347 | |||
348 | int robot_control_t_decode_cleanup(robot_control_t *p) { | ||
349 | return __robot_control_t_decode_array_cleanup(p, 1); | ||
350 | } | ||
351 | |||
352 | int __robot_control_t_clone_array(const robot_control_t *p, robot_control_t *q, | ||
353 | int elements) { | ||
354 | int element; | ||
355 | for (element = 0; element < elements; element++) { | ||
356 | |||
357 | __int64_t_clone_array(&(p[element].utime), &(q[element].utime), 1); | ||
358 | |||
359 | __int8_t_clone_array(&(p[element].commandid), &(q[element].commandid), | ||
360 | 1); | ||
361 | |||
362 | __int8_t_clone_array(&(p[element].robotid), &(q[element].robotid), 1); | ||
363 | |||
364 | __int8_t_clone_array(&(p[element].ndparams), &(q[element].ndparams), 1); | ||
365 | |||
366 | q[element].dparams = | ||
367 | (double *)lcm_malloc(sizeof(double) * q[element].ndparams); | ||
368 | __double_clone_array(p[element].dparams, q[element].dparams, | ||
369 | p[element].ndparams); | ||
370 | |||
371 | __int8_t_clone_array(&(p[element].niparams), &(q[element].niparams), 1); | ||
372 | |||
373 | q[element].iparams = | ||
374 | (int8_t *)lcm_malloc(sizeof(int8_t) * q[element].niparams); | ||
375 | __int8_t_clone_array(p[element].iparams, q[element].iparams, | ||
376 | p[element].niparams); | ||
377 | |||
378 | __int8_t_clone_array(&(p[element].nsparams), &(q[element].nsparams), 1); | ||
379 | |||
380 | q[element].sparams = | ||
381 | (char **)lcm_malloc(sizeof(char *) * q[element].nsparams); | ||
382 | __string_clone_array(p[element].sparams, q[element].sparams, | ||
383 | p[element].nsparams); | ||
384 | |||
385 | __int64_t_clone_array(&(p[element].nbparams), &(q[element].nbparams), | ||
386 | 1); | ||
387 | |||
388 | q[element].bparams = | ||
389 | (uint8_t *)lcm_malloc(sizeof(uint8_t) * q[element].nbparams); | ||
390 | __byte_clone_array(p[element].bparams, q[element].bparams, | ||
391 | p[element].nbparams); | ||
392 | } | ||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | robot_control_t *robot_control_t_copy(const robot_control_t *p) { | ||
397 | robot_control_t *q = (robot_control_t *)malloc(sizeof(robot_control_t)); | ||
398 | __robot_control_t_clone_array(p, q, 1); | ||
399 | return q; | ||
400 | } | ||
401 | |||
402 | void robot_control_t_destroy(robot_control_t *p) { | ||
403 | __robot_control_t_decode_array_cleanup(p, 1); | ||
404 | free(p); | ||
405 | } | ||
406 | |||
407 | int robot_control_t_publish(lcm_t *lc, const char *channel, | ||
408 | const robot_control_t *p) { | ||
409 | int max_data_size = robot_control_t_encoded_size(p); | ||
410 | uint8_t *buf = (uint8_t *)malloc(max_data_size); | ||
411 | if (!buf) | ||
412 | return -1; | ||
413 | int data_size = robot_control_t_encode(buf, 0, max_data_size, p); | ||
414 | if (data_size < 0) { | ||
415 | free(buf); | ||
416 | return data_size; | ||
417 | } | ||
418 | int status = lcm_publish(lc, channel, buf, data_size); | ||
419 | free(buf); | ||
420 | return status; | ||
421 | } | ||
422 | |||
423 | struct _robot_control_t_subscription_t { | ||
424 | robot_control_t_handler_t user_handler; | ||
425 | void *userdata; | ||
426 | lcm_subscription_t *lc_h; | ||
427 | }; | ||
428 | static void robot_control_t_handler_stub(const lcm_recv_buf_t *rbuf, | ||
429 | const char *channel, void *userdata) { | ||
430 | int status; | ||
431 | robot_control_t p; | ||
432 | memset(&p, 0, sizeof(robot_control_t)); | ||
433 | status = robot_control_t_decode(rbuf->data, 0, rbuf->data_size, &p); | ||
434 | if (status < 0) { | ||
435 | fprintf(stderr, "error %d decoding robot_control_t!!!\n", status); | ||
436 | return; | ||
437 | } | ||
438 | |||
439 | robot_control_t_subscription_t *h = | ||
440 | (robot_control_t_subscription_t *)userdata; | ||
441 | h->user_handler(rbuf, channel, &p, h->userdata); | ||
442 | |||
443 | robot_control_t_decode_cleanup(&p); | ||
444 | } | ||
445 | |||
446 | robot_control_t_subscription_t * | ||
447 | robot_control_t_subscribe(lcm_t *lcm, const char *channel, | ||
448 | robot_control_t_handler_t f, void *userdata) { | ||
449 | robot_control_t_subscription_t *n = | ||
450 | (robot_control_t_subscription_t *)malloc( | ||
451 | sizeof(robot_control_t_subscription_t)); | ||
452 | n->user_handler = f; | ||
453 | n->userdata = userdata; | ||
454 | n->lc_h = lcm_subscribe(lcm, channel, robot_control_t_handler_stub, n); | ||
455 | if (n->lc_h == NULL) { | ||
456 | fprintf(stderr, "couldn't reg robot_control_t LCM handler!\n"); | ||
457 | free(n); | ||
458 | return NULL; | ||
459 | } | ||
460 | return n; | ||
461 | } | ||
462 | |||
463 | int robot_control_t_subscription_set_queue_capacity( | ||
464 | robot_control_t_subscription_t *subs, int num_messages) { | ||
465 | return lcm_subscription_set_queue_capacity(subs->lc_h, num_messages); | ||
466 | } | ||
467 | |||
468 | int robot_control_t_unsubscribe(lcm_t *lcm, | ||
469 | robot_control_t_subscription_t *hid) { | ||
470 | int status = lcm_unsubscribe(lcm, hid->lc_h); | ||
471 | if (0 != status) { | ||
472 | fprintf(stderr, "couldn't unsubscribe robot_control_t_handler %p!\n", | ||
473 | hid); | ||
474 | return -1; | ||
475 | } | ||
476 | free(hid); | ||
477 | return 0; | ||
478 | } | ||