60#ifndef guWhiteboard_Location_h
61#define guWhiteboard_Location_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_Location_DEFINED
73#define guWhiteboard_Location_DEFINED
75#undef Location_DEFINED
76#define Location_DEFINED
78#include <guunits/guunits.h>
79#include <gucoordinates/gucoordinates.h>
81#if __cplusplus >= 201703L
97 void init(int16_t t_direction = 0, uint16_t t_distance = 0, uint8_t t_confidence = 0, uint32_t t_distanceVariance = 0, uint32_t t_directionVariance = 0) {
110 Location(int16_t t_direction = 0, uint16_t t_distance = 0, uint8_t t_confidence = 0, uint32_t t_distanceVariance = 0, uint32_t t_directionVariance = 0) {
111 this->init(t_direction, t_distance, t_confidence, t_distanceVariance, t_directionVariance);
155 return !(*
this == t_other);
165 return !(*
this == t_other);
243#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
253#ifdef USE_WB_LOCATION_C_CONVERSION
256 std::string descr = buffer;
259 std::ostringstream ss;
260 ss <<
"direction=" <<
static_cast<signed>(this->
direction());
262 ss <<
"distance=" <<
static_cast<unsigned>(this->
distance());
264 ss <<
"confidence=" <<
static_cast<unsigned>(this->
confidence());
266 ss <<
"distanceVariance=" <<
static_cast<unsigned>(this->
distanceVariance());
274#ifdef USE_WB_LOCATION_C_CONVERSION
277 std::string toString = buffer;
280 std::ostringstream ss;
281 ss << static_cast<signed>(this->
direction());
283 ss << static_cast<unsigned>(this->
distance());
285 ss << static_cast<unsigned>(this->
confidence());
294#ifdef USE_WB_LOCATION_C_CONVERSION
299 char * str_cstr =
const_cast<char *
>(t_str.c_str());
300 size_t temp_length = strlen(str_cstr);
301 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
306 char* var_str = &var_str_buffer[0];
308 char* key = &key_buffer[0];
315 if (index == 0 && str_cstr[0] ==
'{') {
321 for (
int i = index; i < length; i++) {
323 if (bracecount == 0 && str_cstr[i] ==
'=') {
328 if (bracecount == 0 && isspace(str_cstr[i])) {
335 if (bracecount == 0 && str_cstr[i] ==
',') {
339 if (str_cstr[i] ==
'{') {
343 if (str_cstr[i] ==
'}') {
345 if (bracecount < 0) {
350 if (i == length - 1) {
354 if (endKey >= startKey && endKey - startKey < length) {
355 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
356 key[(endKey - startKey) + 1] = 0;
360 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
361 var_str[(index - startVar) + 1] = 0;
367 if (strlen(key) > 0) {
368 if (0 == strcmp(
"direction", key)) {
370 }
else if (0 == strcmp(
"distance", key)) {
372 }
else if (0 == strcmp(
"confidence", key)) {
374 }
else if (0 == strcmp(
"distanceVariance", key)) {
376 }
else if (0 == strcmp(
"directionVariance", key)) {
391 this->
set_distance(
static_cast<uint16_t
>(atoi(var_str)));
413 }
while(index < length);
430 deg_d_to_i16(t_other.direction()),
431 cm_u_to_u16(mm_u_to_cm_u(t_other.distance()))
446 Location(
const GU::RelativeCoordinate &t_other,
const uint8_t t_confidence)
449 deg_d_to_i16(t_other.direction()),
450 cm_u_to_u16(mm_u_to_cm_u(t_other.distance())),
467 Location(
const GU::RelativeCoordinate &t_other,
const uint8_t t_confidence,
const uint32_t t_distanceVariance, uint32_t t_directionVariance)
470 deg_d_to_i16(t_other.direction()),
471 cm_u_to_u16(mm_u_to_cm_u(t_other.distance())),
506#if __cplusplus >= 201703L
522 if (
confidence() < minimumConfidence)
return std::nullopt;
Provides a C++ wrapper around wb_location.
Location(const struct wb_location &t_other)
Copy Constructor.
const uint32_t & distanceVariance() const
std::optional< GU::RelativeCoordinate > relativeCoordinate(const uint8_t minimumConfidence) const
Convert this location to a GU::RelativeCoordinate only if the confidence of the location is greater t...
void set_distanceVariance(const uint32_t &t_newValue)
Location & operator=(const Location &t_other)
Copy Assignment Operator.
std::string description()
uint32_t & distanceVariance()
Location(const GU::RelativeCoordinate &t_other, const uint8_t t_confidence)
Create a new Location by converting the values from a GU::RelativeCoordinate.
const uint16_t & distance() const
Location(int16_t t_direction=0, uint16_t t_distance=0, uint8_t t_confidence=0, uint32_t t_distanceVariance=0, uint32_t t_directionVariance=0)
Create a new Location.
void set_distance(const uint16_t &t_newValue)
const int16_t & direction() const
bool operator==(const Location &t_other) const
void set_directionVariance(const uint32_t &t_newValue)
const uint8_t & confidence() const
const uint32_t & directionVariance() const
GU::RelativeCoordinate relativeCoordinate() const
Convert this location to a GU::RelativeCoordinate.
void set_confidence(const uint8_t &t_newValue)
bool operator!=(const Location &t_other) const
void from_string(const std::string &t_str)
Location(const GU::RelativeCoordinate &t_other)
WHITEBOARD_POSTER_STRING_CONVERSION.
Location(const std::string &t_str)
String Constructor.
uint32_t & directionVariance()
void set_direction(const int16_t &t_newValue)
Location(const Location &t_other)
Copy Constructor.
GU::OptionalRelativeCoordinate optionalRelativeCoordinate(const uint8_t minimumConfidence) const
Convert this location to a GU::RelativeCoordinate only if the confidence of the location is greater t...
Location(const GU::RelativeCoordinate &t_other, const uint8_t t_confidence, const uint32_t t_distanceVariance, uint32_t t_directionVariance)
Create a new Location by converting the values from a GU::RelativeCoordinate.
WHITEBOARD_POSTER_STRING_CONVERSION.
uint32_t distanceVariance
The variance of the distance.
uint32_t directionVariance
The variance of the direction.
int16_t direction
degrees, relative to the center of the nao torso.
uint8_t confidence
The type of sighting.
uint16_t distance
CM distance to the center point of the sighting.
const char * wb_location_description(const struct wb_location *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_location_to_string(const struct wb_location *self, char *toString, size_t bufferSize)
Convert to a string.
struct gu_optional_relative_coordinate wb_location_to_opt_rr_coord(const struct wb_location location, const uint8_t confidence)
Converts a wb_location to a gu_optional_relative_coordinate.
struct wb_location * wb_location_from_string(struct wb_location *self, const char *str)
Convert from a string.
struct gu_relative_coordinate wb_location_to_rr_coord(const struct wb_location location)
Converts a wb_location to a gu_relative_coordinate.
#define LOCATION_TO_STRING_BUFFER_SIZE
#define LOCATION_DESC_BUFFER_SIZE