gusimplewhiteboard
SENSORSLegJointSensors.hpp
Go to the documentation of this file.
1/*
2 * file SENSORSLegJointSensors.hpp
3 *
4 * This file was generated by classgenerator from SENSORS_LegJointSensors.txt.
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_SENSORSLegJointSensors_h
61#define guWhiteboard_SENSORSLegJointSensors_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_SENSORSLegJointSensors_DEFINED
74#define guWhiteboard_SENSORSLegJointSensors_DEFINED
75
76#undef SENSORSLegJointSensors_DEFINED
77#define SENSORSLegJointSensors_DEFINED
78
79namespace guWhiteboard {
80
85
86 private:
87
91 void init(float t_LKneePitch = 0.0f, float t_LAnklePitch = 0.0f, float t_LAnkleRoll = 0.0f, float t_RKneePitch = 0.0f, float t_RAnklePitch = 0.0f, float t_RAnkleRoll = 0.0f, float t_LHipYawPitch = 0.0f, float t_LHipRoll = 0.0f, float t_LHipPitch = 0.0f, float t_RHipYawPitch = 0.0f, float t_RHipRoll = 0.0f, float t_RHipPitch = 0.0f) {
92 set_LKneePitch(t_LKneePitch);
93 set_LAnklePitch(t_LAnklePitch);
94 set_LAnkleRoll(t_LAnkleRoll);
95 set_RKneePitch(t_RKneePitch);
96 set_RAnklePitch(t_RAnklePitch);
97 set_RAnkleRoll(t_RAnkleRoll);
98 set_LHipYawPitch(t_LHipYawPitch);
99 set_LHipRoll(t_LHipRoll);
100 set_LHipPitch(t_LHipPitch);
101 set_RHipYawPitch(t_RHipYawPitch);
102 set_RHipRoll(t_RHipRoll);
103 set_RHipPitch(t_RHipPitch);
104 }
105
106 public:
107
111 SENSORSLegJointSensors(float t_LKneePitch = 0.0f, float t_LAnklePitch = 0.0f, float t_LAnkleRoll = 0.0f, float t_RKneePitch = 0.0f, float t_RAnklePitch = 0.0f, float t_RAnkleRoll = 0.0f, float t_LHipYawPitch = 0.0f, float t_LHipRoll = 0.0f, float t_LHipPitch = 0.0f, float t_RHipYawPitch = 0.0f, float t_RHipRoll = 0.0f, float t_RHipPitch = 0.0f) {
112 this->init(t_LKneePitch, t_LAnklePitch, t_LAnkleRoll, t_RKneePitch, t_RAnklePitch, t_RAnkleRoll, t_LHipYawPitch, t_LHipRoll, t_LHipPitch, t_RHipYawPitch, t_RHipRoll, t_RHipPitch);
113 }
114
119 this->init(t_other.LKneePitch(), t_other.LAnklePitch(), t_other.LAnkleRoll(), t_other.RKneePitch(), t_other.RAnklePitch(), t_other.RAnkleRoll(), t_other.LHipYawPitch(), t_other.LHipRoll(), t_other.LHipPitch(), t_other.RHipYawPitch(), t_other.RHipRoll(), t_other.RHipPitch());
120 }
121
126 this->init(t_other.LKneePitch, t_other.LAnklePitch, t_other.LAnkleRoll, t_other.RKneePitch, t_other.RAnklePitch, t_other.RAnkleRoll, t_other.LHipYawPitch, t_other.LHipRoll, t_other.LHipPitch, t_other.RHipYawPitch, t_other.RHipRoll, t_other.RHipPitch);
127 }
128
133 this->init(t_other.LKneePitch(), t_other.LAnklePitch(), t_other.LAnkleRoll(), t_other.RKneePitch(), t_other.RAnklePitch(), t_other.RAnkleRoll(), t_other.LHipYawPitch(), t_other.LHipRoll(), t_other.LHipPitch(), t_other.RHipYawPitch(), t_other.RHipRoll(), t_other.RHipPitch());
134 return *this;
135 }
136
141 this->init(t_other.LKneePitch, t_other.LAnklePitch, t_other.LAnkleRoll, t_other.RKneePitch, t_other.RAnklePitch, t_other.RAnkleRoll, t_other.LHipYawPitch, t_other.LHipRoll, t_other.LHipPitch, t_other.RHipYawPitch, t_other.RHipRoll, t_other.RHipPitch);
142 return *this;
143 }
144
145 bool operator ==(const SENSORSLegJointSensors &t_other) const
146 {
147 return fabsf(LKneePitch() - t_other.LKneePitch()) < FLT_EPSILON
148 && fabsf(LAnklePitch() - t_other.LAnklePitch()) < FLT_EPSILON
149 && fabsf(LAnkleRoll() - t_other.LAnkleRoll()) < FLT_EPSILON
150 && fabsf(RKneePitch() - t_other.RKneePitch()) < FLT_EPSILON
151 && fabsf(RAnklePitch() - t_other.RAnklePitch()) < FLT_EPSILON
152 && fabsf(RAnkleRoll() - t_other.RAnkleRoll()) < FLT_EPSILON
153 && fabsf(LHipYawPitch() - t_other.LHipYawPitch()) < FLT_EPSILON
154 && fabsf(LHipRoll() - t_other.LHipRoll()) < FLT_EPSILON
155 && fabsf(LHipPitch() - t_other.LHipPitch()) < FLT_EPSILON
156 && fabsf(RHipYawPitch() - t_other.RHipYawPitch()) < FLT_EPSILON
157 && fabsf(RHipRoll() - t_other.RHipRoll()) < FLT_EPSILON
158 && fabsf(RHipPitch() - t_other.RHipPitch()) < FLT_EPSILON;
159 }
160
161 bool operator !=(const SENSORSLegJointSensors &t_other) const
162 {
163 return !(*this == t_other);
164 }
165
166 bool operator ==(const wb_sensors_legjointsensors &t_other) const
167 {
168 return *this == SENSORSLegJointSensors(t_other);
169 }
170
171 bool operator !=(const wb_sensors_legjointsensors &t_other) const
172 {
173 return !(*this == t_other);
174 }
175
176 float & LKneePitch()
177 {
179 }
180
181 const float & LKneePitch() const
182 {
184 }
185
186 void set_LKneePitch(const float &t_newValue)
187 {
189 }
190
191 float & LAnklePitch()
192 {
194 }
195
196 const float & LAnklePitch() const
197 {
199 }
200
201 void set_LAnklePitch(const float &t_newValue)
202 {
204 }
205
206 float & LAnkleRoll()
207 {
209 }
210
211 const float & LAnkleRoll() const
212 {
214 }
215
216 void set_LAnkleRoll(const float &t_newValue)
217 {
219 }
220
221 float & RKneePitch()
222 {
224 }
225
226 const float & RKneePitch() const
227 {
229 }
230
231 void set_RKneePitch(const float &t_newValue)
232 {
234 }
235
236 float & RAnklePitch()
237 {
239 }
240
241 const float & RAnklePitch() const
242 {
244 }
245
246 void set_RAnklePitch(const float &t_newValue)
247 {
249 }
250
251 float & RAnkleRoll()
252 {
254 }
255
256 const float & RAnkleRoll() const
257 {
259 }
260
261 void set_RAnkleRoll(const float &t_newValue)
262 {
264 }
265
266 float & LHipYawPitch()
267 {
269 }
270
271 const float & LHipYawPitch() const
272 {
274 }
275
276 void set_LHipYawPitch(const float &t_newValue)
277 {
279 }
280
281 float & LHipRoll()
282 {
284 }
285
286 const float & LHipRoll() const
287 {
289 }
290
291 void set_LHipRoll(const float &t_newValue)
292 {
294 }
295
296 float & LHipPitch()
297 {
299 }
300
301 const float & LHipPitch() const
302 {
304 }
305
306 void set_LHipPitch(const float &t_newValue)
307 {
309 }
310
311 float & RHipYawPitch()
312 {
314 }
315
316 const float & RHipYawPitch() const
317 {
319 }
320
321 void set_RHipYawPitch(const float &t_newValue)
322 {
324 }
325
326 float & RHipRoll()
327 {
329 }
330
331 const float & RHipRoll() const
332 {
334 }
335
336 void set_RHipRoll(const float &t_newValue)
337 {
339 }
340
341 float & RHipPitch()
342 {
344 }
345
346 const float & RHipPitch() const
347 {
349 }
350
351 void set_RHipPitch(const float &t_newValue)
352 {
354 }
355
356#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
360 SENSORSLegJointSensors(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_LEGJOINTSENSORS_C_CONVERSION
368 wb_sensors_legjointsensors_description(this, buffer, sizeof(buffer));
369 std::string descr = buffer;
370 return descr;
371#else
372 std::ostringstream ss;
373 ss << "LKneePitch=" << this->LKneePitch();
374 ss << ", ";
375 ss << "LAnklePitch=" << this->LAnklePitch();
376 ss << ", ";
377 ss << "LAnkleRoll=" << this->LAnkleRoll();
378 ss << ", ";
379 ss << "RKneePitch=" << this->RKneePitch();
380 ss << ", ";
381 ss << "RAnklePitch=" << this->RAnklePitch();
382 ss << ", ";
383 ss << "RAnkleRoll=" << this->RAnkleRoll();
384 ss << ", ";
385 ss << "LHipYawPitch=" << this->LHipYawPitch();
386 ss << ", ";
387 ss << "LHipRoll=" << this->LHipRoll();
388 ss << ", ";
389 ss << "LHipPitch=" << this->LHipPitch();
390 ss << ", ";
391 ss << "RHipYawPitch=" << this->RHipYawPitch();
392 ss << ", ";
393 ss << "RHipRoll=" << this->RHipRoll();
394 ss << ", ";
395 ss << "RHipPitch=" << this->RHipPitch();
396 return ss.str();
397#endif
398 }
399
400 std::string to_string() {
401#ifdef USE_WB_SENSORS_LEGJOINTSENSORS_C_CONVERSION
403 wb_sensors_legjointsensors_to_string(this, buffer, sizeof(buffer));
404 std::string toString = buffer;
405 return toString;
406#else
407 std::ostringstream ss;
408 ss << this->LKneePitch();
409 ss << ", ";
410 ss << this->LAnklePitch();
411 ss << ", ";
412 ss << this->LAnkleRoll();
413 ss << ", ";
414 ss << this->RKneePitch();
415 ss << ", ";
416 ss << this->RAnklePitch();
417 ss << ", ";
418 ss << this->RAnkleRoll();
419 ss << ", ";
420 ss << this->LHipYawPitch();
421 ss << ", ";
422 ss << this->LHipRoll();
423 ss << ", ";
424 ss << this->LHipPitch();
425 ss << ", ";
426 ss << this->RHipYawPitch();
427 ss << ", ";
428 ss << this->RHipRoll();
429 ss << ", ";
430 ss << this->RHipPitch();
431 return ss.str();
432#endif
433 }
434
435#ifdef USE_WB_SENSORS_LEGJOINTSENSORS_C_CONVERSION
436 void from_string(const std::string &t_str) {
437 wb_sensors_legjointsensors_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_LEGJOINTSENSORS_DESC_BUFFER_SIZE) {
444 return;
445 }
446 char var_str_buffer[SENSORS_LEGJOINTSENSORS_DESC_BUFFER_SIZE + 1];
447 char* var_str = &var_str_buffer[0];
448 char key_buffer[13];
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("LKneePitch", key)) {
510 varIndex = 0;
511 } else if (0 == strcmp("LAnklePitch", key)) {
512 varIndex = 1;
513 } else if (0 == strcmp("LAnkleRoll", key)) {
514 varIndex = 2;
515 } else if (0 == strcmp("RKneePitch", key)) {
516 varIndex = 3;
517 } else if (0 == strcmp("RAnklePitch", key)) {
518 varIndex = 4;
519 } else if (0 == strcmp("RAnkleRoll", key)) {
520 varIndex = 5;
521 } else if (0 == strcmp("LHipYawPitch", key)) {
522 varIndex = 6;
523 } else if (0 == strcmp("LHipRoll", key)) {
524 varIndex = 7;
525 } else if (0 == strcmp("LHipPitch", key)) {
526 varIndex = 8;
527 } else if (0 == strcmp("RHipYawPitch", key)) {
528 varIndex = 9;
529 } else if (0 == strcmp("RHipRoll", key)) {
530 varIndex = 10;
531 } else if (0 == strcmp("RHipPitch", 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_LKneePitch(static_cast<float>(atof(var_str)));
542 break;
543 }
544 case 1:
545 {
546 this->set_LAnklePitch(static_cast<float>(atof(var_str)));
547 break;
548 }
549 case 2:
550 {
551 this->set_LAnkleRoll(static_cast<float>(atof(var_str)));
552 break;
553 }
554 case 3:
555 {
556 this->set_RKneePitch(static_cast<float>(atof(var_str)));
557 break;
558 }
559 case 4:
560 {
561 this->set_RAnklePitch(static_cast<float>(atof(var_str)));
562 break;
563 }
564 case 5:
565 {
566 this->set_RAnkleRoll(static_cast<float>(atof(var_str)));
567 break;
568 }
569 case 6:
570 {
571 this->set_LHipYawPitch(static_cast<float>(atof(var_str)));
572 break;
573 }
574 case 7:
575 {
576 this->set_LHipRoll(static_cast<float>(atof(var_str)));
577 break;
578 }
579 case 8:
580 {
581 this->set_LHipPitch(static_cast<float>(atof(var_str)));
582 break;
583 }
584 case 9:
585 {
586 this->set_RHipYawPitch(static_cast<float>(atof(var_str)));
587 break;
588 }
589 case 10:
590 {
591 this->set_RHipRoll(static_cast<float>(atof(var_str)));
592 break;
593 }
594 case 11:
595 {
596 this->set_RHipPitch(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_legjointsensors.
void set_RHipRoll(const float &t_newValue)
void set_LHipPitch(const float &t_newValue)
void set_RHipPitch(const float &t_newValue)
SENSORSLegJointSensors(float t_LKneePitch=0.0f, float t_LAnklePitch=0.0f, float t_LAnkleRoll=0.0f, float t_RKneePitch=0.0f, float t_RAnklePitch=0.0f, float t_RAnkleRoll=0.0f, float t_LHipYawPitch=0.0f, float t_LHipRoll=0.0f, float t_LHipPitch=0.0f, float t_RHipYawPitch=0.0f, float t_RHipRoll=0.0f, float t_RHipPitch=0.0f)
Create a new SENSORSLegJointSensors.
SENSORSLegJointSensors(const SENSORSLegJointSensors &t_other)
Copy Constructor.
void set_RAnkleRoll(const float &t_newValue)
void set_LAnklePitch(const float &t_newValue)
void set_RAnklePitch(const float &t_newValue)
bool operator!=(const SENSORSLegJointSensors &t_other) const
void set_RHipYawPitch(const float &t_newValue)
void set_LHipRoll(const float &t_newValue)
void set_LKneePitch(const float &t_newValue)
SENSORSLegJointSensors(const struct wb_sensors_legjointsensors &t_other)
Copy Constructor.
SENSORSLegJointSensors(const std::string &t_str)
String Constructor.
void set_LHipYawPitch(const float &t_newValue)
void set_RKneePitch(const float &t_newValue)
void set_LAnkleRoll(const float &t_newValue)
SENSORSLegJointSensors & operator=(const SENSORSLegJointSensors &t_other)
Copy Assignment Operator.
bool operator==(const SENSORSLegJointSensors &t_other) const
void from_string(const std::string &t_str)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
float RKneePitch
pitch of the knee joint (right)
float LKneePitch
pitch of the knee joint (left)
float RHipPitch
pitch of the hip (right)
float LHipRoll
roll of the hip (left)
float LAnkleRoll
roll of the ankle joint (left)
float RAnklePitch
pitch of the ankle joint (right)
float LHipPitch
pitch of the hip (left)
float RHipRoll
roll of the hip (right)
float RAnkleRoll
roll of the ankle joint (right)
float LHipYawPitch
'yaw/pitch' of the hip.
float RHipYawPitch
'yaw/pitch' of the hip.
float LAnklePitch
pitch of the ankle joint (left)
const char * wb_sensors_legjointsensors_description(const struct wb_sensors_legjointsensors *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_sensors_legjointsensors_to_string(const struct wb_sensors_legjointsensors *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_sensors_legjointsensors * wb_sensors_legjointsensors_from_string(struct wb_sensors_legjointsensors *self, const char *str)
Convert from a string.
#define SENSORS_LEGJOINTSENSORS_TO_STRING_BUFFER_SIZE
#define SENSORS_LEGJOINTSENSORS_DESC_BUFFER_SIZE