8.1 Pit Stops

Introduction

In this chapter we enable our driver to perform pit stops. First let us discuss what they are good for and which steps we need to stop in the pit. You already know that your car can get damage during the race and consumes fuel. To reach the finish line in longer races we need to be able to repair and refuel our car (tire wearing and changing is currently not implemented in TORCS). Damage is modelled as damage "points", if you reach 10000 you are not able to drive further. A pit stop consists of the following steps:

  • Decide that we want to stop in the pit (strategy).
  • Drive into the pit lane with respect to the pit speed limit.
  • Drive to our pit and stop here, request the pit stop in TORCS.
  • When the car is slow enough and in the pit the simulation "captures" our car and asks us for the damage to repair (in damage "points") and how much fuel we need.
  • TORCS repairs and refuels our car.
  • The car becomes released, we drive to the pit exit with respect to the speed limit.
  • Back to business, race further.

You might have recognized that we do not ask if our pit is free, that is because TORCS provides currently one pit per car (not per team). From the above list we can derive the items we need to implement:

  • A path to the pit and back to the track. We will use a spline to compute an offset to the middle of the track (do you remember the overtake offset?).
  • A strategy part which decides if we need a pit stop.
  • The callback which tells TORCS how much repair and fuel we need.
  • An additional filter for the brake value to stop in the pit.
  • Some helper methods.

Summary

  • You know what pit stops are good for.
  • You know about repairing, damage "points" and refueling.
  • You have an idea what we need to implement.