60#ifndef guWhiteboard_Odometry_h
61#define guWhiteboard_Odometry_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
73#undef guWhiteboard_Odometry_DEFINED
74#define guWhiteboard_Odometry_DEFINED
76#undef Odometry_DEFINED
77#define Odometry_DEFINED
91 void init(
float t_forward = 0.0f,
float t_left = 0.0f,
float t_turn = 0.0f) {
102 Odometry(
float t_forward = 0.0f,
float t_left = 0.0f,
float t_turn = 0.0f) {
103 this->init(t_forward, t_left, t_turn);
139 && fabsf(
left() - t_other.
left()) < FLT_EPSILON
140 && fabsf(
turn() - t_other.
turn()) < FLT_EPSILON;
145 return !(*
this == t_other);
155 return !(*
this == t_other);
203#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
213#ifdef USE_WB_ODOMETRY_C_CONVERSION
216 std::string descr = buffer;
219 std::ostringstream ss;
220 ss <<
"forward=" << this->
forward();
222 ss <<
"left=" << this->
left();
224 ss <<
"turn=" << this->
turn();
230#ifdef USE_WB_ODOMETRY_C_CONVERSION
233 std::string toString = buffer;
236 std::ostringstream ss;
246#ifdef USE_WB_ODOMETRY_C_CONVERSION
251 char * str_cstr =
const_cast<char *
>(t_str.c_str());
252 size_t temp_length = strlen(str_cstr);
253 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
258 char* var_str = &var_str_buffer[0];
260 char* key = &key_buffer[0];
267 if (index == 0 && str_cstr[0] ==
'{') {
273 for (
int i = index; i < length; i++) {
275 if (bracecount == 0 && str_cstr[i] ==
'=') {
280 if (bracecount == 0 && isspace(str_cstr[i])) {
287 if (bracecount == 0 && str_cstr[i] ==
',') {
291 if (str_cstr[i] ==
'{') {
295 if (str_cstr[i] ==
'}') {
297 if (bracecount < 0) {
302 if (i == length - 1) {
306 if (endKey >= startKey && endKey - startKey < length) {
307 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
308 key[(endKey - startKey) + 1] = 0;
312 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
313 var_str[(index - startVar) + 1] = 0;
319 if (strlen(key) > 0) {
320 if (0 == strcmp(
"forward", key)) {
322 }
else if (0 == strcmp(
"left", key)) {
324 }
else if (0 == strcmp(
"turn", key)) {
334 this->
set_forward(
static_cast<float>(atof(var_str)));
339 this->
set_left(
static_cast<float>(atof(var_str)));
344 this->
set_turn(
static_cast<float>(atof(var_str)));
351 }
while(index < length);
Provides a C++ wrapper around wb_odometry.
void set_left(const float &t_newValue)
std::string description()
Odometry(float t_forward=0.0f, float t_left=0.0f, float t_turn=0.0f)
Create a new Odometry.
void clear()
WHITEBOARD_POSTER_STRING_CONVERSION.
const float & forward() const
Odometry & operator=(const Odometry &t_other)
Copy Assignment Operator.
bool operator==(const Odometry &t_other) const
const float & turn() const
const float & left() const
void from_string(const std::string &t_str)
Odometry(const struct wb_odometry &t_other)
Copy Constructor.
Odometry operator-(const Odometry &a) const
void set_turn(const float &t_newValue)
Odometry(const std::string &t_str)
String Constructor.
void set_forward(const float &t_newValue)
bool operator!=(const Odometry &t_other) const
Odometry(const Odometry &t_other)
Copy Constructor.
Odometry operator+(const Odometry &a) const
WHITEBOARD_POSTER_STRING_CONVERSION.
float left
/< sideways, mm/s
float turn
/< rotation, deg/s
float forward
/< forward, mm/s
const char * wb_odometry_to_string(const struct wb_odometry *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_odometry_description(const struct wb_odometry *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_odometry * wb_odometry_from_string(struct wb_odometry *self, const char *str)
Convert from a string.
#define ODOMETRY_DESC_BUFFER_SIZE
#define ODOMETRY_TO_STRING_BUFFER_SIZE