60#ifndef guWhiteboard_NaoSonarProtectedWalkCommand_h
61#define guWhiteboard_NaoSonarProtectedWalkCommand_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_NaoSonarProtectedWalkCommand_DEFINED
73#define guWhiteboard_NaoSonarProtectedWalkCommand_DEFINED
75#undef NaoSonarProtectedWalkCommand_DEFINED
76#define NaoSonarProtectedWalkCommand_DEFINED
92 void init(
bool t_walkEngineOn =
false, int16_t t_forward = 0, int16_t t_left = 0, int8_t t_turn = 0, int8_t t_priority = 1,
bool t_exactStepsRequested =
false, uint8_t t_speed = 100,
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_odometryResetCounter = 0, uint8_t t_bend = 0) {
115 NaoSonarProtectedWalkCommand(
bool t_walkEngineOn =
false, int16_t t_forward = 0, int16_t t_left = 0, int8_t t_turn = 0, int8_t t_priority = 1,
bool t_exactStepsRequested =
false, uint8_t t_speed = 100,
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_odometryResetCounter = 0, uint8_t t_bend = 0) {
116 this->init(t_walkEngineOn, t_forward, t_left, t_turn, t_priority, t_exactStepsRequested, t_speed, t_isFast, t_kickWithLeftFoot, t_useShuffle, t_leftArmLimp, t_rightArmLimp, t_power, t_odometryResetCounter, t_bend);
123 this->init(t_other.
walkEngineOn(), t_other.
forward(), t_other.
left(), t_other.
turn(), t_other.
priority(), t_other.
exactStepsRequested(), t_other.
speed(), t_other.
isFast(), t_other.
kickWithLeftFoot(), t_other.
useShuffle(), t_other.
leftArmLimp(), t_other.
rightArmLimp(), t_other.
power(), t_other.
odometryResetCounter(), t_other.
bend());
130 this->init(t_other.
walkEngineOn, t_other.
forward, t_other.
left, t_other.
turn, t_other.
priority, t_other.
exactStepsRequested, t_other.
speed, t_other.
isFast, t_other.
kickWithLeftFoot, t_other.
useShuffle, t_other.
leftArmLimp, t_other.
rightArmLimp, t_other.
power, t_other.
odometryResetCounter, t_other.
bend);
137 this->init(t_other.
walkEngineOn(), t_other.
forward(), t_other.
left(), t_other.
turn(), t_other.
priority(), t_other.
exactStepsRequested(), t_other.
speed(), t_other.
isFast(), t_other.
kickWithLeftFoot(), t_other.
useShuffle(), t_other.
leftArmLimp(), t_other.
rightArmLimp(), t_other.
power(), t_other.
odometryResetCounter(), t_other.
bend());
145 this->init(t_other.
walkEngineOn, t_other.
forward, t_other.
left, t_other.
turn, t_other.
priority, t_other.
exactStepsRequested, t_other.
speed, t_other.
isFast, t_other.
kickWithLeftFoot, t_other.
useShuffle, t_other.
leftArmLimp, t_other.
rightArmLimp, t_other.
power, t_other.
odometryResetCounter, t_other.
bend);
170 return !(*
this == t_other);
180 return !(*
this == t_other);
408#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
418#ifdef USE_WB_NAO_SONAR_PROTECTED_WALK_COMMAND_C_CONVERSION
421 std::string descr = buffer;
424 std::ostringstream ss;
425 ss <<
"walkEngineOn=" << (this->
walkEngineOn() ?
"true" :
"false");
427 ss <<
"forward=" <<
static_cast<signed>(this->
forward());
429 ss <<
"left=" <<
static_cast<signed>(this->
left());
431 ss <<
"turn=" <<
static_cast<signed>(this->
turn());
433 ss <<
"priority=" <<
static_cast<signed>(this->
priority());
437 ss <<
"speed=" <<
static_cast<unsigned>(this->
speed());
439 ss <<
"isFast=" << (this->
isFast() ?
"true" :
"false");
443 ss <<
"useShuffle=" << (this->
useShuffle() ?
"true" :
"false");
445 ss <<
"leftArmLimp=" << (this->
leftArmLimp() ?
"true" :
"false");
447 ss <<
"rightArmLimp=" << (this->
rightArmLimp() ?
"true" :
"false");
449 ss <<
"power=" <<
static_cast<unsigned>(this->
power());
453 ss <<
"bend=" <<
static_cast<unsigned>(this->
bend());
459#ifdef USE_WB_NAO_SONAR_PROTECTED_WALK_COMMAND_C_CONVERSION
462 std::string toString = buffer;
465 std::ostringstream ss;
468 ss << static_cast<signed>(this->
forward());
470 ss << static_cast<signed>(this->
left());
472 ss << static_cast<signed>(this->
turn());
474 ss << static_cast<signed>(this->
priority());
478 ss << static_cast<unsigned>(this->
speed());
480 ss << (this->
isFast() ?
"true" :
"false");
484 ss << (this->
useShuffle() ?
"true" :
"false");
490 ss << static_cast<unsigned>(this->
power());
494 ss << static_cast<unsigned>(this->
bend());
499#ifdef USE_WB_NAO_SONAR_PROTECTED_WALK_COMMAND_C_CONVERSION
504 char * str_cstr =
const_cast<char *
>(t_str.c_str());
505 size_t temp_length = strlen(str_cstr);
506 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
511 char* var_str = &var_str_buffer[0];
513 char* key = &key_buffer[0];
520 if (index == 0 && str_cstr[0] ==
'{') {
526 for (
int i = index; i < length; i++) {
528 if (bracecount == 0 && str_cstr[i] ==
'=') {
533 if (bracecount == 0 && isspace(str_cstr[i])) {
540 if (bracecount == 0 && str_cstr[i] ==
',') {
544 if (str_cstr[i] ==
'{') {
548 if (str_cstr[i] ==
'}') {
550 if (bracecount < 0) {
555 if (i == length - 1) {
559 if (endKey >= startKey && endKey - startKey < length) {
560 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
561 key[(endKey - startKey) + 1] = 0;
565 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
566 var_str[(index - startVar) + 1] = 0;
572 if (strlen(key) > 0) {
573 if (0 == strcmp(
"walkEngineOn", key)) {
575 }
else if (0 == strcmp(
"forward", key)) {
577 }
else if (0 == strcmp(
"left", key)) {
579 }
else if (0 == strcmp(
"turn", key)) {
581 }
else if (0 == strcmp(
"priority", key)) {
583 }
else if (0 == strcmp(
"exactStepsRequested", key)) {
585 }
else if (0 == strcmp(
"speed", key)) {
587 }
else if (0 == strcmp(
"isFast", key)) {
589 }
else if (0 == strcmp(
"kickWithLeftFoot", key)) {
591 }
else if (0 == strcmp(
"useShuffle", key)) {
593 }
else if (0 == strcmp(
"leftArmLimp", key)) {
595 }
else if (0 == strcmp(
"rightArmLimp", key)) {
597 }
else if (0 == strcmp(
"power", key)) {
599 }
else if (0 == strcmp(
"odometryResetCounter", key)) {
601 }
else if (0 == strcmp(
"bend", key)) {
611 this->
set_walkEngineOn(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
616 this->
set_forward(
static_cast<int16_t
>(atoi(var_str)));
621 this->
set_left(
static_cast<int16_t
>(atoi(var_str)));
626 this->
set_turn(
static_cast<int8_t
>(atoi(var_str)));
641 this->
set_speed(
static_cast<uint8_t
>(atoi(var_str)));
646 this->
set_isFast(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
656 this->
set_useShuffle(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
661 this->
set_leftArmLimp(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
666 this->
set_rightArmLimp(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
671 this->
set_power(
static_cast<uint8_t
>(atoi(var_str)));
681 this->
set_bend(
static_cast<uint8_t
>(atoi(var_str)));
688 }
while(index < length);
Provides a C++ wrapper around wb_nao_sonar_protected_walk_command.
const int8_t & turn() const
const bool & isFast() const
void set_walkEngineOn(const bool &t_newValue)
NaoSonarProtectedWalkCommand(const struct wb_nao_sonar_protected_walk_command &t_other)
Copy Constructor.
static NaoSonarProtectedWalkCommand disconnectWalk()
Convenience function to disconnect the walk engine from the DCM.
const bool & leftArmLimp() const
void set_leftArmLimp(const bool &t_newValue)
const bool & exactStepsRequested() const
const bool & walkEngineOn() const
void set_kickWithLeftFoot(const bool &t_newValue)
void set_turn(const int8_t &t_newValue)
const bool & kickWithLeftFoot() const
NaoSonarProtectedWalkCommand & operator=(const NaoSonarProtectedWalkCommand &t_other)
Copy Assignment Operator.
void set_left(const int16_t &t_newValue)
void set_bend(const uint8_t &t_newValue)
bool & kickWithLeftFoot()
void set_power(const uint8_t &t_newValue)
static NaoSonarProtectedWalkCommand stop()
Convenience function to make the nao stop walking.
const bool & rightArmLimp() const
bool & exactStepsRequested()
static NaoSonarProtectedWalkCommand standWithMinimalStiffness()
Convenience function to make the nao stand in the 'STANDING' position, upright with minimal stiffness...
const uint8_t & power() const
static NaoSonarProtectedWalkCommand standWithStiffness()
Convenience function to make the nao stand in the 'walk' position (slightly crouched),...
void set_useShuffle(const bool &t_newValue)
NaoSonarProtectedWalkCommand(bool t_walkEngineOn=false, int16_t t_forward=0, int16_t t_left=0, int8_t t_turn=0, int8_t t_priority=1, bool t_exactStepsRequested=false, uint8_t t_speed=100, 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_odometryResetCounter=0, uint8_t t_bend=0)
Create a new NaoSonarProtectedWalkCommand.
void set_isFast(const bool &t_newValue)
const int8_t & priority() const
const int16_t & forward() const
void set_priority(const int8_t &t_newValue)
bool operator!=(const NaoSonarProtectedWalkCommand &t_other) const
static NaoSonarProtectedWalkCommand walkProtectedPrecisely(int8_t t_priority, 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_speed(const uint8_t &t_newValue)
const uint8_t & bend() const
const uint8_t & speed() const
const int16_t & left() const
bool operator==(const NaoSonarProtectedWalkCommand &t_other) const
uint8_t & odometryResetCounter()
void set_exactStepsRequested(const bool &t_newValue)
void set_forward(const int16_t &t_newValue)
const bool & useShuffle() const
static NaoSonarProtectedWalkCommand walkProtected(int8_t t_priority, int16_t t_forward, int16_t t_left, int8_t t_turn)
WHITEBOARD_POSTER_STRING_CONVERSION.
std::string description()
void set_rightArmLimp(const bool &t_newValue)
void set_odometryResetCounter(const uint8_t &t_newValue)
void from_string(const std::string &t_str)
const uint8_t & odometryResetCounter() const
NaoSonarProtectedWalkCommand(const std::string &t_str)
String Constructor.
NaoSonarProtectedWalkCommand(const NaoSonarProtectedWalkCommand &t_other)
Copy Constructor.
WHITEBOARD_POSTER_STRING_CONVERSION.
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.
bool walkEngineOn
connects the dcm callbacks.
bool leftArmLimp
lower stiffness in the arms when walking, allows the arm to move a little more.
int8_t priority
subsumption priority 1: unprotected walk, command unmodified.
bool useShuffle
limits the step height so the robot 'shuffles' instead of taking larger steps.
int16_t left
[-200 - 200] step-size(mm) per second, limited to +/- 200mm/step
uint8_t power
[0 - 100] stiffness, auto set to minimum needed values.
bool exactStepsRequested
No ratcheting, no speed 'buildup', just full step sizes.
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
uint8_t bend
[0 - 1] controls what the robot does when stopped, 0 == STAND and lower stiffness,...
int8_t turn
[-85 - 85] step-size(mm) per second, limited to +/- 85deg/step
uint8_t speed
[0 - 100] modifier for forward etc.
struct wb_nao_sonar_protected_walk_command * wb_nao_sonar_protected_walk_command_from_string(struct wb_nao_sonar_protected_walk_command *self, const char *str)
Convert from a string.
const char * wb_nao_sonar_protected_walk_command_to_string(const struct wb_nao_sonar_protected_walk_command *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_nao_sonar_protected_walk_command_description(const struct wb_nao_sonar_protected_walk_command *self, char *descString, size_t bufferSize)
Convert to a description string.
#define NAO_SONAR_PROTECTED_WALK_COMMAND_DESC_BUFFER_SIZE
#define NAO_SONAR_PROTECTED_WALK_COMMAND_TO_STRING_BUFFER_SIZE