gusimplewhiteboard
SENSORSLegJointTemps.hpp
Go to the documentation of this file.
1/*
2 * file SENSORSLegJointTemps.hpp
3 *
4 * This file was generated by classgenerator from SENSORS_LegJointTemps.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_SENSORSLegJointTemps_h
61#define guWhiteboard_SENSORSLegJointTemps_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_SENSORSLegJointTemps_DEFINED
74#define guWhiteboard_SENSORSLegJointTemps_DEFINED
75
76#undef SENSORSLegJointTemps_DEFINED
77#define SENSORSLegJointTemps_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) {
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 }
99
100 public:
101
105 SENSORSLegJointTemps(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) {
106 this->init(t_LKneePitch, t_LAnklePitch, t_LAnkleRoll, t_RKneePitch, t_RAnklePitch, t_RAnkleRoll);
107 }
108
113 this->init(t_other.LKneePitch(), t_other.LAnklePitch(), t_other.LAnkleRoll(), t_other.RKneePitch(), t_other.RAnklePitch(), t_other.RAnkleRoll());
114 }
115
120 this->init(t_other.LKneePitch, t_other.LAnklePitch, t_other.LAnkleRoll, t_other.RKneePitch, t_other.RAnklePitch, t_other.RAnkleRoll);
121 }
122
127 this->init(t_other.LKneePitch(), t_other.LAnklePitch(), t_other.LAnkleRoll(), t_other.RKneePitch(), t_other.RAnklePitch(), t_other.RAnkleRoll());
128 return *this;
129 }
130
135 this->init(t_other.LKneePitch, t_other.LAnklePitch, t_other.LAnkleRoll, t_other.RKneePitch, t_other.RAnklePitch, t_other.RAnkleRoll);
136 return *this;
137 }
138
139 bool operator ==(const SENSORSLegJointTemps &t_other) const
140 {
141 return fabsf(LKneePitch() - t_other.LKneePitch()) < FLT_EPSILON
142 && fabsf(LAnklePitch() - t_other.LAnklePitch()) < FLT_EPSILON
143 && fabsf(LAnkleRoll() - t_other.LAnkleRoll()) < FLT_EPSILON
144 && fabsf(RKneePitch() - t_other.RKneePitch()) < FLT_EPSILON
145 && fabsf(RAnklePitch() - t_other.RAnklePitch()) < FLT_EPSILON
146 && fabsf(RAnkleRoll() - t_other.RAnkleRoll()) < FLT_EPSILON;
147 }
148
149 bool operator !=(const SENSORSLegJointTemps &t_other) const
150 {
151 return !(*this == t_other);
152 }
153
154 bool operator ==(const wb_sensors_legjointtemps &t_other) const
155 {
156 return *this == SENSORSLegJointTemps(t_other);
157 }
158
159 bool operator !=(const wb_sensors_legjointtemps &t_other) const
160 {
161 return !(*this == t_other);
162 }
163
164 float & LKneePitch()
165 {
167 }
168
169 const float & LKneePitch() const
170 {
172 }
173
174 void set_LKneePitch(const float &t_newValue)
175 {
177 }
178
179 float & LAnklePitch()
180 {
182 }
183
184 const float & LAnklePitch() const
185 {
187 }
188
189 void set_LAnklePitch(const float &t_newValue)
190 {
192 }
193
194 float & LAnkleRoll()
195 {
197 }
198
199 const float & LAnkleRoll() const
200 {
202 }
203
204 void set_LAnkleRoll(const float &t_newValue)
205 {
207 }
208
209 float & RKneePitch()
210 {
212 }
213
214 const float & RKneePitch() const
215 {
217 }
218
219 void set_RKneePitch(const float &t_newValue)
220 {
222 }
223
224 float & RAnklePitch()
225 {
227 }
228
229 const float & RAnklePitch() const
230 {
232 }
233
234 void set_RAnklePitch(const float &t_newValue)
235 {
237 }
238
239 float & RAnkleRoll()
240 {
242 }
243
244 const float & RAnkleRoll() const
245 {
247 }
248
249 void set_RAnkleRoll(const float &t_newValue)
250 {
252 }
253
254#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
258 SENSORSLegJointTemps(const std::string &t_str) {
259 this->init();
260 this->from_string(t_str);
261 }
262
263 std::string description() {
264#ifdef USE_WB_SENSORS_LEGJOINTTEMPS_C_CONVERSION
266 wb_sensors_legjointtemps_description(this, buffer, sizeof(buffer));
267 std::string descr = buffer;
268 return descr;
269#else
270 std::ostringstream ss;
271 ss << "LKneePitch=" << this->LKneePitch();
272 ss << ", ";
273 ss << "LAnklePitch=" << this->LAnklePitch();
274 ss << ", ";
275 ss << "LAnkleRoll=" << this->LAnkleRoll();
276 ss << ", ";
277 ss << "RKneePitch=" << this->RKneePitch();
278 ss << ", ";
279 ss << "RAnklePitch=" << this->RAnklePitch();
280 ss << ", ";
281 ss << "RAnkleRoll=" << this->RAnkleRoll();
282 return ss.str();
283#endif
284 }
285
286 std::string to_string() {
287#ifdef USE_WB_SENSORS_LEGJOINTTEMPS_C_CONVERSION
289 wb_sensors_legjointtemps_to_string(this, buffer, sizeof(buffer));
290 std::string toString = buffer;
291 return toString;
292#else
293 std::ostringstream ss;
294 ss << this->LKneePitch();
295 ss << ", ";
296 ss << this->LAnklePitch();
297 ss << ", ";
298 ss << this->LAnkleRoll();
299 ss << ", ";
300 ss << this->RKneePitch();
301 ss << ", ";
302 ss << this->RAnklePitch();
303 ss << ", ";
304 ss << this->RAnkleRoll();
305 return ss.str();
306#endif
307 }
308
309#ifdef USE_WB_SENSORS_LEGJOINTTEMPS_C_CONVERSION
310 void from_string(const std::string &t_str) {
311 wb_sensors_legjointtemps_from_string(this, t_str.c_str());
312#else
313 void from_string(const std::string &t_str) {
314 char * str_cstr = const_cast<char *>(t_str.c_str());
315 size_t temp_length = strlen(str_cstr);
316 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
317 if (length < 1 || length > SENSORS_LEGJOINTTEMPS_DESC_BUFFER_SIZE) {
318 return;
319 }
320 char var_str_buffer[SENSORS_LEGJOINTTEMPS_DESC_BUFFER_SIZE + 1];
321 char* var_str = &var_str_buffer[0];
322 char key_buffer[12];
323 char* key = &key_buffer[0];
324 int bracecount = 0;
325 int startVar = 0;
326 int index = 0;
327 int startKey = 0;
328 int endKey = -1;
329 int varIndex = 0;
330 if (index == 0 && str_cstr[0] == '{') {
331 index = 1;
332 }
333 startVar = index;
334 startKey = startVar;
335 do {
336 for (int i = index; i < length; i++) {
337 index = i + 1;
338 if (bracecount == 0 && str_cstr[i] == '=') {
339 endKey = i - 1;
340 startVar = index;
341 continue;
342 }
343 if (bracecount == 0 && isspace(str_cstr[i])) {
344 startVar = index;
345 if (endKey == -1) {
346 startKey = index;
347 }
348 continue;
349 }
350 if (bracecount == 0 && str_cstr[i] == ',') {
351 index = i - 1;
352 break;
353 }
354 if (str_cstr[i] == '{') {
355 bracecount++;
356 continue;
357 }
358 if (str_cstr[i] == '}') {
359 bracecount--;
360 if (bracecount < 0) {
361 index = i - 1;
362 break;
363 }
364 }
365 if (i == length - 1) {
366 index = i;
367 }
368 }
369 if (endKey >= startKey && endKey - startKey < length) {
370 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
371 key[(endKey - startKey) + 1] = 0;
372 } else {
373 key[0] = 0;
374 }
375 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
376 var_str[(index - startVar) + 1] = 0;
377 bracecount = 0;
378 index += 2;
379 startVar = index;
380 startKey = startVar;
381 endKey = -1;
382 if (strlen(key) > 0) {
383 if (0 == strcmp("LKneePitch", key)) {
384 varIndex = 0;
385 } else if (0 == strcmp("LAnklePitch", key)) {
386 varIndex = 1;
387 } else if (0 == strcmp("LAnkleRoll", key)) {
388 varIndex = 2;
389 } else if (0 == strcmp("RKneePitch", key)) {
390 varIndex = 3;
391 } else if (0 == strcmp("RAnklePitch", key)) {
392 varIndex = 4;
393 } else if (0 == strcmp("RAnkleRoll", key)) {
394 varIndex = 5;
395 } else {
396 varIndex = -1;
397 }
398 }
399 switch (varIndex) {
400 case -1: { break; }
401 case 0:
402 {
403 this->set_LKneePitch(static_cast<float>(atof(var_str)));
404 break;
405 }
406 case 1:
407 {
408 this->set_LAnklePitch(static_cast<float>(atof(var_str)));
409 break;
410 }
411 case 2:
412 {
413 this->set_LAnkleRoll(static_cast<float>(atof(var_str)));
414 break;
415 }
416 case 3:
417 {
418 this->set_RKneePitch(static_cast<float>(atof(var_str)));
419 break;
420 }
421 case 4:
422 {
423 this->set_RAnklePitch(static_cast<float>(atof(var_str)));
424 break;
425 }
426 case 5:
427 {
428 this->set_RAnkleRoll(static_cast<float>(atof(var_str)));
429 break;
430 }
431 }
432 if (varIndex >= 0) {
433 varIndex++;
434 }
435 } while(index < length);
436#endif
437 }
438#endif
439 };
440
441}
442
443#endif
Provides a C++ wrapper around wb_sensors_legjointtemps.
SENSORSLegJointTemps & operator=(const SENSORSLegJointTemps &t_other)
Copy Assignment Operator.
void set_RAnkleRoll(const float &t_newValue)
bool operator!=(const SENSORSLegJointTemps &t_other) const
void set_LKneePitch(const float &t_newValue)
SENSORSLegJointTemps(const struct wb_sensors_legjointtemps &t_other)
Copy Constructor.
void set_RAnklePitch(const float &t_newValue)
void set_LAnkleRoll(const float &t_newValue)
void set_RKneePitch(const float &t_newValue)
void set_LAnklePitch(const float &t_newValue)
SENSORSLegJointTemps(const SENSORSLegJointTemps &t_other)
Copy Constructor.
SENSORSLegJointTemps(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)
Create a new SENSORSLegJointTemps.
SENSORSLegJointTemps(const std::string &t_str)
String Constructor.
bool operator==(const SENSORSLegJointTemps &t_other) const
void from_string(const std::string &t_str)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
float RAnklePitch
right ankle pitch temp
float LKneePitch
left knee pitch temp
float LAnkleRoll
left ankle roll temp
float RKneePitch
right knee pitch temp
float RAnkleRoll
right ankle roll temp
float LAnklePitch
left ankle pitch temp
struct wb_sensors_legjointtemps * wb_sensors_legjointtemps_from_string(struct wb_sensors_legjointtemps *self, const char *str)
Convert from a string.
const char * wb_sensors_legjointtemps_to_string(const struct wb_sensors_legjointtemps *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_sensors_legjointtemps_description(const struct wb_sensors_legjointtemps *self, char *descString, size_t bufferSize)
Convert to a description string.
#define SENSORS_LEGJOINTTEMPS_TO_STRING_BUFFER_SIZE
#define SENSORS_LEGJOINTTEMPS_DESC_BUFFER_SIZE