gusimplewhiteboard
SENSORSArmJointSensors.hpp
Go to the documentation of this file.
1/*
2 * file SENSORSArmJointSensors.hpp
3 *
4 * This file was generated by classgenerator from SENSORS_ArmJointSensors.txt.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 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 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_SENSORSArmJointSensors_h
61#define guWhiteboard_SENSORSArmJointSensors_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_SENSORSArmJointSensors_DEFINED
74#define guWhiteboard_SENSORSArmJointSensors_DEFINED
75
76#undef SENSORSArmJointSensors_DEFINED
77#define SENSORSArmJointSensors_DEFINED
78
79namespace guWhiteboard {
80
85
86 private:
87
91 void init(float t_LShoulderPitch = 0.0f, float t_LShoulderRoll = 0.0f, float t_LElbowRoll = 0.0f, float t_LElbowYaw = 0.0f, float t_RShoulderPitch = 0.0f, float t_RShoulderRoll = 0.0f, float t_RElbowRoll = 0.0f, float t_RElbowYaw = 0.0f, float t_LWristYaw = 0.0f, float t_RWristYaw = 0.0f) {
92 set_LShoulderPitch(t_LShoulderPitch);
93 set_LShoulderRoll(t_LShoulderRoll);
94 set_LElbowRoll(t_LElbowRoll);
95 set_LElbowYaw(t_LElbowYaw);
96 set_RShoulderPitch(t_RShoulderPitch);
97 set_RShoulderRoll(t_RShoulderRoll);
98 set_RElbowRoll(t_RElbowRoll);
99 set_RElbowYaw(t_RElbowYaw);
100 set_LWristYaw(t_LWristYaw);
101 set_RWristYaw(t_RWristYaw);
102 }
103
104 public:
105
109 SENSORSArmJointSensors(float t_LShoulderPitch = 0.0f, float t_LShoulderRoll = 0.0f, float t_LElbowRoll = 0.0f, float t_LElbowYaw = 0.0f, float t_RShoulderPitch = 0.0f, float t_RShoulderRoll = 0.0f, float t_RElbowRoll = 0.0f, float t_RElbowYaw = 0.0f, float t_LWristYaw = 0.0f, float t_RWristYaw = 0.0f) {
110 this->init(t_LShoulderPitch, t_LShoulderRoll, t_LElbowRoll, t_LElbowYaw, t_RShoulderPitch, t_RShoulderRoll, t_RElbowRoll, t_RElbowYaw, t_LWristYaw, t_RWristYaw);
111 }
112
117 this->init(t_other.LShoulderPitch(), t_other.LShoulderRoll(), t_other.LElbowRoll(), t_other.LElbowYaw(), t_other.RShoulderPitch(), t_other.RShoulderRoll(), t_other.RElbowRoll(), t_other.RElbowYaw(), t_other.LWristYaw(), t_other.RWristYaw());
118 }
119
124 this->init(t_other.LShoulderPitch, t_other.LShoulderRoll, t_other.LElbowRoll, t_other.LElbowYaw, t_other.RShoulderPitch, t_other.RShoulderRoll, t_other.RElbowRoll, t_other.RElbowYaw, t_other.LWristYaw, t_other.RWristYaw);
125 }
126
131 this->init(t_other.LShoulderPitch(), t_other.LShoulderRoll(), t_other.LElbowRoll(), t_other.LElbowYaw(), t_other.RShoulderPitch(), t_other.RShoulderRoll(), t_other.RElbowRoll(), t_other.RElbowYaw(), t_other.LWristYaw(), t_other.RWristYaw());
132 return *this;
133 }
134
139 this->init(t_other.LShoulderPitch, t_other.LShoulderRoll, t_other.LElbowRoll, t_other.LElbowYaw, t_other.RShoulderPitch, t_other.RShoulderRoll, t_other.RElbowRoll, t_other.RElbowYaw, t_other.LWristYaw, t_other.RWristYaw);
140 return *this;
141 }
142
143 bool operator ==(const SENSORSArmJointSensors &t_other) const
144 {
145 return fabsf(LShoulderPitch() - t_other.LShoulderPitch()) < FLT_EPSILON
146 && fabsf(LShoulderRoll() - t_other.LShoulderRoll()) < FLT_EPSILON
147 && fabsf(LElbowRoll() - t_other.LElbowRoll()) < FLT_EPSILON
148 && fabsf(LElbowYaw() - t_other.LElbowYaw()) < FLT_EPSILON
149 && fabsf(RShoulderPitch() - t_other.RShoulderPitch()) < FLT_EPSILON
150 && fabsf(RShoulderRoll() - t_other.RShoulderRoll()) < FLT_EPSILON
151 && fabsf(RElbowRoll() - t_other.RElbowRoll()) < FLT_EPSILON
152 && fabsf(RElbowYaw() - t_other.RElbowYaw()) < FLT_EPSILON
153 && fabsf(LWristYaw() - t_other.LWristYaw()) < FLT_EPSILON
154 && fabsf(RWristYaw() - t_other.RWristYaw()) < FLT_EPSILON;
155 }
156
157 bool operator !=(const SENSORSArmJointSensors &t_other) const
158 {
159 return !(*this == t_other);
160 }
161
162 bool operator ==(const wb_sensors_armjointsensors &t_other) const
163 {
164 return *this == SENSORSArmJointSensors(t_other);
165 }
166
167 bool operator !=(const wb_sensors_armjointsensors &t_other) const
168 {
169 return !(*this == t_other);
170 }
171
173 {
175 }
176
177 const float & LShoulderPitch() const
178 {
180 }
181
182 void set_LShoulderPitch(const float &t_newValue)
183 {
185 }
186
188 {
190 }
191
192 const float & LShoulderRoll() const
193 {
195 }
196
197 void set_LShoulderRoll(const float &t_newValue)
198 {
200 }
201
202 float & LElbowRoll()
203 {
205 }
206
207 const float & LElbowRoll() const
208 {
210 }
211
212 void set_LElbowRoll(const float &t_newValue)
213 {
215 }
216
217 float & LElbowYaw()
218 {
220 }
221
222 const float & LElbowYaw() const
223 {
225 }
226
227 void set_LElbowYaw(const float &t_newValue)
228 {
230 }
231
233 {
235 }
236
237 const float & RShoulderPitch() const
238 {
240 }
241
242 void set_RShoulderPitch(const float &t_newValue)
243 {
245 }
246
248 {
250 }
251
252 const float & RShoulderRoll() const
253 {
255 }
256
257 void set_RShoulderRoll(const float &t_newValue)
258 {
260 }
261
262 float & RElbowRoll()
263 {
265 }
266
267 const float & RElbowRoll() const
268 {
270 }
271
272 void set_RElbowRoll(const float &t_newValue)
273 {
275 }
276
277 float & RElbowYaw()
278 {
280 }
281
282 const float & RElbowYaw() const
283 {
285 }
286
287 void set_RElbowYaw(const float &t_newValue)
288 {
290 }
291
292 float & LWristYaw()
293 {
295 }
296
297 const float & LWristYaw() const
298 {
300 }
301
302 void set_LWristYaw(const float &t_newValue)
303 {
305 }
306
307 float & RWristYaw()
308 {
310 }
311
312 const float & RWristYaw() const
313 {
315 }
316
317 void set_RWristYaw(const float &t_newValue)
318 {
320 }
321
322#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
326 SENSORSArmJointSensors(const std::string &t_str) {
327 this->init();
328 this->from_string(t_str);
329 }
330
331 std::string description() {
332#ifdef USE_WB_SENSORS_ARMJOINTSENSORS_C_CONVERSION
334 wb_sensors_armjointsensors_description(this, buffer, sizeof(buffer));
335 std::string descr = buffer;
336 return descr;
337#else
338 std::ostringstream ss;
339 ss << "LShoulderPitch=" << this->LShoulderPitch();
340 ss << ", ";
341 ss << "LShoulderRoll=" << this->LShoulderRoll();
342 ss << ", ";
343 ss << "LElbowRoll=" << this->LElbowRoll();
344 ss << ", ";
345 ss << "LElbowYaw=" << this->LElbowYaw();
346 ss << ", ";
347 ss << "RShoulderPitch=" << this->RShoulderPitch();
348 ss << ", ";
349 ss << "RShoulderRoll=" << this->RShoulderRoll();
350 ss << ", ";
351 ss << "RElbowRoll=" << this->RElbowRoll();
352 ss << ", ";
353 ss << "RElbowYaw=" << this->RElbowYaw();
354 ss << ", ";
355 ss << "LWristYaw=" << this->LWristYaw();
356 ss << ", ";
357 ss << "RWristYaw=" << this->RWristYaw();
358 return ss.str();
359#endif
360 }
361
362 std::string to_string() {
363#ifdef USE_WB_SENSORS_ARMJOINTSENSORS_C_CONVERSION
365 wb_sensors_armjointsensors_to_string(this, buffer, sizeof(buffer));
366 std::string toString = buffer;
367 return toString;
368#else
369 std::ostringstream ss;
370 ss << this->LShoulderPitch();
371 ss << ", ";
372 ss << this->LShoulderRoll();
373 ss << ", ";
374 ss << this->LElbowRoll();
375 ss << ", ";
376 ss << this->LElbowYaw();
377 ss << ", ";
378 ss << this->RShoulderPitch();
379 ss << ", ";
380 ss << this->RShoulderRoll();
381 ss << ", ";
382 ss << this->RElbowRoll();
383 ss << ", ";
384 ss << this->RElbowYaw();
385 ss << ", ";
386 ss << this->LWristYaw();
387 ss << ", ";
388 ss << this->RWristYaw();
389 return ss.str();
390#endif
391 }
392
393#ifdef USE_WB_SENSORS_ARMJOINTSENSORS_C_CONVERSION
394 void from_string(const std::string &t_str) {
395 wb_sensors_armjointsensors_from_string(this, t_str.c_str());
396#else
397 void from_string(const std::string &t_str) {
398 char * str_cstr = const_cast<char *>(t_str.c_str());
399 size_t temp_length = strlen(str_cstr);
400 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
401 if (length < 1 || length > SENSORS_ARMJOINTSENSORS_DESC_BUFFER_SIZE) {
402 return;
403 }
404 char var_str_buffer[SENSORS_ARMJOINTSENSORS_DESC_BUFFER_SIZE + 1];
405 char* var_str = &var_str_buffer[0];
406 char key_buffer[15];
407 char* key = &key_buffer[0];
408 int bracecount = 0;
409 int startVar = 0;
410 int index = 0;
411 int startKey = 0;
412 int endKey = -1;
413 int varIndex = 0;
414 if (index == 0 && str_cstr[0] == '{') {
415 index = 1;
416 }
417 startVar = index;
418 startKey = startVar;
419 do {
420 for (int i = index; i < length; i++) {
421 index = i + 1;
422 if (bracecount == 0 && str_cstr[i] == '=') {
423 endKey = i - 1;
424 startVar = index;
425 continue;
426 }
427 if (bracecount == 0 && isspace(str_cstr[i])) {
428 startVar = index;
429 if (endKey == -1) {
430 startKey = index;
431 }
432 continue;
433 }
434 if (bracecount == 0 && str_cstr[i] == ',') {
435 index = i - 1;
436 break;
437 }
438 if (str_cstr[i] == '{') {
439 bracecount++;
440 continue;
441 }
442 if (str_cstr[i] == '}') {
443 bracecount--;
444 if (bracecount < 0) {
445 index = i - 1;
446 break;
447 }
448 }
449 if (i == length - 1) {
450 index = i;
451 }
452 }
453 if (endKey >= startKey && endKey - startKey < length) {
454 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
455 key[(endKey - startKey) + 1] = 0;
456 } else {
457 key[0] = 0;
458 }
459 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
460 var_str[(index - startVar) + 1] = 0;
461 bracecount = 0;
462 index += 2;
463 startVar = index;
464 startKey = startVar;
465 endKey = -1;
466 if (strlen(key) > 0) {
467 if (0 == strcmp("LShoulderPitch", key)) {
468 varIndex = 0;
469 } else if (0 == strcmp("LShoulderRoll", key)) {
470 varIndex = 1;
471 } else if (0 == strcmp("LElbowRoll", key)) {
472 varIndex = 2;
473 } else if (0 == strcmp("LElbowYaw", key)) {
474 varIndex = 3;
475 } else if (0 == strcmp("RShoulderPitch", key)) {
476 varIndex = 4;
477 } else if (0 == strcmp("RShoulderRoll", key)) {
478 varIndex = 5;
479 } else if (0 == strcmp("RElbowRoll", key)) {
480 varIndex = 6;
481 } else if (0 == strcmp("RElbowYaw", key)) {
482 varIndex = 7;
483 } else if (0 == strcmp("LWristYaw", key)) {
484 varIndex = 8;
485 } else if (0 == strcmp("RWristYaw", key)) {
486 varIndex = 9;
487 } else {
488 varIndex = -1;
489 }
490 }
491 switch (varIndex) {
492 case -1: { break; }
493 case 0:
494 {
495 this->set_LShoulderPitch(static_cast<float>(atof(var_str)));
496 break;
497 }
498 case 1:
499 {
500 this->set_LShoulderRoll(static_cast<float>(atof(var_str)));
501 break;
502 }
503 case 2:
504 {
505 this->set_LElbowRoll(static_cast<float>(atof(var_str)));
506 break;
507 }
508 case 3:
509 {
510 this->set_LElbowYaw(static_cast<float>(atof(var_str)));
511 break;
512 }
513 case 4:
514 {
515 this->set_RShoulderPitch(static_cast<float>(atof(var_str)));
516 break;
517 }
518 case 5:
519 {
520 this->set_RShoulderRoll(static_cast<float>(atof(var_str)));
521 break;
522 }
523 case 6:
524 {
525 this->set_RElbowRoll(static_cast<float>(atof(var_str)));
526 break;
527 }
528 case 7:
529 {
530 this->set_RElbowYaw(static_cast<float>(atof(var_str)));
531 break;
532 }
533 case 8:
534 {
535 this->set_LWristYaw(static_cast<float>(atof(var_str)));
536 break;
537 }
538 case 9:
539 {
540 this->set_RWristYaw(static_cast<float>(atof(var_str)));
541 break;
542 }
543 }
544 if (varIndex >= 0) {
545 varIndex++;
546 }
547 } while(index < length);
548#endif
549 }
550#endif
551 };
552
553}
554
555#endif
Provides a C++ wrapper around wb_sensors_armjointsensors.
void set_LWristYaw(const float &t_newValue)
void set_RWristYaw(const float &t_newValue)
SENSORSArmJointSensors(float t_LShoulderPitch=0.0f, float t_LShoulderRoll=0.0f, float t_LElbowRoll=0.0f, float t_LElbowYaw=0.0f, float t_RShoulderPitch=0.0f, float t_RShoulderRoll=0.0f, float t_RElbowRoll=0.0f, float t_RElbowYaw=0.0f, float t_LWristYaw=0.0f, float t_RWristYaw=0.0f)
Create a new SENSORSArmJointSensors.
void from_string(const std::string &t_str)
SENSORSArmJointSensors & operator=(const SENSORSArmJointSensors &t_other)
Copy Assignment Operator.
void set_LShoulderRoll(const float &t_newValue)
void set_RShoulderRoll(const float &t_newValue)
void set_RElbowRoll(const float &t_newValue)
void set_RElbowYaw(const float &t_newValue)
SENSORSArmJointSensors(const struct wb_sensors_armjointsensors &t_other)
Copy Constructor.
SENSORSArmJointSensors(const SENSORSArmJointSensors &t_other)
Copy Constructor.
void set_LShoulderPitch(const float &t_newValue)
void set_RShoulderPitch(const float &t_newValue)
bool operator==(const SENSORSArmJointSensors &t_other) const
SENSORSArmJointSensors(const std::string &t_str)
String Constructor.
void set_LElbowRoll(const float &t_newValue)
bool operator!=(const SENSORSArmJointSensors &t_other) const
void set_LElbowYaw(const float &t_newValue)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
float LWristYaw
yaw of the wrist joint (left)
float RShoulderPitch
pitch of the shoulder joint (right)
float LElbowRoll
roll of the elbow joint (left)
float RElbowRoll
roll of the elbow joint (right)
float RElbowYaw
yaw of the elbow joint (right)
float RWristYaw
yaw of the wrist joint (right)
float LElbowYaw
yaw of the elbow joint (left)
float LShoulderPitch
pitch of the shoulder joint (left)
float RShoulderRoll
roll of the shoulder joint (right)
float LShoulderRoll
roll of the shoulder joint (left)
const char * wb_sensors_armjointsensors_to_string(const struct wb_sensors_armjointsensors *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_sensors_armjointsensors * wb_sensors_armjointsensors_from_string(struct wb_sensors_armjointsensors *self, const char *str)
Convert from a string.
const char * wb_sensors_armjointsensors_description(const struct wb_sensors_armjointsensors *self, char *descString, size_t bufferSize)
Convert to a description string.
#define SENSORS_ARMJOINTSENSORS_TO_STRING_BUFFER_SIZE
#define SENSORS_ARMJOINTSENSORS_DESC_BUFFER_SIZE