Difference between revisions of "Pitting"
|Line 56:||Line 56:|
Revision as of 13:43, 1 November 2008
Definition of pit
TORCS defines the pitlane and the pit by a set of Points:
- P0: Start of pit entry
- P1: Start of first pit and start of pitspeedlimit
- P3: Center of the own pit
- P5: End of the last pit and end of pitspeedlimit
- P6: End of pit exit
For this points the length from the startline is given as coordinate along the track and the sideoffset from the middle of the track (P1 and P5) or from the pitlane (P3) is used as coordinate across the track.
In the first picture we see a part of the track street-1.
The middle of the track defined by TORCS is drawn as gray line. The left and right border of the track are calculated from the robot! TORCS uses a constant width for the main track segments, but defines side segments with different parameters (start width, end width, friction, rolling resistance, height etc.).
Depending on this parameters, the robot marks parts of the sides as drivable or not drivable. This results in the different width of the usable track width. The black lines across the track give the sections, calculated from the robot. Here we have two different parts: Along the normal track, the TORCS track segments are divided in sections beeing up to 2.5 m long, along the pitting area, this is reduced to a maximum length of 1 m for the sections. The dividing is done with adjustable values for the length in a way, that brings section borders to the original segment borders at the start and the end of a segment, avoiding very short sections.
The red line along the track is the main racingline calculated from the robot for driving without traffic. The second red line along the pitlane is calculated from this main racingline starting at P0 and ending at P6. The part from P1 to P5 is the pitlane. TORCS allways defines this line parallel to the main track (sideoffset P1 = sideoffset P5). In fact, this part is used as straight to make TORCS draw the doors of the pitbuildings correct. The door are drawn while runtime, the rest of the pit buildings are made with the track. This way of definition could be used for a pitlane along a curve too, but TORCS doesn't draw the doors correct in this case.
It is up to the robot, to calculate the way from P0 to P1, breaking down (at least) to the speedlimit, drive from P1 to P2, start steering into the pit, and stop at P3.
If the car stands in the pit (near P3) TORCS starts the service (refueling and repairing). After beeing serviced, the robot has to drive from P3 to P4 to avoid possible opponents in the next pit, go along the rest of the pitlane to P5 regarding the speedlimit and then speed up and go back to the track (P6).
This definitions are used in principle for all tracks, but there are some problems with it. While the first sort of bugs could be fixed by changing the track definition (i.e. there are tracks, where the length from the startline to P5 is greater than the one to P6!), the definition of P1 is used for concurrenting things!
P1 is used as start of the pitlane (pitwall, speedlimit, pitbuildings etc.) and start of the first pit. Most robots define the distance from P2 to P3 and P3 to P4 by the length of a pit. If a robot gets the first pit, P2 is in front of P1!
The pitracingline is build by several parts:
- The part form P0 to P1 is calculated from the offset of the main racingline and the direction of it at P0 to the given offset at P1 by fitting a spline.
- For P1 to P2 and P4 to P5 straights are used.
- From P2 to P3 and P4 again a spline is fitted.
- The spline from P5 to P6 is calculated to match the offset and direction of the main racingline at P6.
Problems with the standard pitting
The points P0 and P6 are defined regarding the visible representation of the track, not the cars physics!
The Points P1 and P2 can change the order.
To be able to stop in the pit, a car using the first pit has to brake earlier. So pitting spends more time for it than for a car using it's pit in the middle of the pilane. The same problem at the end of the pitlane, but mostly the last pits aren't used.
The distance from P0 to P1 is too short on several tracks.
The resulting pitracingline isn't good, the car has to cross the whole track at the entry and/or the exit and has to drive narrow curves not really needed.
In the next picture we see a pitracingline better adjusted to the track at the start and the end of the pitlane.
To get a better pitracingline for the first pit it should be calculated in a different way. In the third picture we see a compare of the pitracingline to pit1 as made for the other pits (red, without special handling for P2) and the optimized version (green). Here P1, P2 and P3 got the same sideoffset to the middle of the main track.