60#ifndef guWhiteboard_VisionDetectionBall_h
61#define guWhiteboard_VisionDetectionBall_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_VisionDetectionBall_DEFINED
73#define guWhiteboard_VisionDetectionBall_DEFINED
75#undef VisionDetectionBall_DEFINED
76#define VisionDetectionBall_DEFINED
80#include <guunits/guunits.h>
81#include <gucoordinates/gucoordinates.h>
108 this->init(t_sightingType, t_coordinate, t_verticalRadius, t_horizontalRadius);
151 return !(*
this == t_other);
161 return !(*
this == t_other);
224#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
234#ifdef USE_WB_VISION_DETECTION_BALL_C_CONVERSION
237 std::string descr = buffer;
240 std::ostringstream ss;
244 ss <<
"sightingType=" <<
"BallDetected";
249 ss <<
"sightingType=" <<
"NoBallDetected";
256 ss <<
"verticalRadius=" <<
static_cast<unsigned>(this->
verticalRadius());
258 ss <<
"horizontalRadius=" <<
static_cast<unsigned>(this->
horizontalRadius());
264#ifdef USE_WB_VISION_DETECTION_BALL_C_CONVERSION
267 std::string toString = buffer;
270 std::ostringstream ss;
274 ss <<
"BallDetected";
279 ss <<
"NoBallDetected";
293#ifdef USE_WB_VISION_DETECTION_BALL_C_CONVERSION
298 char * str_cstr =
const_cast<char *
>(t_str.c_str());
299 size_t temp_length = strlen(str_cstr);
300 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
305 char* var_str = &var_str_buffer[0];
307 char* key = &key_buffer[0];
314 if (index == 0 && str_cstr[0] ==
'{') {
320 for (
int i = index; i < length; i++) {
322 if (bracecount == 0 && str_cstr[i] ==
'=') {
327 if (bracecount == 0 && isspace(str_cstr[i])) {
334 if (bracecount == 0 && str_cstr[i] ==
',') {
338 if (str_cstr[i] ==
'{') {
342 if (str_cstr[i] ==
'}') {
344 if (bracecount < 0) {
349 if (i == length - 1) {
353 if (endKey >= startKey && endKey - startKey < length) {
354 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
355 key[(endKey - startKey) + 1] = 0;
359 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
360 var_str[(index - startVar) + 1] = 0;
366 if (strlen(key) > 0) {
367 if (0 == strcmp(
"sightingType", key)) {
369 }
else if (0 == strcmp(
"coordinate", key)) {
371 }
else if (0 == strcmp(
"verticalRadius", key)) {
373 }
else if (0 == strcmp(
"horizontalRadius", key)) {
383 if (strcmp(
"BallDetected", var_str) == 0) {
384#pragma clang diagnostic push
385#pragma clang diagnostic ignored "-Wbad-function-cast"
387#pragma clang diagnostic pop
388 }
else if (strcmp(
"NoBallDetected", var_str) == 0) {
389#pragma clang diagnostic push
390#pragma clang diagnostic ignored "-Wbad-function-cast"
392#pragma clang diagnostic pop
394#pragma clang diagnostic push
395#pragma clang diagnostic ignored "-Wbad-function-cast"
397#pragma clang diagnostic pop
422 }
while(index < length);
Provides a C++ wrapper around wb_pixel_coordinate.
std::string description()
void from_string(const std::string &t_str)
GU::PixelCoordinate pixelCoordinate(const uint16_t resWidth, const uint16_t resHeight)
Provides a C++ wrapper around wb_vision_detection_ball.
const uint16_t & verticalRadius() const
void set_coordinate(const PixelCoordinate &t_newValue)
GU::PixelCoordinate coordinatePixelCoordinate(const uint16_t resWidth, const uint16_t resHeight)
WHITEBOARD_POSTER_STRING_CONVERSION.
VisionDetectionBall(const VisionDetectionBall &t_other)
Copy Constructor.
void set_verticalRadius(const uint16_t &t_newValue)
const uint16_t & horizontalRadius() const
uint16_t & verticalRadius()
std::string description()
void from_string(const std::string &t_str)
void set_sightingType(const enum BallOptions &t_newValue)
VisionDetectionBall(enum BallOptions t_sightingType=NoBallDetected, struct wb_pixel_coordinate t_coordinate=wb_pixel_coordinate(), uint16_t t_verticalRadius=0, uint16_t t_horizontalRadius=0)
Create a new VisionDetectionBall.
bool operator==(const VisionDetectionBall &t_other) const
const PixelCoordinate & coordinate() const
PixelCoordinate & coordinate()
uint16_t & horizontalRadius()
VisionDetectionBall(const struct wb_vision_detection_ball &t_other)
Copy Constructor.
enum BallOptions & sightingType()
void set_horizontalRadius(const uint16_t &t_newValue)
VisionDetectionBall(const std::string &t_str)
String Constructor.
VisionDetectionBall & operator=(const VisionDetectionBall &t_other)
Copy Assignment Operator.
bool operator!=(const VisionDetectionBall &t_other) const
enum BallOptions & sightingType() const
WHITEBOARD_POSTER_STRING_CONVERSION.
WHITEBOARD_POSTER_STRING_CONVERSION.
struct wb_pixel_coordinate coordinate
The pixel coordinate.
uint16_t verticalRadius
The vertical radius in pixels.
enum BallOptions sightingType
Ball detection details.
uint16_t horizontalRadius
The horizontal radius in pixels.
struct wb_vision_detection_ball * wb_vision_detection_ball_from_string(struct wb_vision_detection_ball *self, const char *str)
Convert from a string.
const char * wb_vision_detection_ball_to_string(const struct wb_vision_detection_ball *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_vision_detection_ball_description(const struct wb_vision_detection_ball *self, char *descString, size_t bufferSize)
Convert to a description string.
@ BallDetected
Ball Found.
@ NoBallDetected
No Ball Found.
#define VISION_DETECTION_BALL_DESC_BUFFER_SIZE
#define VISION_DETECTION_BALL_TO_STRING_BUFFER_SIZE