gusimplewhiteboard
TeleoperationControlVR.hpp
Go to the documentation of this file.
1/*
2 * file TeleoperationControlVR.hpp
3 *
4 * This file was generated by classgenerator from teleoperationControlVR.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Carl Lusty. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Carl Lusty.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef guWhiteboard_TeleoperationControlVR_h
61#define guWhiteboard_TeleoperationControlVR_h
62
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
64#include <cstdlib>
65#include <string.h>
66#include <sstream>
67#endif
68
69#include <gu_util.h>
71#include <float.h>
72
73#undef guWhiteboard_TeleoperationControlVR_DEFINED
74#define guWhiteboard_TeleoperationControlVR_DEFINED
75
76#undef TeleoperationControlVR_DEFINED
77#define TeleoperationControlVR_DEFINED
78
79namespace guWhiteboard {
80
85
86 private:
87
91 void init(uint8_t t_ip = 0, int32_t t_action = 0, float t_HeadYaw = 0, float t_HeadPitch = 0, int32_t t_stance = 0, int32_t t_streamType = 0, int32_t t_selectedCamera = 0, std::string t_sayString = "", int32_t t_walk = 0, int32_t t_turn = 0, int32_t t_timestamp = 0) {
92 set_ip(t_ip);
93 set_action(t_action);
94 set_HeadYaw(t_HeadYaw);
95 set_HeadPitch(t_HeadPitch);
96 set_stance(t_stance);
97 set_streamType(t_streamType);
98 set_selectedCamera(t_selectedCamera);
99 gu_strlcpy(const_cast<char *>(this->sayString()), t_sayString.c_str(), 30);
100 set_walk(t_walk);
101 set_turn(t_turn);
102 set_timestamp(t_timestamp);
103 }
104
105 public:
106
110 TeleoperationControlVR(uint8_t t_ip = 0, int32_t t_action = 0, float t_HeadYaw = 0, float t_HeadPitch = 0, int32_t t_stance = 0, int32_t t_streamType = 0, int32_t t_selectedCamera = 0, std::string t_sayString = "", int32_t t_walk = 0, int32_t t_turn = 0, int32_t t_timestamp = 0) {
111 this->init(t_ip, t_action, t_HeadYaw, t_HeadPitch, t_stance, t_streamType, t_selectedCamera, t_sayString, t_walk, t_turn, t_timestamp);
112 }
113
118 this->init(t_other.ip(), t_other.action(), t_other.HeadYaw(), t_other.HeadPitch(), t_other.stance(), t_other.streamType(), t_other.selectedCamera(), t_other.sayString(), t_other.walk(), t_other.turn(), t_other.timestamp());
119 }
120
125 this->init(t_other.ip, t_other.action, t_other.HeadYaw, t_other.HeadPitch, t_other.stance, t_other.streamType, t_other.selectedCamera, t_other.sayString, t_other.walk, t_other.turn, t_other.timestamp);
126 }
127
132 this->init(t_other.ip(), t_other.action(), t_other.HeadYaw(), t_other.HeadPitch(), t_other.stance(), t_other.streamType(), t_other.selectedCamera(), t_other.sayString(), t_other.walk(), t_other.turn(), t_other.timestamp());
133 return *this;
134 }
135
140 this->init(t_other.ip, t_other.action, t_other.HeadYaw, t_other.HeadPitch, t_other.stance, t_other.streamType, t_other.selectedCamera, t_other.sayString, t_other.walk, t_other.turn, t_other.timestamp);
141 return *this;
142 }
143
144 bool operator ==(const TeleoperationControlVR &t_other) const
145 {
146 return ip() == t_other.ip()
147 && action() == t_other.action()
148 && fabsf(HeadYaw() - t_other.HeadYaw()) < FLT_EPSILON
149 && fabsf(HeadPitch() - t_other.HeadPitch()) < FLT_EPSILON
150 && stance() == t_other.stance()
151 && streamType() == t_other.streamType()
152 && selectedCamera() == t_other.selectedCamera()
153 && 0 == strncmp(sayString(), t_other.sayString(), 30)
154 && walk() == t_other.walk()
155 && turn() == t_other.turn()
156 && timestamp() == t_other.timestamp();
157 }
158
159 bool operator !=(const TeleoperationControlVR &t_other) const
160 {
161 return !(*this == t_other);
162 }
163
164 bool operator ==(const wb_teleoperation_control_v_r &t_other) const
165 {
166 return *this == TeleoperationControlVR(t_other);
167 }
168
169 bool operator !=(const wb_teleoperation_control_v_r &t_other) const
170 {
171 return !(*this == t_other);
172 }
173
174 uint8_t & ip()
175 {
177 }
178
179 const uint8_t & ip() const
180 {
182 }
183
184 void set_ip(const uint8_t &t_newValue)
185 {
187 }
188
189 int32_t & action()
190 {
192 }
193
194 const int32_t & action() const
195 {
197 }
198
199 void set_action(const int32_t &t_newValue)
200 {
202 }
203
204 float & HeadYaw()
205 {
207 }
208
209 const float & HeadYaw() const
210 {
212 }
213
214 void set_HeadYaw(const float &t_newValue)
215 {
217 }
218
219 float & HeadPitch()
220 {
222 }
223
224 const float & HeadPitch() const
225 {
227 }
228
229 void set_HeadPitch(const float &t_newValue)
230 {
232 }
233
234 int32_t & stance()
235 {
237 }
238
239 const int32_t & stance() const
240 {
242 }
243
244 void set_stance(const int32_t &t_newValue)
245 {
247 }
248
249 int32_t & streamType()
250 {
252 }
253
254 const int32_t & streamType() const
255 {
257 }
258
259 void set_streamType(const int32_t &t_newValue)
260 {
262 }
263
264 int32_t & selectedCamera()
265 {
267 }
268
269 const int32_t & selectedCamera() const
270 {
272 }
273
274 void set_selectedCamera(const int32_t &t_newValue)
275 {
277 }
278
279 const char * sayString() const
280 {
282 }
283
284 size_t sayString_size() const
285 {
286 return 30;
287 }
288
289 char & sayString(int t_i)
290 {
292 }
293
294 const char & sayString(int t_i) const
295 {
297 }
298
299 void set_sayString(const char *t_newValue)
300 {
301 strncpy(wb_teleoperation_control_v_r::sayString, t_newValue, 30);
302 }
303
304 int32_t & walk()
305 {
307 }
308
309 const int32_t & walk() const
310 {
312 }
313
314 void set_walk(const int32_t &t_newValue)
315 {
317 }
318
319 int32_t & turn()
320 {
322 }
323
324 const int32_t & turn() const
325 {
327 }
328
329 void set_turn(const int32_t &t_newValue)
330 {
332 }
333
334 int32_t & timestamp()
335 {
337 }
338
339 const int32_t & timestamp() const
340 {
342 }
343
344 void set_timestamp(const int32_t &t_newValue)
345 {
347 }
348
349#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
353 TeleoperationControlVR(const std::string &t_str) {
354 this->init();
355 this->from_string(t_str);
356 }
357
358 std::string description() {
359#ifdef USE_WB_TELEOPERATION_CONTROL_V_R_C_CONVERSION
361 wb_teleoperation_control_v_r_description(this, buffer, sizeof(buffer));
362 std::string descr = buffer;
363 return descr;
364#else
365 std::ostringstream ss;
366 ss << "ip=" << static_cast<unsigned>(this->ip());
367 ss << ", ";
368 ss << "action=" << static_cast<signed>(this->action());
369 ss << ", ";
370 ss << "HeadYaw=" << this->HeadYaw();
371 ss << ", ";
372 ss << "HeadPitch=" << this->HeadPitch();
373 ss << ", ";
374 ss << "stance=" << static_cast<signed>(this->stance());
375 ss << ", ";
376 ss << "streamType=" << static_cast<signed>(this->streamType());
377 ss << ", ";
378 ss << "selectedCamera=" << static_cast<signed>(this->selectedCamera());
379 ss << ", ";
380 if (0 == strncmp("", this->sayString(), 1)) {
381 ss << "sayString=" << "";
382 } else {
383 ss << "sayString=" << this->sayString();
384 }
385 ss << ", ";
386 ss << "walk=" << static_cast<signed>(this->walk());
387 ss << ", ";
388 ss << "turn=" << static_cast<signed>(this->turn());
389 ss << ", ";
390 ss << "timestamp=" << static_cast<signed>(this->timestamp());
391 return ss.str();
392#endif
393 }
394
395 std::string to_string() {
396#ifdef USE_WB_TELEOPERATION_CONTROL_V_R_C_CONVERSION
398 wb_teleoperation_control_v_r_to_string(this, buffer, sizeof(buffer));
399 std::string toString = buffer;
400 return toString;
401#else
402 std::ostringstream ss;
403 ss << static_cast<unsigned>(this->ip());
404 ss << ", ";
405 ss << static_cast<signed>(this->action());
406 ss << ", ";
407 ss << this->HeadYaw();
408 ss << ", ";
409 ss << this->HeadPitch();
410 ss << ", ";
411 ss << static_cast<signed>(this->stance());
412 ss << ", ";
413 ss << static_cast<signed>(this->streamType());
414 ss << ", ";
415 ss << static_cast<signed>(this->selectedCamera());
416 ss << ", ";
417 if (0 == strncmp("", this->sayString(), 1)) {
418 ss << "";
419 } else {
420 ss << this->sayString();
421 }
422 ss << ", ";
423 ss << static_cast<signed>(this->walk());
424 ss << ", ";
425 ss << static_cast<signed>(this->turn());
426 ss << ", ";
427 ss << static_cast<signed>(this->timestamp());
428 return ss.str();
429#endif
430 }
431
432#ifdef USE_WB_TELEOPERATION_CONTROL_V_R_C_CONVERSION
433 void from_string(const std::string &t_str) {
434 wb_teleoperation_control_v_r_from_string(this, t_str.c_str());
435#else
436 void from_string(const std::string &t_str) {
437 char * str_cstr = const_cast<char *>(t_str.c_str());
438 size_t temp_length = strlen(str_cstr);
439 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
440 if (length < 1 || length > TELEOPERATIONCONTROLVR_DESC_BUFFER_SIZE) {
441 return;
442 }
443 char var_str_buffer[TELEOPERATIONCONTROLVR_DESC_BUFFER_SIZE + 1];
444 char* var_str = &var_str_buffer[0];
445 char key_buffer[15];
446 char* key = &key_buffer[0];
447 int bracecount = 0;
448 int startVar = 0;
449 int index = 0;
450 int startKey = 0;
451 int endKey = -1;
452 int varIndex = 0;
453 if (index == 0 && str_cstr[0] == '{') {
454 index = 1;
455 }
456 startVar = index;
457 startKey = startVar;
458 do {
459 for (int i = index; i < length; i++) {
460 index = i + 1;
461 if (bracecount == 0 && str_cstr[i] == '=') {
462 endKey = i - 1;
463 startVar = index;
464 continue;
465 }
466 if (bracecount == 0 && isspace(str_cstr[i])) {
467 startVar = index;
468 if (endKey == -1) {
469 startKey = index;
470 }
471 continue;
472 }
473 if (bracecount == 0 && str_cstr[i] == ',') {
474 index = i - 1;
475 break;
476 }
477 if (str_cstr[i] == '{') {
478 bracecount++;
479 continue;
480 }
481 if (str_cstr[i] == '}') {
482 bracecount--;
483 if (bracecount < 0) {
484 index = i - 1;
485 break;
486 }
487 }
488 if (i == length - 1) {
489 index = i;
490 }
491 }
492 if (endKey >= startKey && endKey - startKey < length) {
493 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
494 key[(endKey - startKey) + 1] = 0;
495 } else {
496 key[0] = 0;
497 }
498 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
499 var_str[(index - startVar) + 1] = 0;
500 bracecount = 0;
501 index += 2;
502 startVar = index;
503 startKey = startVar;
504 endKey = -1;
505 if (strlen(key) > 0) {
506 if (0 == strcmp("ip", key)) {
507 varIndex = 0;
508 } else if (0 == strcmp("action", key)) {
509 varIndex = 1;
510 } else if (0 == strcmp("HeadYaw", key)) {
511 varIndex = 2;
512 } else if (0 == strcmp("HeadPitch", key)) {
513 varIndex = 3;
514 } else if (0 == strcmp("stance", key)) {
515 varIndex = 4;
516 } else if (0 == strcmp("streamType", key)) {
517 varIndex = 5;
518 } else if (0 == strcmp("selectedCamera", key)) {
519 varIndex = 6;
520 } else if (0 == strcmp("sayString", key)) {
521 varIndex = 7;
522 } else if (0 == strcmp("walk", key)) {
523 varIndex = 8;
524 } else if (0 == strcmp("turn", key)) {
525 varIndex = 9;
526 } else if (0 == strcmp("timestamp", key)) {
527 varIndex = 10;
528 } else {
529 varIndex = -1;
530 }
531 }
532 switch (varIndex) {
533 case -1: { break; }
534 case 0:
535 {
536 this->set_ip(static_cast<uint8_t>(atoi(var_str)));
537 break;
538 }
539 case 1:
540 {
541 this->set_action(static_cast<int32_t>(atoi(var_str)));
542 break;
543 }
544 case 2:
545 {
546 this->set_HeadYaw(static_cast<float>(atof(var_str)));
547 break;
548 }
549 case 3:
550 {
551 this->set_HeadPitch(static_cast<float>(atof(var_str)));
552 break;
553 }
554 case 4:
555 {
556 this->set_stance(static_cast<int32_t>(atoi(var_str)));
557 break;
558 }
559 case 5:
560 {
561 this->set_streamType(static_cast<int32_t>(atoi(var_str)));
562 break;
563 }
564 case 6:
565 {
566 this->set_selectedCamera(static_cast<int32_t>(atoi(var_str)));
567 break;
568 }
569 case 7:
570 {
571 strncpy(wb_teleoperation_control_v_r::sayString, var_str, 30);
572 break;
573 }
574 case 8:
575 {
576 this->set_walk(static_cast<int32_t>(atoi(var_str)));
577 break;
578 }
579 case 9:
580 {
581 this->set_turn(static_cast<int32_t>(atoi(var_str)));
582 break;
583 }
584 case 10:
585 {
586 this->set_timestamp(static_cast<int32_t>(atoi(var_str)));
587 break;
588 }
589 }
590 if (varIndex >= 0) {
591 varIndex++;
592 }
593 } while(index < length);
594#endif
595 }
596#endif
597 };
598
599}
600
601#endif
Provides a C++ wrapper around wb_teleoperation_control_v_r.
TeleoperationControlVR(uint8_t t_ip=0, int32_t t_action=0, float t_HeadYaw=0, float t_HeadPitch=0, int32_t t_stance=0, int32_t t_streamType=0, int32_t t_selectedCamera=0, std::string t_sayString="", int32_t t_walk=0, int32_t t_turn=0, int32_t t_timestamp=0)
Create a new TeleoperationControlVR.
TeleoperationControlVR(const std::string &t_str)
String Constructor.
bool operator!=(const TeleoperationControlVR &t_other) const
TeleoperationControlVR(const TeleoperationControlVR &t_other)
Copy Constructor.
void set_action(const int32_t &t_newValue)
void set_HeadYaw(const float &t_newValue)
void set_streamType(const int32_t &t_newValue)
TeleoperationControlVR & operator=(const TeleoperationControlVR &t_other)
Copy Assignment Operator.
void set_selectedCamera(const int32_t &t_newValue)
void set_turn(const int32_t &t_newValue)
void set_HeadPitch(const float &t_newValue)
void set_stance(const int32_t &t_newValue)
void set_sayString(const char *t_newValue)
void set_walk(const int32_t &t_newValue)
void set_ip(const uint8_t &t_newValue)
TeleoperationControlVR(const struct wb_teleoperation_control_v_r &t_other)
Copy Constructor.
void set_timestamp(const int32_t &t_newValue)
bool operator==(const TeleoperationControlVR &t_other) const
void from_string(const std::string &t_str)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
int32_t action
Use guWhiteboard::Motions::action enum values!
int32_t stance
guWhiteboard::Motions::stance
char sayString[30]
String passed to Say_t.
int32_t timestamp
Timestamp for task distinguishing.
int32_t streamType
Use enum StreamingType (Vision_Control.h)
uint8_t ip
Last octet of IP address.
struct wb_teleoperation_control_v_r * wb_teleoperation_control_v_r_from_string(struct wb_teleoperation_control_v_r *self, const char *str)
Convert from a string.
const char * wb_teleoperation_control_v_r_description(const struct wb_teleoperation_control_v_r *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_teleoperation_control_v_r_to_string(const struct wb_teleoperation_control_v_r *self, char *toString, size_t bufferSize)
Convert to a string.
#define TELEOPERATIONCONTROLVR_TO_STRING_BUFFER_SIZE
#define TELEOPERATIONCONTROLVR_DESC_BUFFER_SIZE