60#ifndef guWhiteboard_MachineFilteredLines_h
61#define guWhiteboard_MachineFilteredLines_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_MachineFilteredLines_DEFINED
73#define guWhiteboard_MachineFilteredLines_DEFINED
75#undef MachineFilteredLines_DEFINED
76#define MachineFilteredLines_DEFINED
79#include <SimpleShapes.h>
93 void init(uint8_t t_numberOfSightings = 0,
const struct wb_line_sighting t_sightings[8] = NULLPTR) {
95 if (t_sightings != NULLPTR) {
109 this->init(t_numberOfSightings, t_sightings);
148 for (
int sightings_0_index = 0; sightings_0_index < 8; sightings_0_index++)
157 return !(*
this == t_other);
167 return !(*
this == t_other);
215#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
225#ifdef USE_WB_MACHINE_FILTERED_LINES_C_CONVERSION
228 std::string descr = buffer;
231 std::ostringstream ss;
234 bool sightings_first =
true;
238 sightings_first =
false;
246#ifdef USE_WB_MACHINE_FILTERED_LINES_C_CONVERSION
249 std::string toString = buffer;
252 std::ostringstream ss;
255 bool sightings_first =
true;
259 sightings_first =
false;
266#ifdef USE_WB_MACHINE_FILTERED_LINES_C_CONVERSION
271 char * str_cstr =
const_cast<char *
>(t_str.c_str());
272 size_t temp_length = strlen(str_cstr);
273 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
278 char* var_str = &var_str_buffer[0];
280 char* key = &key_buffer[0];
288 if (index == 0 && str_cstr[0] ==
'{') {
294 for (
int i = index; i < length; i++) {
296 if (bracecount == 0 && str_cstr[i] ==
'=') {
301 if (bracecount == 0 && isspace(str_cstr[i])) {
308 if (bracecount == 0 && str_cstr[i] ==
',') {
312 if (str_cstr[i] ==
'{') {
314 if (bracecount == 1) {
319 if (str_cstr[i] ==
'}') {
321 if (bracecount < 0) {
326 if (i == length - 1) {
330 if (endKey >= startKey && endKey - startKey < length) {
331 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
332 key[(endKey - startKey) + 1] = 0;
336 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
337 var_str[(index - startVar) + 1] = 0;
343 if (strlen(key) > 0) {
344 if (0 == strcmp(
"numberOfSightings", key)) {
346 }
else if (0 == strcmp(
"sightings", key)) {
361 int restartIndex = index;
362 index = lastBrace + 1;
368 for (
int i = index; i < length; i++) {
370 if (bracecount == 0 && str_cstr[i] ==
'=') {
375 if (bracecount == 0 && isspace(str_cstr[i])) {
382 if (bracecount == 0 && str_cstr[i] ==
',') {
386 if (str_cstr[i] ==
'{') {
390 if (str_cstr[i] ==
'}') {
392 if (bracecount < 0) {
397 if (i == length - 1) {
401 if (endKey >= startKey && endKey - startKey < length) {
402 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
403 key[(endKey - startKey) + 1] = 0;
407 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
408 var_str[(index - startVar) + 1] = 0;
419 index = restartIndex;
426 }
while(index < length);
449 short dist = line.
simpleLine().distanceToLineSegment();
450 if(dist < d || index < 0) {
Provides a C++ wrapper around wb_line_sighting.
SimpleLine simpleLine()
WHITEBOARD_POSTER_STRING_CONVERSION.
enum LineSightingType & sightingType()
void from_string(const std::string &t_str)
Provides a C++ wrapper around wb_machine_filtered_lines.
const LineSighting * sightings() const
bool operator==(const MachineFilteredLines &t_other) const
MachineFilteredLines(const struct wb_machine_filtered_lines &t_other)
Copy Constructor.
void set_sightings(const LineSighting &t_newValue, int t_i)
void from_string(const std::string &t_str)
MachineFilteredLines(const std::string &t_str)
String Constructor.
void set_numberOfSightings(const uint8_t &t_newValue)
std::string description()
void set_sightings(const LineSighting *t_newValue)
MachineFilteredLines(const MachineFilteredLines &t_other)
Copy Constructor.
LineSighting & sightings(int t_i)
const uint8_t & numberOfSightings() const
const LineSighting & sightings(int t_i) const
MachineFilteredLines & operator=(const MachineFilteredLines &t_other)
Copy Assignment Operator.
MachineFilteredLines(uint8_t t_numberOfSightings=0, const struct wb_line_sighting t_sightings[8]=NULLPTR)
Create a new MachineFilteredLines.
int firstSighting(LineSightingType sightingType)
WHITEBOARD_POSTER_STRING_CONVERSION.
bool operator!=(const MachineFilteredLines &t_other) const
size_t sightings_size() const
uint8_t & numberOfSightings()
WHITEBOARD_POSTER_STRING_CONVERSION.
enum LineSightingType sightingType
The type of sighting.
Results of the KalmanFilter machines for lines.
struct wb_line_sighting sightings[8]
All sightings.
uint8_t numberOfSightings
The number of sightings in sightings.
@ HorizonLineSightingType
struct wb_machine_filtered_lines * wb_machine_filtered_lines_from_string(struct wb_machine_filtered_lines *self, const char *str)
Convert from a string.
const char * wb_machine_filtered_lines_to_string(const struct wb_machine_filtered_lines *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_machine_filtered_lines_description(const struct wb_machine_filtered_lines *self, char *descString, size_t bufferSize)
Convert to a description string.
#define MACHINE_FILTERED_LINES_SIGHTINGS_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.
#define MACHINE_FILTERED_LINES_DESC_BUFFER_SIZE
#define MACHINE_FILTERED_LINES_TO_STRING_BUFFER_SIZE