9#ifndef Giraff_MainSerialInterface_DEFINED
10#define Giraff_MainSerialInterface_DEFINED
14#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
15#pragma clang diagnostic push
16#pragma clang diagnostic ignored "-Wdeprecated"
21#pragma clang diagnostic pop
54#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
62#define PARSER(s, c, p) if (k.compare(s) == 0) { set_##c ( p ); continue; }
63#define SV std::vector<std::string>
64#define COMP(v, s) v.compare(0, 2, s) == 0
65#define IS_HEX(v) COMP(v, "F*") || COMP(v, "I*")
67#define READ_HEX(v) htonl(strtol(v.c_str()+2, NULL, 16))
68#define PARSE_HEX_FLOAT(v) static_cast<float>(READ_HEX(v))
69#define PARSE_HEX_INT32(v) static_cast<int32_t>(READ_HEX(v))
70#define PARSE_HEX_INT16(v) static_cast<int16_t>(READ_HEX(v))
71#define PARSE_HEX_INT8(v) static_cast<int8_t>(READ_HEX(v))
73#define PARSE_FLOAT IS_HEX(v) ? PARSE_HEX_FLOAT(v) : static_cast<float>(atof(v.c_str()))
74#define PARSE_INT16 IS_HEX(v) ? PARSE_HEX_INT16(v) : static_cast<int16_t>(atoi(v.c_str()))
75#define PARSE_INT32 IS_HEX(v) ? PARSE_HEX_INT32(v) : static_cast<int32_t>(atoi(v.c_str()))
76#define PARSE_INT8 IS_HEX(v) ? PARSE_HEX_INT8(v) : static_cast<uint8_t>(atoi(v.c_str()))
82 SV sn = components_of_string_separated(str,
DELIMITER,
true);
83 for(
size_t i = 0; i < sn.size(); i++)
85 SV kv = components_of_string_separated(sn.at(i),
SEP,
true);
88 fprintf(stderr,
"parse error\n");
91 std::string k = kv.at(0);
92 std::string v = kv.at(1);
137 std::stringstream ss;
139 << velocity() <<
"velocity : , "
140 << movement_type() <<
"movement_type : , "
141 << acceleration() <<
"acceleration : , "
142 << position() <<
"position : , "
143 << coord_type() <<
"coord_type : , "
144 << head_angle() <<
"head_angle : , "
145 << max_gear_ratio() <<
"max_gear_ratio : , "
146 << gear_ratio_increments() <<
"gear_ratio_increments : , "
147 << gear_ratio_slowdown_dist() <<
"gear_ratio_slowdown_dist : , "
148 << current_gear_ratio() <<
"current_gear_ratio : , "
149 << red_button_presses() <<
"red_button_presses : , "
150 << blue_button_presses() <<
"blue_button_presses : , "
151 << dial_increments() <<
"dial_increments : , "
152 << left_motor_encoder_ticks() <<
"left_motor_encoder_ticks : , "
153 << right_motor_encoder_ticks() <<
"right_motor_encoder_ticks : , "
154 << head_motor_encoder_ticks() <<
"head_motor_encoder_ticks : ";
Serial interface for the main giraff board.
Giraff_MainSerialInterface(const std::string &str)
string constructor (see from_string() below)
void from_string(const std::string &str)
parse class properties from a string
std::string description() const
pretty print method for showing the current property values
Giraff_MainSerialInterface()
default constructor
Serial interface for the main giraff board.
Giraff_CoordType
Controls when position uses relative and absolute distances (absolute is based on odometry and is res...
Giraff_MovementType
/file wb_giraff_main_serial.h