# Motion Planning

In it's full denotation Motion Planning includes two different phases:

## The Strategic Part

The strategic part of the motion planning is (normally) done before driving. It uses all available a priory information (facts, estimations or assumptions) to determine the route to drive to come from the start point to the target point. The information relates to the world (track descriptions, maps, known permanent or possible obstacles, statistical values about traffic, weather forecast etc.) and the vehicle (dimensions: width, wheelbase, steer lock angle etc.; abilities: torque/power/aerodynamic parameters/Vmax, possible slope up/down/side, fuel consume/capacity, speed limits, etc). This part isn't time critical. It is possible to have more than one strategy, ready to switch to if new informations are available.

## The Tactical Part

The tactical part of motion planning is used to determine, how to implement the strategy in the current situation. It uses all available actual information (facts, estimations or assumptions) about all relevant aspects (Global position, track local postion, distance/direction to opponents/obstacles, current fuel, traffic density, damages etc.). This part is time critical. Normally to go back that decision isn't possible (i.e. do a pit stop or not can be decided till the car passed the pit entry, but start overtaking means the car leaves slipstream).

Motion Planning contains several tasks, depending on the situation: Driving untroubled Driving in traffic

### Driving untroubled

If no obstacles or opponents are near, we try to drive an „optimal“ line, called racing line. It is calculated to maximize the driven radius (or minimize the curvature) and adjust steering to anticipate turns (braking, acceleration/deceleration). If the whole track is known, this calculation is made with the strategic part before racing. If only a part of the track is known, it has to be done incrementally. Because we want to drive as fast as possible up to the physical limits, we have to monitor the driven line and compare it to the racing line. Depending on the differences, we have to adjust the commands (steer angle, brake pressure, acceleration). Here we differ being inside (not critical) or outside (critical) the racing line in a turn. If racing on a looped track or repeating a race, we can use learning to get better results.

### Driving in traffic

If opponents are near, we can't always stay on the racing line (Obstacles can be modelled as opponents with speed 0). There are different basic situations:

Opponent(s) in front Opponent(s) aside Opponent(s) behind

### Opponent in front

If an opponent is in front and slower, we have to decide, whether we try to overtake or stay behind it.

### Opponent aside

If an opponent is aside, we have to keep a minimum side distance. Normally we won't brake, but if the offset to the racing line is contrary, we have to adjust our speed. If Opponents are on both sides, we have to drive to the remaining way in the middle.

### Opponent behind

If an opponent is behind and faster, we have to give it way according to the rules (let pass if overlapped, don't stuck it). But we can decide to go to the bright side.

### Collision Avoiding

All this basic situations are easy to handle occuring separate, but if combined, we have to set priorities. For the decision we need information about the velocity (speed and direction) and possible acceleration/deceleration of all cars involved, the free way on both sides (or in the middle, if more than one opponent is in front), the side of the next turn etc. but we don't know the actions of the opponents. Here we can use only estimations based on the current situation and the car's physics. Therefore we have to handle Collision Avoiding as an optimization with concurrent targets under uncertainty. To avoid as fast as possible, we have to use a high speed perpendicular to the track. But to drive stable we have to control this move. Starting from driving just along the track, we may not make a sudden change of the direction we steer to. We should use an increasing acceleration to the side till we got the offset to start deceleration of this movement. May be we reached a needed side distance or we come to the track's drivable bounds, the move to the side shall not lead us to an exceeding offset. Other aspects may be importand too, i.e. why risk overtaking if the next pit stop is near?