60#ifndef guWhiteboard_NaoWalkCommand_h
61#define guWhiteboard_NaoWalkCommand_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_NaoWalkCommand_DEFINED
73#define guWhiteboard_NaoWalkCommand_DEFINED
75#undef NaoWalkCommand_DEFINED
76#define NaoWalkCommand_DEFINED
90 void init(
bool t_walkEngineOn =
false, int16_t t_forward = 0, int16_t t_left = 0, int8_t t_turn = 0,
bool t_exactStepsRequested =
false, uint8_t t_speed = 100, uint8_t t_odometryResetCounter = 0,
bool t_isFast =
false,
bool t_kickWithLeftFoot =
true,
bool t_useShuffle =
true,
bool t_leftArmLimp =
false,
bool t_rightArmLimp =
false, uint8_t t_power = 0, uint8_t t_bend = 0) {
112 NaoWalkCommand(
bool t_walkEngineOn =
false, int16_t t_forward = 0, int16_t t_left = 0, int8_t t_turn = 0,
bool t_exactStepsRequested =
false, uint8_t t_speed = 100, uint8_t t_odometryResetCounter = 0,
bool t_isFast =
false,
bool t_kickWithLeftFoot =
true,
bool t_useShuffle =
true,
bool t_leftArmLimp =
false,
bool t_rightArmLimp =
false, uint8_t t_power = 0, uint8_t t_bend = 0) {
113 this->init(t_walkEngineOn, t_forward, t_left, t_turn, t_exactStepsRequested, t_speed, t_odometryResetCounter, t_isFast, t_kickWithLeftFoot, t_useShuffle, t_leftArmLimp, t_rightArmLimp, t_power, t_bend);
120 this->init(t_other.
walkEngineOn(), t_other.
forward(), t_other.
left(), t_other.
turn(), t_other.
exactStepsRequested(), t_other.
speed(), t_other.
odometryResetCounter(), t_other.
isFast(), t_other.
kickWithLeftFoot(), t_other.
useShuffle(), t_other.
leftArmLimp(), t_other.
rightArmLimp(), t_other.
power(), t_other.
bend());
127 this->init(t_other.
walkEngineOn, t_other.
forward, t_other.
left, t_other.
turn, t_other.
exactStepsRequested, t_other.
speed, t_other.
odometryResetCounter, t_other.
isFast, t_other.
kickWithLeftFoot, t_other.
useShuffle, t_other.
leftArmLimp, t_other.
rightArmLimp, t_other.
power, t_other.
bend);
134 this->init(t_other.
walkEngineOn(), t_other.
forward(), t_other.
left(), t_other.
turn(), t_other.
exactStepsRequested(), t_other.
speed(), t_other.
odometryResetCounter(), t_other.
isFast(), t_other.
kickWithLeftFoot(), t_other.
useShuffle(), t_other.
leftArmLimp(), t_other.
rightArmLimp(), t_other.
power(), t_other.
bend());
142 this->init(t_other.
walkEngineOn, t_other.
forward, t_other.
left, t_other.
turn, t_other.
exactStepsRequested, t_other.
speed, t_other.
odometryResetCounter, t_other.
isFast, t_other.
kickWithLeftFoot, t_other.
useShuffle, t_other.
leftArmLimp, t_other.
rightArmLimp, t_other.
power, t_other.
bend);
166 return !(*
this == t_other);
176 return !(*
this == t_other);
389#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
399#ifdef USE_WB_NAO_WALK_COMMAND_C_CONVERSION
402 std::string descr = buffer;
405 std::ostringstream ss;
406 ss <<
"walkEngineOn=" << (this->
walkEngineOn() ?
"true" :
"false");
408 ss <<
"forward=" <<
static_cast<signed>(this->
forward());
410 ss <<
"left=" <<
static_cast<signed>(this->
left());
412 ss <<
"turn=" <<
static_cast<signed>(this->
turn());
416 ss <<
"speed=" <<
static_cast<unsigned>(this->
speed());
420 ss <<
"isFast=" << (this->
isFast() ?
"true" :
"false");
424 ss <<
"useShuffle=" << (this->
useShuffle() ?
"true" :
"false");
426 ss <<
"leftArmLimp=" << (this->
leftArmLimp() ?
"true" :
"false");
428 ss <<
"rightArmLimp=" << (this->
rightArmLimp() ?
"true" :
"false");
430 ss <<
"power=" <<
static_cast<unsigned>(this->
power());
432 ss <<
"bend=" <<
static_cast<unsigned>(this->
bend());
438#ifdef USE_WB_NAO_WALK_COMMAND_C_CONVERSION
441 std::string toString = buffer;
444 std::ostringstream ss;
447 ss << static_cast<signed>(this->
forward());
449 ss << static_cast<signed>(this->
left());
451 ss << static_cast<signed>(this->
turn());
455 ss << static_cast<unsigned>(this->
speed());
459 ss << (this->
isFast() ?
"true" :
"false");
463 ss << (this->
useShuffle() ?
"true" :
"false");
469 ss << static_cast<unsigned>(this->
power());
471 ss << static_cast<unsigned>(this->
bend());
476#ifdef USE_WB_NAO_WALK_COMMAND_C_CONVERSION
481 char * str_cstr =
const_cast<char *
>(t_str.c_str());
482 size_t temp_length = strlen(str_cstr);
483 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
488 char* var_str = &var_str_buffer[0];
490 char* key = &key_buffer[0];
497 if (index == 0 && str_cstr[0] ==
'{') {
503 for (
int i = index; i < length; i++) {
505 if (bracecount == 0 && str_cstr[i] ==
'=') {
510 if (bracecount == 0 && isspace(str_cstr[i])) {
517 if (bracecount == 0 && str_cstr[i] ==
',') {
521 if (str_cstr[i] ==
'{') {
525 if (str_cstr[i] ==
'}') {
527 if (bracecount < 0) {
532 if (i == length - 1) {
536 if (endKey >= startKey && endKey - startKey < length) {
537 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
538 key[(endKey - startKey) + 1] = 0;
542 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
543 var_str[(index - startVar) + 1] = 0;
549 if (strlen(key) > 0) {
550 if (0 == strcmp(
"walkEngineOn", key)) {
552 }
else if (0 == strcmp(
"forward", key)) {
554 }
else if (0 == strcmp(
"left", key)) {
556 }
else if (0 == strcmp(
"turn", key)) {
558 }
else if (0 == strcmp(
"exactStepsRequested", key)) {
560 }
else if (0 == strcmp(
"speed", key)) {
562 }
else if (0 == strcmp(
"odometryResetCounter", key)) {
564 }
else if (0 == strcmp(
"isFast", key)) {
566 }
else if (0 == strcmp(
"kickWithLeftFoot", key)) {
568 }
else if (0 == strcmp(
"useShuffle", key)) {
570 }
else if (0 == strcmp(
"leftArmLimp", key)) {
572 }
else if (0 == strcmp(
"rightArmLimp", key)) {
574 }
else if (0 == strcmp(
"power", key)) {
576 }
else if (0 == strcmp(
"bend", key)) {
586 this->
set_walkEngineOn(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
591 this->
set_forward(
static_cast<int16_t
>(atoi(var_str)));
596 this->
set_left(
static_cast<int16_t
>(atoi(var_str)));
601 this->
set_turn(
static_cast<int8_t
>(atoi(var_str)));
611 this->
set_speed(
static_cast<uint8_t
>(atoi(var_str)));
621 this->
set_isFast(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
631 this->
set_useShuffle(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
636 this->
set_leftArmLimp(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
641 this->
set_rightArmLimp(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
646 this->
set_power(
static_cast<uint8_t
>(atoi(var_str)));
651 this->
set_bend(
static_cast<uint8_t
>(atoi(var_str)));
658 }
while(index < length);
Provides a C++ wrapper around wb_nao_walk_command.
void set_left(const int16_t &t_newValue)
NaoWalkCommand(const std::string &t_str)
String Constructor.
bool & exactStepsRequested()
void set_kickWithLeftFoot(const bool &t_newValue)
static NaoWalkCommand standWithStiffness()
Convenience function to make the nao stand in the 'walk' position (slightly crouched),...
bool operator!=(const NaoWalkCommand &t_other) const
void set_forward(const int16_t &t_newValue)
const bool & useShuffle() const
bool operator==(const NaoWalkCommand &t_other) const
static NaoWalkCommand disconnectWalk()
Convenience function to disconnect the walk engine from the DCM.
const bool & isFast() const
static NaoWalkCommand walk(int16_t t_forward, int16_t t_left, int8_t t_turn)
WHITEBOARD_POSTER_STRING_CONVERSION.
void set_rightArmLimp(const bool &t_newValue)
const bool & walkEngineOn() const
const int16_t & left() const
void set_leftArmLimp(const bool &t_newValue)
const bool & leftArmLimp() const
std::string description()
const uint8_t & bend() const
void set_speed(const uint8_t &t_newValue)
void set_exactStepsRequested(const bool &t_newValue)
const bool & rightArmLimp() const
const uint8_t & speed() const
void set_useShuffle(const bool &t_newValue)
NaoWalkCommand & operator=(const NaoWalkCommand &t_other)
Copy Assignment Operator.
void set_walkEngineOn(const bool &t_newValue)
const int8_t & turn() const
const uint8_t & odometryResetCounter() const
NaoWalkCommand(const struct wb_nao_walk_command &t_other)
Copy Constructor.
void set_power(const uint8_t &t_newValue)
static NaoWalkCommand walkPrecisely(int16_t t_forward, int16_t t_left, int8_t t_turn)
Convenience function to make the nao walk, with precise step distances.
void set_turn(const int8_t &t_newValue)
const int16_t & forward() const
static NaoWalkCommand stop()
Convenience function to make the nao stop walking.
void set_odometryResetCounter(const uint8_t &t_newValue)
const uint8_t & power() const
void set_bend(const uint8_t &t_newValue)
static NaoWalkCommand standWithMinimalStiffness()
Convenience function to make the nao stand in the 'STANDING' position, upright with minimal stiffness...
uint8_t & odometryResetCounter()
NaoWalkCommand(bool t_walkEngineOn=false, int16_t t_forward=0, int16_t t_left=0, int8_t t_turn=0, bool t_exactStepsRequested=false, uint8_t t_speed=100, uint8_t t_odometryResetCounter=0, bool t_isFast=false, bool t_kickWithLeftFoot=true, bool t_useShuffle=true, bool t_leftArmLimp=false, bool t_rightArmLimp=false, uint8_t t_power=0, uint8_t t_bend=0)
Create a new NaoWalkCommand.
bool & kickWithLeftFoot()
const bool & exactStepsRequested() const
const bool & kickWithLeftFoot() const
NaoWalkCommand(const NaoWalkCommand &t_other)
Copy Constructor.
void set_isFast(const bool &t_newValue)
void from_string(const std::string &t_str)
WHITEBOARD_POSTER_STRING_CONVERSION.
int8_t turn
[-85 - 85] step-size(mm) per second, limited to +/- 85deg/step
uint8_t power
[0 - 100] stiffness, auto set to minimum needed values.
uint8_t speed
[0 - 100] modifier for forward etc.
bool leftArmLimp
lower stiffness in the arms when walking, allows the arm to move a little more.
bool kickWithLeftFoot
which foot to use for kicking
bool rightArmLimp
lower stiffness in the arms when walking, allows the arm to move a little more.
uint8_t odometryResetCounter
Odometry will reset any time this is changed or incremented.
int16_t forward
[-300 - 300] step-size(mm) per second, limited to +/- 300mm/step
bool useShuffle
limits the step height so the robot 'shuffles' instead of taking larger steps.
bool exactStepsRequested
No ratcheting, no speed 'buildup', just full step sizes.
uint8_t bend
[0 - 1] controls what the robot does when stopped, 0 == STAND and lower stiffness,...
bool walkEngineOn
connects the dcm callbacks.
int16_t left
[-200 - 200] step-size(mm) per second, limited to +/- 200mm/step
const char * wb_nao_walk_command_to_string(const struct wb_nao_walk_command *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_nao_walk_command_description(const struct wb_nao_walk_command *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_nao_walk_command * wb_nao_walk_command_from_string(struct wb_nao_walk_command *self, const char *str)
Convert from a string.
#define NAOWALKCOMMAND_TO_STRING_BUFFER_SIZE
#define NAOWALKCOMMAND_DESC_BUFFER_SIZE