# Option grab-ball-with-vlc2-head Grabs the ball with the head ## State Machine ## State approach-ball
If that state is active,
> | The option approach-ball is executed. Parameters:
| approach-ball.look-at-ball-distance | = | 500 ;
| approach-ball.slow-down-distance | = | ( ball.play-ball-precisely ? 380 : 350 ) ;
| approach-ball.slow-speed | = | ( ball.play-ball-precisely ? 100 : 170 ) ;
> | 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-consecutively < 200 | )
&& |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| ) | // ball distance greater than 200 mm
{
transition-to-state(approach-ball);
}
else
{
if ( | time-of-state-execution < 300 | ) | // state running less than 300 ms
{
transition-to-state(approach-ball);
}
else if ( |
( | ball.time-since-last-seen-consecutively < 300 | )
&& |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance < ( ball.play-ball-precisely ? 90 : 180 ) | )
&& |
( | ball.seen.angle < ( ball.play-ball-precisely ? 15 : 20 ) | )
&& |
( | ball.seen.angle > ( ball.play-ball-precisely ? -15 : -20 ) | )
| ) | // grab possible
{
transition-to-state(grab);
}
else
{
transition-to-state(approach-ball);
}
}
## State grab
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.gt2004mode ;
| walk.speed-x | = | 100 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | (ball.seen.angle * 2) ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.catch-ball
| strategy.ball-handling | = | handling-the-ball
The decision tree:
Pseudo code of the decision tree:
if ( |
( | ball.time-since-last-seen-consecutively < 200 | )
&& |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| ) | // ball distance greater than 200 mm
{
transition-to-state(approach-ball);
}
else
{
if ( | time-of-state-execution < 1000 | ) | // grab in progress
{
transition-to-state(grab);
}
else
{
transition-to-state(continue-grab);
}
}
## State continue-grab
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.turn-with-ball ;
| walk.speed-x | = | 0 ;
| walk.speed-y | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.catch-ball
| strategy.ball-handling | = | dribble-the-ball
The decision tree:
Pseudo code of the decision tree:
if ( |
( | ball.time-since-last-seen-consecutively < 200 | )
&& |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| ) | // ball distance greater than 200 mm
{
transition-to-state(approach-ball);
}
else
{
if ( | robot-state.something-in-front-of-chest | ) | // ball in front of chest
{
transition-to-state(grabbed);
}
else if ( | time-of-state-execution < 100 | ) | // grab in progress
{
transition-to-state(continue-grab);
}
else
{
transition-to-state(grabbed);
}
}
## State grabbed
This state is a target state.
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.turn-with-ball ;
| walk.speed-x | = | 0 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.hold-ball
| strategy.ball-handling | = | dribble-the-ball
The decision tree:
Pseudo code of the decision tree:
if ( |
( | ball.time-since-last-seen-consecutively < 200 | )
&& |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| ) | // ball distance greater than 200 mm
{
transition-to-state(approach-ball);
}
else
{
if ( | robot-state.time-since-something-was-in-front-of-chest > 450 | ) | // ball is not in front of chest
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(grabbed);
}
}