60#ifndef guWhiteboard_LandmarkSighting_h
61#define guWhiteboard_LandmarkSighting_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_LandmarkSighting_DEFINED
73#define guWhiteboard_LandmarkSighting_DEFINED
75#undef LandmarkSighting_DEFINED
76#define LandmarkSighting_DEFINED
102 this->init(t_direction, t_distance, t_sightingType);
144 return !(*
this == t_other);
154 return !(*
this == t_other);
202#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
212#ifdef USE_WB_LANDMARK_SIGHTING_C_CONVERSION
215 std::string descr = buffer;
218 std::ostringstream ss;
219 ss <<
"direction=" <<
static_cast<signed>(this->
direction());
221 ss <<
"distance=" <<
static_cast<unsigned>(this->
distance());
226 ss <<
"sightingType=" <<
"BallSightingType";
231 ss <<
"sightingType=" <<
"CornerHorizonSightingType";
236 ss <<
"sightingType=" <<
"CornerLineSightingType";
241 ss <<
"sightingType=" <<
"CrossLineSightingType";
246 ss <<
"sightingType=" <<
"GenericGoalPostSightingType";
251 ss <<
"sightingType=" <<
"GoalLandmarkSightingType";
256 ss <<
"sightingType=" <<
"LeftGoalPostSightingType";
261 ss <<
"sightingType=" <<
"LineHorizonSightingType";
266 ss <<
"sightingType=" <<
"RightGoalPostSightingType";
271 ss <<
"sightingType=" <<
"StraightLineSightingType";
276 ss <<
"sightingType=" <<
"TIntersectionLineSightingType";
285#ifdef USE_WB_LANDMARK_SIGHTING_C_CONVERSION
288 std::string toString = buffer;
291 std::ostringstream ss;
292 ss << static_cast<signed>(this->
direction());
294 ss << static_cast<unsigned>(this->
distance());
299 ss <<
"BallSightingType";
304 ss <<
"CornerHorizonSightingType";
309 ss <<
"CornerLineSightingType";
314 ss <<
"CrossLineSightingType";
319 ss <<
"GenericGoalPostSightingType";
324 ss <<
"GoalLandmarkSightingType";
329 ss <<
"LeftGoalPostSightingType";
334 ss <<
"LineHorizonSightingType";
339 ss <<
"RightGoalPostSightingType";
344 ss <<
"StraightLineSightingType";
349 ss <<
"TIntersectionLineSightingType";
357#ifdef USE_WB_LANDMARK_SIGHTING_C_CONVERSION
362 char * str_cstr =
const_cast<char *
>(t_str.c_str());
363 size_t temp_length = strlen(str_cstr);
364 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
369 char* var_str = &var_str_buffer[0];
371 char* key = &key_buffer[0];
378 if (index == 0 && str_cstr[0] ==
'{') {
384 for (
int i = index; i < length; i++) {
386 if (bracecount == 0 && str_cstr[i] ==
'=') {
391 if (bracecount == 0 && isspace(str_cstr[i])) {
398 if (bracecount == 0 && str_cstr[i] ==
',') {
402 if (str_cstr[i] ==
'{') {
406 if (str_cstr[i] ==
'}') {
408 if (bracecount < 0) {
413 if (i == length - 1) {
417 if (endKey >= startKey && endKey - startKey < length) {
418 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
419 key[(endKey - startKey) + 1] = 0;
423 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
424 var_str[(index - startVar) + 1] = 0;
430 if (strlen(key) > 0) {
431 if (0 == strcmp(
"direction", key)) {
433 }
else if (0 == strcmp(
"distance", key)) {
435 }
else if (0 == strcmp(
"sightingType", key)) {
450 this->
set_distance(
static_cast<uint16_t
>(atoi(var_str)));
455 if (strcmp(
"BallSightingType", var_str) == 0) {
456#pragma clang diagnostic push
457#pragma clang diagnostic ignored "-Wbad-function-cast"
459#pragma clang diagnostic pop
460 }
else if (strcmp(
"CornerHorizonSightingType", var_str) == 0) {
461#pragma clang diagnostic push
462#pragma clang diagnostic ignored "-Wbad-function-cast"
464#pragma clang diagnostic pop
465 }
else if (strcmp(
"CornerLineSightingType", var_str) == 0) {
466#pragma clang diagnostic push
467#pragma clang diagnostic ignored "-Wbad-function-cast"
469#pragma clang diagnostic pop
470 }
else if (strcmp(
"CrossLineSightingType", var_str) == 0) {
471#pragma clang diagnostic push
472#pragma clang diagnostic ignored "-Wbad-function-cast"
474#pragma clang diagnostic pop
475 }
else if (strcmp(
"GenericGoalPostSightingType", var_str) == 0) {
476#pragma clang diagnostic push
477#pragma clang diagnostic ignored "-Wbad-function-cast"
479#pragma clang diagnostic pop
480 }
else if (strcmp(
"GoalLandmarkSightingType", var_str) == 0) {
481#pragma clang diagnostic push
482#pragma clang diagnostic ignored "-Wbad-function-cast"
484#pragma clang diagnostic pop
485 }
else if (strcmp(
"LeftGoalPostSightingType", var_str) == 0) {
486#pragma clang diagnostic push
487#pragma clang diagnostic ignored "-Wbad-function-cast"
489#pragma clang diagnostic pop
490 }
else if (strcmp(
"LineHorizonSightingType", var_str) == 0) {
491#pragma clang diagnostic push
492#pragma clang diagnostic ignored "-Wbad-function-cast"
494#pragma clang diagnostic pop
495 }
else if (strcmp(
"RightGoalPostSightingType", var_str) == 0) {
496#pragma clang diagnostic push
497#pragma clang diagnostic ignored "-Wbad-function-cast"
499#pragma clang diagnostic pop
500 }
else if (strcmp(
"StraightLineSightingType", var_str) == 0) {
501#pragma clang diagnostic push
502#pragma clang diagnostic ignored "-Wbad-function-cast"
504#pragma clang diagnostic pop
505 }
else if (strcmp(
"TIntersectionLineSightingType", var_str) == 0) {
506#pragma clang diagnostic push
507#pragma clang diagnostic ignored "-Wbad-function-cast"
509#pragma clang diagnostic pop
511#pragma clang diagnostic push
512#pragma clang diagnostic ignored "-Wbad-function-cast"
514#pragma clang diagnostic pop
522 }
while(index < length);
Provides a C++ wrapper around wb_landmark_sighting.
LandmarkSighting & operator=(const LandmarkSighting &t_other)
Copy Assignment Operator.
void set_direction(const int16_t &t_newValue)
void set_sightingType(const enum LandmarkSightingType &t_newValue)
void from_string(const std::string &t_str)
const int16_t & direction() const
bool operator==(const LandmarkSighting &t_other) const
const uint16_t & distance() const
LandmarkSighting(const std::string &t_str)
String Constructor.
LandmarkSighting(int16_t t_direction=0, uint16_t t_distance=0, enum LandmarkSightingType t_sightingType=static_cast< enum LandmarkSightingType >(0))
Create a new LandmarkSighting.
std::string description()
enum LandmarkSightingType & sightingType()
void set_distance(const uint16_t &t_newValue)
LandmarkSighting(const struct wb_landmark_sighting &t_other)
Copy Constructor.
LandmarkSighting(const LandmarkSighting &t_other)
Copy Constructor.
bool operator!=(const LandmarkSighting &t_other) const
enum LandmarkSightingType & sightingType() const
WHITEBOARD_POSTER_STRING_CONVERSION.
int16_t direction
degrees, relative to the center of the nao torso.
uint16_t distance
CM distance to the center point of the sighting.
enum LandmarkSightingType sightingType
The type of sighting.
const char * wb_landmark_sighting_description(const struct wb_landmark_sighting *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_landmark_sighting_to_string(const struct wb_landmark_sighting *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_landmark_sighting * wb_landmark_sighting_from_string(struct wb_landmark_sighting *self, const char *str)
Convert from a string.
#define LANDMARK_SIGHTING_DESC_BUFFER_SIZE
#define LANDMARK_SIGHTING_TO_STRING_BUFFER_SIZE
@ GenericGoalPostSightingType
@ StraightLineSightingType
@ LeftGoalPostSightingType
@ GoalLandmarkSightingType
@ TIntersectionLineSightingType
@ LineHorizonSightingType
@ CornerHorizonSightingType
@ RightGoalPostSightingType