gusimplewhiteboard
SENSORSTorsoJointSensors.hpp
Go to the documentation of this file.
1/*
2 * file SENSORSTorsoJointSensors.hpp
3 *
4 * This file was generated by classgenerator from SENSORS_TorsoJointSensors.txt.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Carl Lusty & Dimitri Joukoff. 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 & Dimitri Joukoff.
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_SENSORSTorsoJointSensors_h
61#define guWhiteboard_SENSORSTorsoJointSensors_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_SENSORSTorsoJointSensors_DEFINED
74#define guWhiteboard_SENSORSTorsoJointSensors_DEFINED
75
76#undef SENSORSTorsoJointSensors_DEFINED
77#define SENSORSTorsoJointSensors_DEFINED
78
79namespace guWhiteboard {
80
85
86 private:
87
91 void init(float t_HeadYaw = 0.0f, float t_HeadPitch = 0.0f, float t_LShoulderPitch = 0.0f, float t_LShoulderRoll = 0.0f, float t_LElbowYaw = 0.0f, float t_LElbowRoll = 0.0f, float t_RShoulderPitch = 0.0f, float t_RShoulderRoll = 0.0f, float t_RElbowYaw = 0.0f, float t_RElbowRoll = 0.0f, float t_LWristYaw = 0.0f, float t_RWristYaw = 0.0f) {
92 set_HeadYaw(t_HeadYaw);
93 set_HeadPitch(t_HeadPitch);
94 set_LShoulderPitch(t_LShoulderPitch);
95 set_LShoulderRoll(t_LShoulderRoll);
96 set_LElbowYaw(t_LElbowYaw);
97 set_LElbowRoll(t_LElbowRoll);
98 set_RShoulderPitch(t_RShoulderPitch);
99 set_RShoulderRoll(t_RShoulderRoll);
100 set_RElbowYaw(t_RElbowYaw);
101 set_RElbowRoll(t_RElbowRoll);
102 set_LWristYaw(t_LWristYaw);
103 set_RWristYaw(t_RWristYaw);
104 }
105
106 public:
107
111 SENSORSTorsoJointSensors(float t_HeadYaw = 0.0f, float t_HeadPitch = 0.0f, float t_LShoulderPitch = 0.0f, float t_LShoulderRoll = 0.0f, float t_LElbowYaw = 0.0f, float t_LElbowRoll = 0.0f, float t_RShoulderPitch = 0.0f, float t_RShoulderRoll = 0.0f, float t_RElbowYaw = 0.0f, float t_RElbowRoll = 0.0f, float t_LWristYaw = 0.0f, float t_RWristYaw = 0.0f) {
112 this->init(t_HeadYaw, t_HeadPitch, t_LShoulderPitch, t_LShoulderRoll, t_LElbowYaw, t_LElbowRoll, t_RShoulderPitch, t_RShoulderRoll, t_RElbowYaw, t_RElbowRoll, t_LWristYaw, t_RWristYaw);
113 }
114
119 this->init(t_other.HeadYaw(), t_other.HeadPitch(), t_other.LShoulderPitch(), t_other.LShoulderRoll(), t_other.LElbowYaw(), t_other.LElbowRoll(), t_other.RShoulderPitch(), t_other.RShoulderRoll(), t_other.RElbowYaw(), t_other.RElbowRoll(), t_other.LWristYaw(), t_other.RWristYaw());
120 }
121
126 this->init(t_other.HeadYaw, t_other.HeadPitch, t_other.LShoulderPitch, t_other.LShoulderRoll, t_other.LElbowYaw, t_other.LElbowRoll, t_other.RShoulderPitch, t_other.RShoulderRoll, t_other.RElbowYaw, t_other.RElbowRoll, t_other.LWristYaw, t_other.RWristYaw);
127 }
128
133 this->init(t_other.HeadYaw(), t_other.HeadPitch(), t_other.LShoulderPitch(), t_other.LShoulderRoll(), t_other.LElbowYaw(), t_other.LElbowRoll(), t_other.RShoulderPitch(), t_other.RShoulderRoll(), t_other.RElbowYaw(), t_other.RElbowRoll(), t_other.LWristYaw(), t_other.RWristYaw());
134 return *this;
135 }
136
141 this->init(t_other.HeadYaw, t_other.HeadPitch, t_other.LShoulderPitch, t_other.LShoulderRoll, t_other.LElbowYaw, t_other.LElbowRoll, t_other.RShoulderPitch, t_other.RShoulderRoll, t_other.RElbowYaw, t_other.RElbowRoll, t_other.LWristYaw, t_other.RWristYaw);
142 return *this;
143 }
144
145 bool operator ==(const SENSORSTorsoJointSensors &t_other) const
146 {
147 return fabsf(HeadYaw() - t_other.HeadYaw()) < FLT_EPSILON
148 && fabsf(HeadPitch() - t_other.HeadPitch()) < FLT_EPSILON
149 && fabsf(LShoulderPitch() - t_other.LShoulderPitch()) < FLT_EPSILON
150 && fabsf(LShoulderRoll() - t_other.LShoulderRoll()) < FLT_EPSILON
151 && fabsf(LElbowYaw() - t_other.LElbowYaw()) < FLT_EPSILON
152 && fabsf(LElbowRoll() - t_other.LElbowRoll()) < FLT_EPSILON
153 && fabsf(RShoulderPitch() - t_other.RShoulderPitch()) < FLT_EPSILON
154 && fabsf(RShoulderRoll() - t_other.RShoulderRoll()) < FLT_EPSILON
155 && fabsf(RElbowYaw() - t_other.RElbowYaw()) < FLT_EPSILON
156 && fabsf(RElbowRoll() - t_other.RElbowRoll()) < FLT_EPSILON
157 && fabsf(LWristYaw() - t_other.LWristYaw()) < FLT_EPSILON
158 && fabsf(RWristYaw() - t_other.RWristYaw()) < FLT_EPSILON;
159 }
160
161 bool operator !=(const SENSORSTorsoJointSensors &t_other) const
162 {
163 return !(*this == t_other);
164 }
165
166 bool operator ==(const wb_sensors_torsojointsensors &t_other) const
167 {
168 return *this == SENSORSTorsoJointSensors(t_other);
169 }
170
171 bool operator !=(const wb_sensors_torsojointsensors &t_other) const
172 {
173 return !(*this == t_other);
174 }
175
176 float & HeadYaw()
177 {
179 }
180
181 const float & HeadYaw() const
182 {
184 }
185
186 void set_HeadYaw(const float &t_newValue)
187 {
189 }
190
191 float & HeadPitch()
192 {
194 }
195
196 const float & HeadPitch() const
197 {
199 }
200
201 void set_HeadPitch(const float &t_newValue)
202 {
204 }
205
207 {
209 }
210
211 const float & LShoulderPitch() const
212 {
214 }
215
216 void set_LShoulderPitch(const float &t_newValue)
217 {
219 }
220
222 {
224 }
225
226 const float & LShoulderRoll() const
227 {
229 }
230
231 void set_LShoulderRoll(const float &t_newValue)
232 {
234 }
235
236 float & LElbowYaw()
237 {
239 }
240
241 const float & LElbowYaw() const
242 {
244 }
245
246 void set_LElbowYaw(const float &t_newValue)
247 {
249 }
250
251 float & LElbowRoll()
252 {
254 }
255
256 const float & LElbowRoll() const
257 {
259 }
260
261 void set_LElbowRoll(const float &t_newValue)
262 {
264 }
265
267 {
269 }
270
271 const float & RShoulderPitch() const
272 {
274 }
275
276 void set_RShoulderPitch(const float &t_newValue)
277 {
279 }
280
282 {
284 }
285
286 const float & RShoulderRoll() const
287 {
289 }
290
291 void set_RShoulderRoll(const float &t_newValue)
292 {
294 }
295
296 float & RElbowYaw()
297 {
299 }
300
301 const float & RElbowYaw() const
302 {
304 }
305
306 void set_RElbowYaw(const float &t_newValue)
307 {
309 }
310
311 float & RElbowRoll()
312 {
314 }
315
316 const float & RElbowRoll() const
317 {
319 }
320
321 void set_RElbowRoll(const float &t_newValue)
322 {
324 }
325
326 float & LWristYaw()
327 {
329 }
330
331 const float & LWristYaw() const
332 {
334 }
335
336 void set_LWristYaw(const float &t_newValue)
337 {
339 }
340
341 float & RWristYaw()
342 {
344 }
345
346 const float & RWristYaw() const
347 {
349 }
350
351 void set_RWristYaw(const float &t_newValue)
352 {
354 }
355
356#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
360 SENSORSTorsoJointSensors(const std::string &t_str) {
361 this->init();
362 this->from_string(t_str);
363 }
364
365 std::string description() {
366#ifdef USE_WB_SENSORS_TORSOJOINTSENSORS_C_CONVERSION
368 wb_sensors_torsojointsensors_description(this, buffer, sizeof(buffer));
369 std::string descr = buffer;
370 return descr;
371#else
372 std::ostringstream ss;
373 ss << "HeadYaw=" << this->HeadYaw();
374 ss << ", ";
375 ss << "HeadPitch=" << this->HeadPitch();
376 ss << ", ";
377 ss << "LShoulderPitch=" << this->LShoulderPitch();
378 ss << ", ";
379 ss << "LShoulderRoll=" << this->LShoulderRoll();
380 ss << ", ";
381 ss << "LElbowYaw=" << this->LElbowYaw();
382 ss << ", ";
383 ss << "LElbowRoll=" << this->LElbowRoll();
384 ss << ", ";
385 ss << "RShoulderPitch=" << this->RShoulderPitch();
386 ss << ", ";
387 ss << "RShoulderRoll=" << this->RShoulderRoll();
388 ss << ", ";
389 ss << "RElbowYaw=" << this->RElbowYaw();
390 ss << ", ";
391 ss << "RElbowRoll=" << this->RElbowRoll();
392 ss << ", ";
393 ss << "LWristYaw=" << this->LWristYaw();
394 ss << ", ";
395 ss << "RWristYaw=" << this->RWristYaw();
396 return ss.str();
397#endif
398 }
399
400 std::string to_string() {
401#ifdef USE_WB_SENSORS_TORSOJOINTSENSORS_C_CONVERSION
403 wb_sensors_torsojointsensors_to_string(this, buffer, sizeof(buffer));
404 std::string toString = buffer;
405 return toString;
406#else
407 std::ostringstream ss;
408 ss << this->HeadYaw();
409 ss << ", ";
410 ss << this->HeadPitch();
411 ss << ", ";
412 ss << this->LShoulderPitch();
413 ss << ", ";
414 ss << this->LShoulderRoll();
415 ss << ", ";
416 ss << this->LElbowYaw();
417 ss << ", ";
418 ss << this->LElbowRoll();
419 ss << ", ";
420 ss << this->RShoulderPitch();
421 ss << ", ";
422 ss << this->RShoulderRoll();
423 ss << ", ";
424 ss << this->RElbowYaw();
425 ss << ", ";
426 ss << this->RElbowRoll();
427 ss << ", ";
428 ss << this->LWristYaw();
429 ss << ", ";
430 ss << this->RWristYaw();
431 return ss.str();
432#endif
433 }
434
435#ifdef USE_WB_SENSORS_TORSOJOINTSENSORS_C_CONVERSION
436 void from_string(const std::string &t_str) {
437 wb_sensors_torsojointsensors_from_string(this, t_str.c_str());
438#else
439 void from_string(const std::string &t_str) {
440 char * str_cstr = const_cast<char *>(t_str.c_str());
441 size_t temp_length = strlen(str_cstr);
442 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
443 if (length < 1 || length > SENSORS_TORSOJOINTSENSORS_DESC_BUFFER_SIZE) {
444 return;
445 }
446 char var_str_buffer[SENSORS_TORSOJOINTSENSORS_DESC_BUFFER_SIZE + 1];
447 char* var_str = &var_str_buffer[0];
448 char key_buffer[15];
449 char* key = &key_buffer[0];
450 int bracecount = 0;
451 int startVar = 0;
452 int index = 0;
453 int startKey = 0;
454 int endKey = -1;
455 int varIndex = 0;
456 if (index == 0 && str_cstr[0] == '{') {
457 index = 1;
458 }
459 startVar = index;
460 startKey = startVar;
461 do {
462 for (int i = index; i < length; i++) {
463 index = i + 1;
464 if (bracecount == 0 && str_cstr[i] == '=') {
465 endKey = i - 1;
466 startVar = index;
467 continue;
468 }
469 if (bracecount == 0 && isspace(str_cstr[i])) {
470 startVar = index;
471 if (endKey == -1) {
472 startKey = index;
473 }
474 continue;
475 }
476 if (bracecount == 0 && str_cstr[i] == ',') {
477 index = i - 1;
478 break;
479 }
480 if (str_cstr[i] == '{') {
481 bracecount++;
482 continue;
483 }
484 if (str_cstr[i] == '}') {
485 bracecount--;
486 if (bracecount < 0) {
487 index = i - 1;
488 break;
489 }
490 }
491 if (i == length - 1) {
492 index = i;
493 }
494 }
495 if (endKey >= startKey && endKey - startKey < length) {
496 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
497 key[(endKey - startKey) + 1] = 0;
498 } else {
499 key[0] = 0;
500 }
501 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
502 var_str[(index - startVar) + 1] = 0;
503 bracecount = 0;
504 index += 2;
505 startVar = index;
506 startKey = startVar;
507 endKey = -1;
508 if (strlen(key) > 0) {
509 if (0 == strcmp("HeadYaw", key)) {
510 varIndex = 0;
511 } else if (0 == strcmp("HeadPitch", key)) {
512 varIndex = 1;
513 } else if (0 == strcmp("LShoulderPitch", key)) {
514 varIndex = 2;
515 } else if (0 == strcmp("LShoulderRoll", key)) {
516 varIndex = 3;
517 } else if (0 == strcmp("LElbowYaw", key)) {
518 varIndex = 4;
519 } else if (0 == strcmp("LElbowRoll", key)) {
520 varIndex = 5;
521 } else if (0 == strcmp("RShoulderPitch", key)) {
522 varIndex = 6;
523 } else if (0 == strcmp("RShoulderRoll", key)) {
524 varIndex = 7;
525 } else if (0 == strcmp("RElbowYaw", key)) {
526 varIndex = 8;
527 } else if (0 == strcmp("RElbowRoll", key)) {
528 varIndex = 9;
529 } else if (0 == strcmp("LWristYaw", key)) {
530 varIndex = 10;
531 } else if (0 == strcmp("RWristYaw", key)) {
532 varIndex = 11;
533 } else {
534 varIndex = -1;
535 }
536 }
537 switch (varIndex) {
538 case -1: { break; }
539 case 0:
540 {
541 this->set_HeadYaw(static_cast<float>(atof(var_str)));
542 break;
543 }
544 case 1:
545 {
546 this->set_HeadPitch(static_cast<float>(atof(var_str)));
547 break;
548 }
549 case 2:
550 {
551 this->set_LShoulderPitch(static_cast<float>(atof(var_str)));
552 break;
553 }
554 case 3:
555 {
556 this->set_LShoulderRoll(static_cast<float>(atof(var_str)));
557 break;
558 }
559 case 4:
560 {
561 this->set_LElbowYaw(static_cast<float>(atof(var_str)));
562 break;
563 }
564 case 5:
565 {
566 this->set_LElbowRoll(static_cast<float>(atof(var_str)));
567 break;
568 }
569 case 6:
570 {
571 this->set_RShoulderPitch(static_cast<float>(atof(var_str)));
572 break;
573 }
574 case 7:
575 {
576 this->set_RShoulderRoll(static_cast<float>(atof(var_str)));
577 break;
578 }
579 case 8:
580 {
581 this->set_RElbowYaw(static_cast<float>(atof(var_str)));
582 break;
583 }
584 case 9:
585 {
586 this->set_RElbowRoll(static_cast<float>(atof(var_str)));
587 break;
588 }
589 case 10:
590 {
591 this->set_LWristYaw(static_cast<float>(atof(var_str)));
592 break;
593 }
594 case 11:
595 {
596 this->set_RWristYaw(static_cast<float>(atof(var_str)));
597 break;
598 }
599 }
600 if (varIndex >= 0) {
601 varIndex++;
602 }
603 } while(index < length);
604#endif
605 }
606#endif
607 };
608
609}
610
611#endif
Provides a C++ wrapper around wb_sensors_torsojointsensors.
SENSORSTorsoJointSensors(const struct wb_sensors_torsojointsensors &t_other)
Copy Constructor.
SENSORSTorsoJointSensors(const std::string &t_str)
String Constructor.
SENSORSTorsoJointSensors(const SENSORSTorsoJointSensors &t_other)
Copy Constructor.
bool operator==(const SENSORSTorsoJointSensors &t_other) const
void set_RShoulderPitch(const float &t_newValue)
bool operator!=(const SENSORSTorsoJointSensors &t_other) const
SENSORSTorsoJointSensors(float t_HeadYaw=0.0f, float t_HeadPitch=0.0f, float t_LShoulderPitch=0.0f, float t_LShoulderRoll=0.0f, float t_LElbowYaw=0.0f, float t_LElbowRoll=0.0f, float t_RShoulderPitch=0.0f, float t_RShoulderRoll=0.0f, float t_RElbowYaw=0.0f, float t_RElbowRoll=0.0f, float t_LWristYaw=0.0f, float t_RWristYaw=0.0f)
Create a new SENSORSTorsoJointSensors.
SENSORSTorsoJointSensors & operator=(const SENSORSTorsoJointSensors &t_other)
Copy Assignment Operator.
void set_LShoulderPitch(const float &t_newValue)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
float LElbowRoll
roll of the elbow joint (left) RAD
float RShoulderPitch
pitch of the shoulder joint (right) RAD
float LWristYaw
yaw of the wrist joint (left)
float LShoulderPitch
pitch of the shoulder joint (left) RAD
float RShoulderRoll
roll of the shoulder joint (right) RAD
float RElbowRoll
roll of the elbow joint (right) RAD
float LElbowYaw
yaw of the elbow joint (left) RAD
float RElbowYaw
yaw of the elbow joint (right) RAD
float RWristYaw
yaw of the wrist joint (right)
float LShoulderRoll
roll of the shoulder joint (left) RAD
struct wb_sensors_torsojointsensors * wb_sensors_torsojointsensors_from_string(struct wb_sensors_torsojointsensors *self, const char *str)
Convert from a string.
const char * wb_sensors_torsojointsensors_to_string(const struct wb_sensors_torsojointsensors *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_sensors_torsojointsensors_description(const struct wb_sensors_torsojointsensors *self, char *descString, size_t bufferSize)
Convert to a description string.
#define SENSORS_TORSOJOINTSENSORS_TO_STRING_BUFFER_SIZE
#define SENSORS_TORSOJOINTSENSORS_DESC_BUFFER_SIZE