In this challenge, we control a car whose mission is to catch another car. Both cars have the same maximum speed. We have a radar and lidar to feed our Unscented Kalman Filter and track and predict the other car. Almost like the plot to Fast & Furious saga.
Here is the action:
The algorithm I devised is something like this:
Point in the general direction of the other car
If we are confident about our predictive abilities (Coefficients of covariance matrix are small)
Try the following for time intervals starting from 0.1 seconds to 5 seconds, increasing them by 0.05 seconds each time
Predict the position of the other car after this time interval
Check how far it will be from our current position
If we are able to reach it in time with our max speed or less, set course!
As with many other projects, it is easy to get stuck on the little details. For me in this project the problem was passing the heading and speed to the simulator. I guess the simulator is using some crude controller to implement the commands, which results in unprecise controls. This situation is aggravated by the time lags between command inputs. I solved this by implementing a kind of proportional control. While I calculate the exact values for heading and speed, I pass them multiplied by a small value to the simulator. This results in a smooth control which catches the car in the first try.
The code for my project is hosted in github: