Collision Avoidance Simulation

[an error occurred while processing this directive]
Java 1.3 or higher is needed to view this applet.

This applet requires Java 1.3 or higher.


The aim of this project was to create a simulation of two moving vehicles that will avoid colliding.

The simulation exists in a two dimensional real co-ordinate system. This means that the vehicles are able to move in any direction and do not snap to a grid position. In a grid system the vehicles can only move to a spare grid slot around them. However, in a real co-ordinate system there are an infinite number of places to move to in your vicinity.

I have been working on solving this problem since it arose during the development of YARTS. At that time I was trying to make a reactive decision; once a predicted collision was detected then try and avoid it.

This new solution predicts the path to the target and if there is a collision then it will avoid it. This approach can only be taken in a situation where all the information is known about the system. For example in RTS games the world is completely known and the only variable is the user interaction, but the user can only move a vehicle in the way the game lets them. So everytime the user moves a vehicle (in a legal move) then the system recalculates the predicted positions and paths.

The results of my project can be seen above. The speed is set as a constant so that once the vehicles reach their target they do not stop but continue travelling in circles. This further demonstrates the collision avoidance system. If you set the targets of both vehicles to the same position, they will travel in circles avoiding each other.

However, there are two ways of making them crash:

  • If you set them to face each other at close range there is an unavoidable collision. At this point the simulation resets.
  • This problem can also occur when the simulation is running and arises when the system recalculates the next section of the predicted path. The system assumes that the vehicle is travelling straight until the end of the present second. This means that although the previous course had the two vehicles avoiding each other (probably turning to avoid each other), the recalculated path has both vehicles advancing in a straight line and then taking avoiding action. So if the vehicles are close enough and facing each other when this recalculation happens they will crash and the simulation will reset. The problem is (quite) easy to solve by following the previous path until the recalculation reaches creates valid paths. This will always work as the new paths are always calulated whist there are still predicted positions in the previous path.

This is still work in progress but as I am going on holiday soon it will have to take a back seat till the other 101 things in my life are sorted.

[an error occurred while processing this directive]