# Option approach-and-turn Approaches the ball and turns to accelerate the ball to the right direction Parameters of that option:
Parameter | Measure | Range | Description
approach-and-turn.angle | deg | -180..180 | The angle where to kick relative to the robot
approach-and-turn.y-offset | mm | -1000..1000 | The offset the robot is approaching the ball with.
## 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 ? 400 : 300 ) ;
| approach-ball.slow-speed | = | ( ball.play-ball-precisely ? 150 : 160 ) ;
| approach-ball.y-offset | = | ::approach-and-turn.y-offset ;
> | These output symbols are set:
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance < 150 | )
&& |
( |
( | ball.seen.angle > 50 | )
( | ball.seen.angle < -50 | )
| )
&& |
( | ball.seen.angle < (::approach-and-turn.angle + 30) | )
&& |
( | ball.seen.angle > (::approach-and-turn.angle - 30) | )
| ) | // ball is close, angle is bigger then 50 degress, ball on line with angle
{
transition-to-state(go-to-ball-without-turning);
}
else if ( |
( | ball.time-since-last-seen-consecutively < 100 | )
&& |
( | ball.consecutively-seen-time > 100 | )
&& |
( | ball.seen.distance < 150 | )
&& |
( | ball.seen.angle < 50 | )
&& |
( | ball.seen.angle > -50 | )
| ) | // near ball
{
if ( | ::approach-and-turn.angle < -30 | ) | // turn right is better
{
transition-to-state(turn-right);
}
else if ( | ::approach-and-turn.angle > 30 | ) | // turn left is better
{
transition-to-state(turn-left);
}
else
{
transition-to-state(go-on);
}
}
else
{
transition-to-state(approach-ball);
}
## State turn-right
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.turn-kick ;
| walk.speed-x | = | 230 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | -100 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
| leds.back-middle-white | = | back-middle-white.llll
| strategy.ball-handling | = | handling-the-ball
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 500 | ) | // state running long enough
{
if ( | ball.just-seen | ) | // ball seen
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(find-ball-again-right);
}
}
else
{
transition-to-state(turn-right);
}
## State turn-left
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.turn-kick ;
| walk.speed-x | = | 230 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 100 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
| leds.back-middle-white | = | back-middle-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 500 | ) | // state running long enough
{
if ( | ball.just-seen | ) | // ball seen
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(find-ball-again-left);
}
}
else
{
transition-to-state(turn-left);
}
## State go-on
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | 390 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
| strategy.ball-handling | = | dribble-the-ball
| leds.back-front-white | = | back-front-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 250 | ) | // state running long enough
{
if ( | ball.just-seen | ) | // ball seen
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(find-ball-again);
}
}
else
{
transition-to-state(go-on);
}
## State find-ball-again
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | 50 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 500 | ) | // state running long enough
{
transition-to-state(approach-ball);
}
else if ( | ball.just-seen | ) | // ball seen again
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(find-ball-again);
}
## State find-ball-again-left
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | 50 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball-left
| leds.back-middle-orange | = | back-middle-orange.llll
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 500 | ) | // state running long enough
{
transition-to-state(approach-ball);
}
else if ( | ball.just-seen | ) | // ball seen again
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(find-ball-again-left);
}
## State find-ball-again-right
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | walk-type.normal ;
| walk.speed-x | = | 50 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-ball-right
| leds.back-front-blue | = | back-front-blue.llll
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 500 | ) | // state running long enough
{
transition-to-state(approach-ball);
}
else if ( | ball.just-seen | ) | // ball seen again
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(find-ball-again-right);
}
## State go-to-ball-without-turning
If that state is active,
> | The basic behavior go-to-ball-without-turning is executed. Parameters:
| go-to-ball-without-turning.max-speed | = | 600 ;
> | 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 > 100 | ) | // ball not seen
{
transition-to-state(approach-ball);
}
else if ( | time-of-state-execution > 500 | ) | // state running for long time
{
transition-to-state(approach-ball);
}
else if ( |
( | ball.seen.distance > 200 | )
( |
( | ball.seen.angle < 40 | )
&& |
( | ball.seen.angle > -40 | )
| )
| ) | // ball is in front of robot or further away
{
transition-to-state(approach-ball);
}
else if ( |
( | ball.seen.angle > (::approach-and-turn.angle + 35) | )
&& |
( | ball.seen.angle < (::approach-and-turn.angle - 35) | )
| ) | // ball not on line with angle
{
transition-to-state(approach-ball);
}
else
{
transition-to-state(go-to-ball-without-turning);
}