gusimplewhiteboard
FilteredVisionObject.hpp
Go to the documentation of this file.
1/*
2 * file FilteredVisionObject.hpp
3 *
4 * This file was generated by classgenerator from Filtered_Vision_Object.txt.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Vlad Estivill-Castro. 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 Vlad Estivill-Castro.
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_FilteredVisionObject_h
61#define guWhiteboard_FilteredVisionObject_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
72#undef guWhiteboard_FilteredVisionObject_DEFINED
73#define guWhiteboard_FilteredVisionObject_DEFINED
74
75#undef FilteredVisionObject_DEFINED
76#define FilteredVisionObject_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(uint64_t t_visibilityHistory = 0, int32_t t_frameCounter = 0, int16_t t_distance = 0, int16_t t_x = 0, int16_t t_y = 0, int16_t t_yaw = 0, int16_t t_ray_angle = 0, bool t_isVisible = true, bool t_pad1 = true) {
91 set_visibilityHistory(t_visibilityHistory);
92 set_frameCounter(t_frameCounter);
93 set_distance(t_distance);
94 set_x(t_x);
95 set_y(t_y);
96 set_yaw(t_yaw);
97 set_ray_angle(t_ray_angle);
98 set_isVisible(t_isVisible);
99 set_pad1(t_pad1);
100 }
101
102 public:
103
107 FilteredVisionObject(uint64_t t_visibilityHistory = 0, int32_t t_frameCounter = 0, int16_t t_distance = 0, int16_t t_x = 0, int16_t t_y = 0, int16_t t_yaw = 0, int16_t t_ray_angle = 0, bool t_isVisible = true, bool t_pad1 = true) {
108 this->init(t_visibilityHistory, t_frameCounter, t_distance, t_x, t_y, t_yaw, t_ray_angle, t_isVisible, t_pad1);
109 }
110
115 this->init(t_other.visibilityHistory(), t_other.frameCounter(), t_other.distance(), t_other.x(), t_other.y(), t_other.yaw(), t_other.ray_angle(), t_other.isVisible(), t_other.pad1());
116 }
117
122 this->init(t_other.visibilityHistory, t_other.frameCounter, t_other.distance, t_other.x, t_other.y, t_other.yaw, t_other.ray_angle, t_other.isVisible, t_other.pad1);
123 }
124
129 this->init(t_other.visibilityHistory(), t_other.frameCounter(), t_other.distance(), t_other.x(), t_other.y(), t_other.yaw(), t_other.ray_angle(), t_other.isVisible(), t_other.pad1());
130 return *this;
131 }
132
137 this->init(t_other.visibilityHistory, t_other.frameCounter, t_other.distance, t_other.x, t_other.y, t_other.yaw, t_other.ray_angle, t_other.isVisible, t_other.pad1);
138 return *this;
139 }
140
141 bool operator ==(const FilteredVisionObject &t_other) const
142 {
143 return visibilityHistory() == t_other.visibilityHistory()
144 && frameCounter() == t_other.frameCounter()
145 && distance() == t_other.distance()
146 && x() == t_other.x()
147 && y() == t_other.y()
148 && yaw() == t_other.yaw()
149 && ray_angle() == t_other.ray_angle()
150 && isVisible() == t_other.isVisible()
151 && pad1() == t_other.pad1();
152 }
153
154 bool operator !=(const FilteredVisionObject &t_other) const
155 {
156 return !(*this == t_other);
157 }
158
159 bool operator ==(const wb_filtered_vision_object &t_other) const
160 {
161 return *this == FilteredVisionObject(t_other);
162 }
163
164 bool operator !=(const wb_filtered_vision_object &t_other) const
165 {
166 return !(*this == t_other);
167 }
168
169 uint64_t & visibilityHistory()
170 {
172 }
173
174 const uint64_t & visibilityHistory() const
175 {
177 }
178
179 void set_visibilityHistory(const uint64_t &t_newValue)
180 {
182 }
183
184 int32_t & frameCounter()
185 {
187 }
188
189 const int32_t & frameCounter() const
190 {
192 }
193
194 void set_frameCounter(const int32_t &t_newValue)
195 {
197 }
198
199 int16_t & distance()
200 {
202 }
203
204 const int16_t & distance() const
205 {
207 }
208
209 void set_distance(const int16_t &t_newValue)
210 {
212 }
213
214 int16_t & x()
215 {
217 }
218
219 const int16_t & x() const
220 {
222 }
223
224 void set_x(const int16_t &t_newValue)
225 {
226 wb_filtered_vision_object::x = t_newValue;
227 }
228
229 int16_t & y()
230 {
232 }
233
234 const int16_t & y() const
235 {
237 }
238
239 void set_y(const int16_t &t_newValue)
240 {
241 wb_filtered_vision_object::y = t_newValue;
242 }
243
244 int16_t & yaw()
245 {
247 }
248
249 const int16_t & yaw() const
250 {
252 }
253
254 void set_yaw(const int16_t &t_newValue)
255 {
257 }
258
259 int16_t & ray_angle()
260 {
262 }
263
264 const int16_t & ray_angle() const
265 {
267 }
268
269 void set_ray_angle(const int16_t &t_newValue)
270 {
272 }
273
274 bool & isVisible()
275 {
277 }
278
279 const bool & isVisible() const
280 {
282 }
283
284 void set_isVisible(const bool &t_newValue)
285 {
287 }
288
289 bool & pad1()
290 {
292 }
293
294 const bool & pad1() const
295 {
297 }
298
299 void set_pad1(const bool &t_newValue)
300 {
302 }
303
304#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
308 FilteredVisionObject(const std::string &t_str) {
309 this->init();
310 this->from_string(t_str);
311 }
312
313 std::string description() {
314#ifdef USE_WB_FILTERED_VISION_OBJECT_C_CONVERSION
316 wb_filtered_vision_object_description(this, buffer, sizeof(buffer));
317 std::string descr = buffer;
318 return descr;
319#else
320 std::ostringstream ss;
321 ss << "visibilityHistory=" << this->visibilityHistory();
322 ss << ", ";
323 ss << "frameCounter=" << static_cast<signed>(this->frameCounter());
324 ss << ", ";
325 ss << "distance=" << static_cast<signed>(this->distance());
326 ss << ", ";
327 ss << "x=" << static_cast<signed>(this->x());
328 ss << ", ";
329 ss << "y=" << static_cast<signed>(this->y());
330 ss << ", ";
331 ss << "yaw=" << static_cast<signed>(this->yaw());
332 ss << ", ";
333 ss << "ray_angle=" << static_cast<signed>(this->ray_angle());
334 ss << ", ";
335 ss << "isVisible=" << (this->isVisible() ? "true" : "false");
336 ss << ", ";
337 ss << "pad1=" << (this->pad1() ? "true" : "false");
338 return ss.str();
339#endif
340 }
341
342 std::string to_string() {
343#ifdef USE_WB_FILTERED_VISION_OBJECT_C_CONVERSION
345 wb_filtered_vision_object_to_string(this, buffer, sizeof(buffer));
346 std::string toString = buffer;
347 return toString;
348#else
349 std::ostringstream ss;
350 ss << this->visibilityHistory();
351 ss << ", ";
352 ss << static_cast<signed>(this->frameCounter());
353 ss << ", ";
354 ss << static_cast<signed>(this->distance());
355 ss << ", ";
356 ss << static_cast<signed>(this->x());
357 ss << ", ";
358 ss << static_cast<signed>(this->y());
359 ss << ", ";
360 ss << static_cast<signed>(this->yaw());
361 ss << ", ";
362 ss << static_cast<signed>(this->ray_angle());
363 ss << ", ";
364 ss << (this->isVisible() ? "true" : "false");
365 ss << ", ";
366 ss << (this->pad1() ? "true" : "false");
367 return ss.str();
368#endif
369 }
370
371#ifdef USE_WB_FILTERED_VISION_OBJECT_C_CONVERSION
372 void from_string(const std::string &t_str) {
373 wb_filtered_vision_object_from_string(this, t_str.c_str());
374#else
375 void from_string(const std::string &t_str) {
376 char * str_cstr = const_cast<char *>(t_str.c_str());
377 size_t temp_length = strlen(str_cstr);
378 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
379 if (length < 1 || length > FILTERED_VISION_OBJECT_DESC_BUFFER_SIZE) {
380 return;
381 }
382 char var_str_buffer[FILTERED_VISION_OBJECT_DESC_BUFFER_SIZE + 1];
383 char* var_str = &var_str_buffer[0];
384 char key_buffer[18];
385 char* key = &key_buffer[0];
386 int bracecount = 0;
387 int startVar = 0;
388 int index = 0;
389 int startKey = 0;
390 int endKey = -1;
391 int varIndex = 0;
392 if (index == 0 && str_cstr[0] == '{') {
393 index = 1;
394 }
395 startVar = index;
396 startKey = startVar;
397 do {
398 for (int i = index; i < length; i++) {
399 index = i + 1;
400 if (bracecount == 0 && str_cstr[i] == '=') {
401 endKey = i - 1;
402 startVar = index;
403 continue;
404 }
405 if (bracecount == 0 && isspace(str_cstr[i])) {
406 startVar = index;
407 if (endKey == -1) {
408 startKey = index;
409 }
410 continue;
411 }
412 if (bracecount == 0 && str_cstr[i] == ',') {
413 index = i - 1;
414 break;
415 }
416 if (str_cstr[i] == '{') {
417 bracecount++;
418 continue;
419 }
420 if (str_cstr[i] == '}') {
421 bracecount--;
422 if (bracecount < 0) {
423 index = i - 1;
424 break;
425 }
426 }
427 if (i == length - 1) {
428 index = i;
429 }
430 }
431 if (endKey >= startKey && endKey - startKey < length) {
432 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
433 key[(endKey - startKey) + 1] = 0;
434 } else {
435 key[0] = 0;
436 }
437 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
438 var_str[(index - startVar) + 1] = 0;
439 bracecount = 0;
440 index += 2;
441 startVar = index;
442 startKey = startVar;
443 endKey = -1;
444 if (strlen(key) > 0) {
445 if (0 == strcmp("visibilityHistory", key)) {
446 varIndex = 0;
447 } else if (0 == strcmp("frameCounter", key)) {
448 varIndex = 1;
449 } else if (0 == strcmp("distance", key)) {
450 varIndex = 2;
451 } else if (0 == strcmp("x", key)) {
452 varIndex = 3;
453 } else if (0 == strcmp("y", key)) {
454 varIndex = 4;
455 } else if (0 == strcmp("yaw", key)) {
456 varIndex = 5;
457 } else if (0 == strcmp("ray_angle", key)) {
458 varIndex = 6;
459 } else if (0 == strcmp("isVisible", key)) {
460 varIndex = 7;
461 } else if (0 == strcmp("pad1", key)) {
462 varIndex = 8;
463 } else {
464 varIndex = -1;
465 }
466 }
467 switch (varIndex) {
468 case -1: { break; }
469 case 0:
470 {
471#ifdef __APPLE__
472 this->set_visibilityHistory(static_cast<uint64_t>(atoll(var_str)));
473#else
474 this->set_visibilityHistory(static_cast<uint64_t>(atol(var_str)));
475#endif
476 break;
477 }
478 case 1:
479 {
480 this->set_frameCounter(static_cast<int32_t>(atoi(var_str)));
481 break;
482 }
483 case 2:
484 {
485 this->set_distance(static_cast<int16_t>(atoi(var_str)));
486 break;
487 }
488 case 3:
489 {
490 this->set_x(static_cast<int16_t>(atoi(var_str)));
491 break;
492 }
493 case 4:
494 {
495 this->set_y(static_cast<int16_t>(atoi(var_str)));
496 break;
497 }
498 case 5:
499 {
500 this->set_yaw(static_cast<int16_t>(atoi(var_str)));
501 break;
502 }
503 case 6:
504 {
505 this->set_ray_angle(static_cast<int16_t>(atoi(var_str)));
506 break;
507 }
508 case 7:
509 {
510 this->set_isVisible(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
511 break;
512 }
513 case 8:
514 {
515 this->set_pad1(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
516 break;
517 }
518 }
519 if (varIndex >= 0) {
520 varIndex++;
521 }
522 } while(index < length);
523#endif
524 }
525#endif
526 };
527
528}
529
530#endif
Provides a C++ wrapper around wb_filtered_vision_object.
FilteredVisionObject(const FilteredVisionObject &t_other)
Copy Constructor.
void set_ray_angle(const int16_t &t_newValue)
void set_x(const int16_t &t_newValue)
FilteredVisionObject(const struct wb_filtered_vision_object &t_other)
Copy Constructor.
void set_visibilityHistory(const uint64_t &t_newValue)
FilteredVisionObject(uint64_t t_visibilityHistory=0, int32_t t_frameCounter=0, int16_t t_distance=0, int16_t t_x=0, int16_t t_y=0, int16_t t_yaw=0, int16_t t_ray_angle=0, bool t_isVisible=true, bool t_pad1=true)
Create a new FilteredVisionObject.
void set_pad1(const bool &t_newValue)
void set_y(const int16_t &t_newValue)
bool operator==(const FilteredVisionObject &t_other) const
void set_isVisible(const bool &t_newValue)
void from_string(const std::string &t_str)
FilteredVisionObject & operator=(const FilteredVisionObject &t_other)
Copy Assignment Operator.
FilteredVisionObject(const std::string &t_str)
String Constructor.
bool operator!=(const FilteredVisionObject &t_other) const
const uint64_t & visibilityHistory() const
void set_frameCounter(const int32_t &t_newValue)
void set_distance(const int16_t &t_newValue)
void set_yaw(const int16_t &t_newValue)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
int16_t x
centre x-coordinate in image (0,0) is the centre of the image, positive is to the right
int32_t frameCounter
incremented every time we do not see the object.
int16_t distance
distance to landmark in cm
uint64_t visibilityHistory
a 64-bit history of whether vision said visible 1 or not visible 0.
int16_t yaw
the Yaw in Degrees when the object was last used to generated filtered values.
int16_t ray_angle
In degrees, position of the object, positive is left, negative is right, with distance polar position...
int16_t y
centre y-coordinate in image, positive is upwards
bool isVisible
is this a credible sighting.
const char * wb_filtered_vision_object_to_string(const struct wb_filtered_vision_object *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_filtered_vision_object_description(const struct wb_filtered_vision_object *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_filtered_vision_object * wb_filtered_vision_object_from_string(struct wb_filtered_vision_object *self, const char *str)
Convert from a string.
#define FILTERED_VISION_OBJECT_TO_STRING_BUFFER_SIZE
#define FILTERED_VISION_OBJECT_DESC_BUFFER_SIZE