# Option vlc-playing the VLC-playing option ## State Machine ## State search
If that state is active,
> | The option vlc2-search-for-ball is executed.
The decision tree:
Pseudo code of the decision tree:
if ( | ball.just-seen | ) | // ball was just seen
{
transition-to-state(approach);
}
else if ( |
( | time-of-state-execution > 7000 | )
&& |
( | save-value( 123 , (-1300 + (random * 2600)) ) == 0 | )
| ) | // ball wasn't seen for a very long time (use the save/get hack to fix a random number for the positioning
{
transition-to-state(confusedRepositioning);
}
else
{
transition-to-state(search);
}
## State confusedRepositioning
If that state is active,
> | The option get-to-position-and-avoid-obstacles is executed. Parameters:
| get-to-position-and-avoid-obstacles.x | = | 500 ;
| get-to-position-and-avoid-obstacles.y | = | get-value( 123 ) ;
| get-to-position-and-avoid-obstacles.destination-angle | = | 0 ;
| get-to-position-and-avoid-obstacles.max-speed | = | 450 ;
| get-to-position-and-avoid-obstacles.no-obstacle-avoidance-distance | = | 700 ;
| get-to-position-and-avoid-obstacles.avoid-penalty-areas | = | 0 ;
| get-to-position-and-avoid-obstacles.avoidance-level | = | 1 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-auto
The decision tree:
Pseudo code of the decision tree:
if ( | ball.just-seen | ) | // ball was seen
{
transition-to-state(approach);
}
else if ( | distance-to( 500 , get-value( 123 ) ) < 300 | ) | // reached the target position
{
transition-to-state(search);
}
else
{
transition-to-state(confusedRepositioning);
}
## State approach
If that state is active,
> | The basic behavior go-to-ball is executed. Parameters:
| go-to-ball.distance | = | 0 ;
| go-to-ball.max-speed | = | 450 ;
| go-to-ball.max-speed.y | = | 300 ;
| go-to-ball.max-turn-speed | = | 150 ;
| go-to-ball.target-angle-to-ball | = | ball.known-or-near.angle ;
| go-to-ball.walk-type | = | walk-type.normal ;
| go-to-ball.y-offset | = | 0 ;
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-landmarks
The decision tree:
Pseudo code of the decision tree:
if ( | ball.time-since-last-seen > 3000 | ) | // lost sight of the ball
{
transition-to-state(search);
}
else if ( | ball.known-or-near.distance < 800 | ) | // ball is near
{
if ( | abs( (ball.known-or-near.angle - angle-to( 2700 , 0 )) ) < 80 | ) | // we approach the ball from the right side, i.e. directed to the opponent goal
{
transition-to-state(approachNearBallGoodDirection);
}
else
{
transition-to-state(approachNearBallBadDirection);
}
}
else
{
transition-to-state(approach);
}
## State approachNearBallGoodDirection
If that state is active,
> | The basic behavior go-to-ball is executed. Parameters:
| go-to-ball.distance | = | 120 ;
| go-to-ball.max-speed | = | 300 ;
| go-to-ball.max-speed.y | = | 300 ;
| go-to-ball.max-turn-speed | = | 120 ;
| go-to-ball.target-angle-to-ball | = | angle.best-angle-to-opponent-goal ;
| go-to-ball.walk-type | = | 0 ;
| go-to-ball.y-offset | = | 0 ;
> | 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-known > 3000 | ) | // lost the ball
{
transition-to-state(search);
}
else if ( |
( | abs( (ball.known-or-near.angle - angle.best-angle-to-opponent-goal) ) > 100 | )
( | ball.known-or-near.distance > 1000 | )
| ) | // direction is not good any more or ball is somehow too far away now
{
transition-to-state(approach);
}
else if ( | ball.seen.distance < 300 | ) | // ball is near enough to kick
{
transition-to-state(faceBall);
}
else
{
transition-to-state(approachNearBallGoodDirection);
}
## State approachNearBallBadDirection
If that state is active,
> | The option grab-ball-with-vlc2-head is executed.
> | 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-known > 3000 | ) | // lost the ball
{
transition-to-state(search);
}
else if ( |
( | abs( (ball.known-or-near.angle - angle.best-angle-to-opponent-goal) ) < 60 | )
( | ball.known-or-near.distance > 1000 | )
| ) | // direction is not that bad any more or ball is somehow too far away now
{
transition-to-state(approach);
}
else if ( | subsequent-option-reached-target-state | ) | // ball is grabbed
{
transition-to-state(turnWithBall);
}
else
{
transition-to-state(approachNearBallBadDirection);
}
## State faceBall
If that state is active,
> | The basic behavior walk is executed. Parameters:
| walk.type | = | 0 ;
| walk.speed-x | = | 0 ;
| walk.speed-y | = | 0 ;
| walk.rotation-speed | = | (sgn( ball.known-or-near.angle ) * 150) ;
> | 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.known-or-near.distance > 300 | )
( | ball.time-since-last-seen > 3000 | )
| ) | // ball is too far away or not seen any more
{
transition-to-state(approach);
}
else if ( | ball.known-or-near.angle < 20 | ) | // robot is facing the ball
{
transition-to-state(turnAroundBall);
}
else
{
transition-to-state(faceBall);
}
## State turnAroundBall
If that state is active,
> | The basic behavior turn-around-point is executed. Parameters:
| turn-around-point.x | = | ball.known-or-near.x ;
| turn-around-point.y | = | ball.known-or-near.y ;
| turn-around-point.radius | = | ball.propagated.distance ;
| turn-around-point.left-right | = | sgn( (ball.known-or-near.angle - angle.best-angle-to-opponent-goal) ) ;
| turn-around-point.forward-component | = | 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 ( | ball.known-or-near.distance > 200 | ) | // ball is too far away
{
transition-to-state(approach);
}
else
{
if ( | abs( ((angle.best-angle-to-opponent-goal + angle.best-angle-to-opponent-goal-no-obstacles) / 2) ) < 5 | ) | // direction is ok now
{
if ( | robot-pose.distance-to-opponent-goal > 1600 | ) | // goal is to far away for a good shot
{
transition-to-state(dribble);
}
else if ( | abs( ball.known-or-near.y ) > 1400 | ) | // ball near a border
{
transition-to-state(dribble);
}
else
{
transition-to-state(relocalize);
}
}
else
{
transition-to-state(turnAroundBall);
}
}
## State turnWithBall
If that state is active,
> | The option vlc-turn-and-release is executed. Parameters:
| vlc-turn-and-release.angle | = | angle.best-angle-to-opponent-goal ;
The decision tree:
Pseudo code of the decision tree:
if ( | subsequent-option-reached-target-state | ) | // turning finished or ball lost or something
{
transition-to-state(relocalize);
}
else
{
transition-to-state(turnWithBall);
}
## State dribble
If that state is active,
> | The option vlc2-localized-dribbling is executed. Parameters:
| vlc2-localized-dribbling.destination-angle | = | angle-to( 2000 , 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 ( | ball.time-since-last-seen < 3000 | ) | // ball lost
{
transition-to-state(search);
}
else if ( | robot-pose.distance-to-opponent-goal < 1100 | ) | // near enough to consider kicking
{
transition-to-state(approach);
}
else if ( |
( | ball.known-or-near.distance > 300 | )
( | abs( (angle-to( 2000 , 0 ) - ball.known-or-near.angle) ) > 100 | )
| ) | // ball is now to far away or the direction is shitty
{
transition-to-state(approach);
}
else
{
transition-to-state(dribble);
}
## State kick
If that state is active,
> | The option do-special-action is executed. Parameters:
| do-special-action.special-action-id | = | special-action.forward-kick-fast ;
| do-special-action.target-action-id | = | 0 ;
The decision tree:
Pseudo code of the decision tree:
if ( | subsequent-option-reached-target-state | ) | //
{
transition-to-state(approach);
}
else
{
transition-to-state(kick);
}
## State relocalize
If that state is active,
> | The basic behavior stand is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-for-landmarks
The decision tree:
Pseudo code of the decision tree:
if ( | time-of-state-execution > 1000 | ) | // should be relocalized after a few seconds
{
transition-to-state(prepareKick);
}
else
{
transition-to-state(relocalize);
}
## State prepareKick
If that state is active,
> | The basic behavior stand is executed.
> | 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 > 2000 | )
( | ball.just-seen | )
| ) | // to be sure where the ball is
{
if ( | robot-pose.distance-to-opponent-goal > 1600 | ) | // goal is to far away for a good shot
{
transition-to-state(dribble);
}
else
{
if ( |
( | ball.known-or-near.distance < 210 | )
&& |
( | abs( ball.known-or-near.angle ) < 25 | )
| ) | // direction is ok
{
if ( | abs( ((angle.best-angle-to-opponent-goal + angle.best-angle-to-opponent-goal-no-obstacles) / 2) ) < 8 | ) | // if direction is very good
{
transition-to-state(kick);
}
else if ( |
( | abs( angle-to( 2700 , 0 ) ) < 20 | )
&& |
( | robot-pose.distance-to-opponent-goal < 600 | )
| ) | // if direction to the goal is ok and the goal is right in front of the robot
{
transition-to-state(kick);
}
else
{
transition-to-state(turnAroundBall);
}
}
else
{
transition-to-state(turnAroundBall);
}
}
}
else
{
transition-to-state(prepareKick);
}