Skip to content

double-fault/torcs-robot

Repository files navigation

torcs-robot

A simple torcs robot. Main robot code is in driver.cpp. A demo video of the robot over one lap of the Wheel 1 track can be seen here.

Rough overview of the project is as follows.

Coming up with a racing line

  1. Simplistic implementation of the K1999 algorithm, described in Appendix C of Remi Coulom's PhD Thesis.
  2. To make the racing line smooth, have put a cubic spline through the various discrete track nodes. Eventually the cubic spline is also discretized, but it is a lot smoother, as the initial track nodes were kept at relatively large distances to allow for a quick convergence of the K1999 algorithm.

A close-up of the racine line generated on the last section of the Wheel 1 track:

image

Acceleration, Braking and Gear changes

Have used a simplistic model image

Downforce has been modeled as follows, with alpha and beta being arbitrary coefficients found by trial-and-error. Can also be found by proper aerodynamic modeling, but getting the coefficient by trial-and-error works decent enough for a simple robot.

image

On every segment of the track we are either accelerating or braking. Using the above equations we can get the max allowed speed on every segment of the track.

A simple approach to figure out whether we need to brake or not is the following; we look at a segment some L distance ahead. Let the current speed be u and the maximum alloweed speed on the segment we are looking at be v. If v < u, we calculate the distance it would take for the car to reduce its speed from u to v. Call this distance brake distance d. If d > L, we brake. We get d by assuming maximum retardation force when we brake, which gives us an integral:

image

We change gears at fixed engine RPM values.

About

A simple torcs robot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published