# Option approach-ball Approaches the close ball Parameters of that option:
Parameter | Measure | Range | Description
approach-ball.look-at-ball-distance | int | 0.. | The distance when the robot looks to the ball only
approach-ball.slow-down-distance | int | 0.. | The distance when the robot slows down
approach-ball.slow-speed | int | 1.. | The speed for the state look-at-ball
approach-ball.y-offset | mm | -1000...1000 | The y offset the robot is approaching the ball with.
## State Machine ## State search-auto
If that state is active,
> | The option approach-ball-set-walk-speed is executed. Parameters:
| approach-ball-set-walk-speed.slow-down-distance | = | ::approach-ball.slow-down-distance ;
| approach-ball-set-walk-speed.slow-speed | = | ::approach-ball.slow-speed ;
| approach-ball-set-walk-speed.y-offset | = | ::approach-ball.y-offset ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-auto
The decision tree:
Pseudo code of the decision tree:
if ( | ball.time-since-last-seen > 1300 | ) | // ball not seen for 1300 ms
{
transition-to-state(ball-not-seen);
}
else if ( | ball.seen.distance < (::approach-ball.look-at-ball-distance - 25) | ) | // search for ball
{
transition-to-state(search-for-ball);
}
else
{
transition-to-state(search-auto);
}
## State search-for-ball
If that state is active,
> | The option approach-ball-set-walk-speed is executed. Parameters:
| approach-ball-set-walk-speed.slow-down-distance | = | ::approach-ball.slow-down-distance ;
| approach-ball-set-walk-speed.slow-speed | = | ::approach-ball.slow-speed ;
| approach-ball-set-walk-speed.y-offset | = | ::approach-ball.y-offset ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
The decision tree:
Pseudo code of the decision tree:
if ( | ball.time-since-last-seen > 400 | ) | // ball not seen for 400 ms
{
transition-to-state(ball-not-seen);
}
else if ( | ball.seen.distance > (::approach-ball.look-at-ball-distance + 25) | ) | // walk fast and search auto
{
transition-to-state(search-auto);
}
else
{
transition-to-state(search-for-ball);
}
## State ball-just-found
If that state is active,
> | The option approach-ball-set-walk-speed is executed. Parameters:
| approach-ball-set-walk-speed.slow-down-distance | = | ::approach-ball.slow-down-distance ;
| approach-ball-set-walk-speed.slow-speed | = | ::approach-ball.slow-speed ;
| approach-ball-set-walk-speed.y-offset | = | ::approach-ball.y-offset ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
The decision tree:
Pseudo code of the decision tree:
if ( | ball.time-since-last-seen > 500 | ) | // ball not seen for 400 ms
{
transition-to-state(ball-not-seen);
}
else if ( | time-of-state-execution > 2000 | ) | // state-runs-long-enough
{
transition-to-state(search-for-ball);
}
else
{
transition-to-state(ball-just-found);
}
## State ball-not-seen
If that state is active,
> | The option turn-for-ball is executed.
The decision tree:
Pseudo code of the decision tree:
if ( | ball.just-seen | ) | // ball seen
{
transition-to-state(ball-just-found);
}
else
{
transition-to-state(ball-not-seen);
}
## State draw-back-left
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | -150 ;
| walk.speed-y | = | 75 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-auto
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 2000 | ) | // state running long enough
{
transition-to-state(search-for-ball);
}
else
{
transition-to-state(draw-back-left);
}
## State draw-back-right
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | -150 ;
| walk.speed-y | = | -75 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-auto
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 2000 | ) | // state running long enough
{
transition-to-state(search-for-ball);
}
else
{
transition-to-state(draw-back-right);
}