# Option obstacle-avoidance-challenge03 ## State Machine ## State stand-still
If that state is active,
> | The basic behavior stand is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.directed-scan-for-obstacles
The decision tree:
Pseudo code of the decision tree:
if ( | robot-state.head-button-pressed-short | ) | //
{
transition-to-state(move-to-other-half-and-avoid-obstacles);
}
else
{
transition-to-state(stand-still);
}
## State localize
If that state is active,
> | The basic behavior stand is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.directed-scan-for-obstacles
The decision tree:
Pseudo code of the decision tree:
if ( | robot-state.any-back-button-pressed-short-and-released | ) | //
{
transition-to-state(stand-still);
}
else if ( | time-of-state-execution > 5000 | ) | // waited too long, turn!
{
transition-to-state(turn);
}
else if ( | robot-pose.position-standard-deviation > 350 | ) | // not localized
{
transition-to-state(localize);
}
else
{
transition-to-state(move-to-other-half-and-avoid-obstacles);
}
## State turn
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | 0 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 45 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.directed-scan-for-obstacles
The decision tree:
Pseudo code of the decision tree:
if ( | robot-state.any-back-button-pressed-short-and-released | ) | //
{
transition-to-state(stand-still);
}
else if ( | time-of-state-execution > 3000 | ) | // the robot turned for 180 degrees
{
transition-to-state(localize);
}
else
{
transition-to-state(turn);
}
## State move-to-other-half-and-avoid-obstacles
If that state is active,
> | The basic behavior go-to-point-and-avoid-obstacles is executed. Parameters:
| go-to-point-and-avoid-obstacles.x | = | 2300 ;
| go-to-point-and-avoid-obstacles.y | = | 0 ;
| go-to-point-and-avoid-obstacles.max-speed | = | 600 ;
| go-to-point-and-avoid-obstacles.avoidance-level | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.directed-scan-for-obstacles
The decision tree:
Pseudo code of the decision tree:
if ( | robot-state.any-back-button-pressed-short-and-released | ) | //
{
transition-to-state(stand-still);
}
else if ( | robot-pose.position-standard-deviation > 700 | ) | //
{
transition-to-state(localize);
}
else
{
transition-to-state(move-to-other-half-and-avoid-obstacles);
}