# Option turn-and-release Catches the ball with the head only and turns then to the requested angle and realeases the ball. Parameters of that option:
Parameter | Measure | Range | Description
turn-and-release.angle |  | -180..180 | The desired absolute angle of the robot on the field
## State Machine ## State grab
If that state is active,
> | The option grab-ball-with-head is executed.
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | ball.ball-was-seen | )
&& |
( | ball.number-of-images-with-ball-percept > 4 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| )
( | robot-state.time-since-something-was-in-front-of-chest > 450 | )
| ) | // ball distance greater than 200 mm or not 'seen' by PSD-sensor
{
transition-to-state(grab);
}
else
{
if ( | subsequent-option-reached-target-state | ) | // grabbed
{
if ( | ::turn-and-release.angle < 0 | ) | // turn right is better
{
transition-to-state(turn-right);
}
else
{
transition-to-state(turn-left);
}
}
else
{
transition-to-state(grab);
}
}
## State turn-left
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 | = | 140 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.catch-ball
| strategy.ball-handling | = | dribble-the-ball
| team-message | = | team-message.performing-a-kick
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | ball.ball-was-seen | )
&& |
( | ball.number-of-images-with-ball-percept > 4 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| )
( | robot-state.time-since-something-was-in-front-of-chest > 450 | )
| ) | // ball distance greater than 200 mm or not 'seen' by PSD-sensor
{
transition-to-state(grab);
}
else
{
if ( |
( | time-of-state-execution > 500 | )
&& |
( | ball.time-since-last-seen < 300 | )
&& |
( | ball.seen.distance > 150 | )
| ) | // not caught
{
transition-to-state(release-ball-left);
}
else if ( | time-of-state-execution > 2500 | ) | // ball caught too long
{
transition-to-state(release-ball-left);
}
else if ( |
( | ::turn-and-release.angle < 110 | )
&& |
( | ::turn-and-release.angle > -110 | )
| ) | // reached target angle
{
transition-to-state(release-ball-left);
}
else
{
transition-to-state(turn-left);
}
}
## State turn-right
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 | = | -140 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.catch-ball
| strategy.ball-handling | = | dribble-the-ball
| team-message | = | team-message.performing-a-kick
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | ball.ball-was-seen | )
&& |
( | ball.number-of-images-with-ball-percept > 4 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| )
( | robot-state.time-since-something-was-in-front-of-chest > 450 | )
| ) | // ball distance greater than 200 mm or not 'seen' by PSD-sensor
{
transition-to-state(grab);
}
else
{
if ( |
( | time-of-state-execution > 500 | )
&& |
( | ball.time-since-last-seen < 300 | )
&& |
( | ball.seen.distance > 150 | )
| ) | // not caught
{
transition-to-state(release-ball-right);
}
else if ( | time-of-state-execution > 2500 | ) | // ball caught too long
{
transition-to-state(release-ball-right);
}
else if ( |
( | ::turn-and-release.angle < 110 | )
&& |
( | ::turn-and-release.angle > -110 | )
| ) | // reached target angle
{
transition-to-state(release-ball-right);
}
else
{
transition-to-state(turn-right);
}
}
## State find-ball-again
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.speed-x | = | 100 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 0 ;
| walk.type | = | walk-type.normal ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
| strategy.ball-handling | = | handling-the-ball
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | ball.ball-was-seen | )
&& |
( | ball.number-of-images-with-ball-percept > 4 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| )
( | robot-state.time-since-something-was-in-front-of-chest > 450 | )
| ) | // ball distance greater than 200 mm or not 'seen' by PSD-sensor
{
transition-to-state(grab);
}
else
{
if ( | ball.just-seen | ) | // ball seen again
{
transition-to-state(grab);
}
else if ( | time-of-state-execution < 500 | ) | // state running less than 0,5 seconds
{
transition-to-state(find-ball-again);
}
else
{
transition-to-state(grab);
}
}
## State release-ball-left
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 | = | 140 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.release-caught-ball-when-turning-left
| strategy.ball-handling | = | performing-a-kick
| team-message | = | team-message.performing-a-kick
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | ball.ball-was-seen | )
&& |
( | ball.number-of-images-with-ball-percept > 4 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| )
( | robot-state.time-since-something-was-in-front-of-chest > 450 | )
| ) | // ball distance greater than 200 mm or not 'seen' by PSD-sensor
{
transition-to-state(grab);
}
else
{
if ( |
( | ball.just-seen | )
&& |
( | ball.seen.distance > 600 | )
| ) | // ball seen far away
{
transition-to-state(grab);
}
else if ( | time-of-state-execution > 2000 | ) | // state running more than 1000 ms
{
transition-to-state(find-ball-again);
}
else
{
transition-to-state(release-ball-left);
}
}
## State release-ball-right
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 | = | -140 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.release-caught-ball-when-turning-right
| strategy.ball-handling | = | performing-a-kick
| team-message | = | team-message.performing-a-kick
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | ball.ball-was-seen | )
&& |
( | ball.number-of-images-with-ball-percept > 4 | )
&& |
( | ball.seen.distance > 200 | )
&& |
( | ball.seen.distance < 800 | )
| )
( | robot-state.time-since-something-was-in-front-of-chest > 450 | )
| ) | // ball distance greater than 200 mm or not 'seen' by PSD-sensor
{
transition-to-state(grab);
}
else
{
if ( |
( | ball.just-seen | )
&& |
( | ball.seen.distance > 600 | )
| ) | // ball seen far away
{
transition-to-state(grab);
}
else if ( | time-of-state-execution > 2000 | ) | // state running more than 1000 ms
{
transition-to-state(find-ball-again);
}
else
{
transition-to-state(release-ball-right);
}
}