TORCS  1.3.9
The Open Racing Car Simulator
Robot Track Tools API

API to gather information about the track and the cars state relative to the track. More...

Collaboration diagram for Robot Track Tools API:

Functions

tdble RtTrackGetWidth (tTrackSeg *seg, tdble toStart)
 Get the track width at the specified point. More...
 
void RtTrackLocal2Global (tTrkLocPos *p, tdble *X, tdble *Y, int flag)
 Calculate global coordinates from a local position relative to the given track segment (segment, toRight, toStart)The toStart position refers to the current segment, the function will not search for next segment if toStart is greater than the segment length. More...
 
void RtTrackGlobal2Local (tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
 Convert a Global (segment, X, Y) position into a Local one (segment, toRight, toStart)The segment in the Global position is used to start the search of a good segment in term of toStart value. More...
 
tdble RtTrackHeightL (tTrkLocPos *p)
 Returns the absolute height in meters of the road at the Local position p. More...
 
tTrackSegRtTrackGetSideNeighbourSeg (tTrackSeg *main, tTrackSeg *current, int tr_side)
 Get the neighbour segment of the given current segment. More...
 
tTrackSegRtTrackGetSeg (tTrkLocPos *p)
 Get the effective segment of the given position starting from a segment of type TR_MAIN, searching to the sides. More...
 
tdble RtTrackHeightG (tTrackSeg *seg, tdble X, tdble Y)
 Returns the absolute height in meters of the road at the Global position (segment, X, Y) More...
 
void RtTrackSideNormalG (tTrackSeg *seg, tdble X, tdble Y, int side, t3Dd *norm)
 Give the normal vector of the border of the track including the sides. More...
 
tdble RtTrackSideTgAngleL (tTrkLocPos *p)
 Used to get the tangent angle for a track position The angle is given in radian. More...
 
void RtTrackSurfaceNormalL (tTrkLocPos *p, t3Dd *norm)
 Used to get the normal vector of the road (pointing upward). More...
 
tdble RtGetDistFromStart (tCarElt *car)
 Get the distance from the start lane. More...
 
tdble RtGetDistFromStart2 (tTrkLocPos *p)
 Get the distance from the start lane. More...
 
int RtDistToPit (struct CarElt *car, tTrack *track, tdble *dL, tdble *dW)
 Get the distance to the pit stop. More...
 

Detailed Description

API to gather information about the track and the cars state relative to the track.

Function Documentation

◆ RtDistToPit()

int RtDistToPit ( struct CarElt car,
tTrack track,
tdble dL,
tdble dW 
)

Get the distance to the pit stop.

Parameters
[in]carThe concerned car.
[in]trackThe current Track
[in,out]dLLength to the pits
[in,out]dWWidth to the pits
Returns
0
Note
dW > 0 if the pit is on the right

Definition at line 662 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtGetDistFromStart()

tdble RtGetDistFromStart ( tCarElt car)

Get the distance from the start lane.

Parameters
[in]carthe concerned car.
Returns
The distance between the start lane and the car.

Definition at line 619 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtGetDistFromStart2()

tdble RtGetDistFromStart2 ( tTrkLocPos p)

Get the distance from the start lane.

Parameters
[in]pLocal position
Returns
The distance between the start lane and the car.

Definition at line 631 of file rttrack.cpp.

◆ RtTrackGetSeg()

tTrackSeg* RtTrackGetSeg ( tTrkLocPos p)

Get the effective segment of the given position starting from a segment of type TR_MAIN, searching to the sides.

Get the current segment.

It does not search along the previous and next segments on the track.

Parameters
[in]pCurrent position relative to the main segment
Returns
segment for the given position

Definition at line 413 of file rttrack.cpp.

◆ RtTrackGetSideNeighbourSeg()

tTrackSeg* RtTrackGetSideNeighbourSeg ( tTrackSeg main,
tTrackSeg current,
int  tr_side 
)

Get the neighbour segment of the given current segment.

This is required, because the lside and rside members only point to segments on the outside, the inside pointer is always NULL and this is implied in various code locations.

Parameters
[in]mainMain segment to serach for neighbour from the inside (must be of type TR_MAIN)
[in]currentSegment to find the neighbour for
[in]tr_sideNeighbour we are looking for, either left or right, TR_SIDE_LFT or TR_SIDE_RGT
Returns
neighbour found or outermost segment or NULL

Definition at line 383 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtTrackGetWidth()

tdble RtTrackGetWidth ( tTrackSeg seg,
tdble  toStart 
)

Get the track width at the specified point.

Parameters
[in]segSegment
[in]toStartDistance from the beginning of the segment.
The units are:
  • meters for straights
  • radians for turns
Returns
Width of the track at this point.
Note
The Pit lane and the track have different width, and the side segments have variable width.

Definition at line 58 of file rttrack.cpp.

◆ RtTrackGlobal2Local()

void RtTrackGlobal2Local ( tTrackSeg segment,
tdble  X,
tdble  Y,
tTrkLocPos p,
int  type 
)

Convert a Global (segment, X, Y) position into a Local one (segment, toRight, toStart)The segment in the Global position is used to start the search of a good segment in term of toStart value.

The segments are scanned in order to find a toStart value between 0 and the length of the segment for straights or the arc of the curve. The sides parameters is to indicate wether to use the track sides (1) or not (0) in the toRight computation.

Parameters
[in]segmentCurrent segment
[in]XCurrent X position
[in]YCurrent Y position
[in,out]pReturned local position
[in]typeType of local position desired:
  • TR_LPOS_MAIN Relative to the main segment, mostly used for racing on the main track
  • TR_LPOS_SEGMENT Relative to the segment which the point is located, including border and sides, mostly used for contact physics
  • TR_LPOS_TRACK Local position relative to the outermost barriers, mostly used for collision detection with barrier

Definition at line 156 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtTrackHeightG()

tdble RtTrackHeightG ( tTrackSeg seg,
tdble  X,
tdble  Y 
)

Returns the absolute height in meters of the road at the Global position (segment, X, Y)

Parameters
[in]segSegment
[in]XGlobal X position
[in]YGlobal Y position
Returns
Height in meters

Definition at line 443 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtTrackHeightL()

tdble RtTrackHeightL ( tTrkLocPos p)

Returns the absolute height in meters of the road at the Local position p.

If the point lies outside the track (and sides) the height is computed using the tangent to the banking of the segment (or side).

             + Point given
            .^
           . |
          .  |
         .   |
        /    | heigth
       /     |
______/      v
^    ^^  ^
|    ||  |
track side
Parameters
[in]pLocal position
Returns
Height in meters

Definition at line 314 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtTrackLocal2Global()

void RtTrackLocal2Global ( tTrkLocPos p,
tdble X,
tdble Y,
int  flag 
)

Calculate global coordinates from a local position relative to the given track segment (segment, toRight, toStart)The toStart position refers to the current segment, the function will not search for next segment if toStart is greater than the segment length.

toStart represent an angle in radian for curves and a length in meters for straights.

Parameters
[in]pLocal position
[in,out]XReturned X position
[in,out]YReturned Y position
[in]flagLocal position use:
  • TR_TOMIDDLE the toMiddle field is used (+ to left, - to right), relative to the middle of segment
  • TR_TORIGHT the toRight field is used (+ to left, - to right), relative to the right side of segment
  • TR_TOLEFT the toLeft field is used (- to left, + to right), relative to left side of segment

Definition at line 80 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtTrackSideNormalG()

void RtTrackSideNormalG ( tTrackSeg seg,
tdble  X,
tdble  Y,
int  side,
t3Dd norm 
)

Give the normal vector of the border of the track including the sides.

The side parameter is used to indicate the right (TR_RGT) of the left (TR_LFT) side to consider. The Global position given (segment, X, Y) is used to project the point on the border, it is not necessary to give a point directly on the border itself. The vector is normalized.

Parameters
[in]segCurrent segment
[in]XGlobal X position
[in]YGlobal Y position
[in]sideSide where the normal is wanted
  • TR_LFT for left side
  • TR_RGT for right side
[in,out]normReturned normalized side normal vector

Definition at line 470 of file rttrack.cpp.

◆ RtTrackSideTgAngleL()

tdble RtTrackSideTgAngleL ( tTrkLocPos p)

Used to get the tangent angle for a track position The angle is given in radian.

the angle 0 is parallel to the first segment start.

Parameters
[in]pLocal position
Returns
Tagent angle in radian.
Note
For side segment, the track side is used for the tangent.

Definition at line 514 of file rttrack.cpp.

◆ RtTrackSurfaceNormalL()

void RtTrackSurfaceNormalL ( tTrkLocPos p,
t3Dd norm 
)

Used to get the normal vector of the road (pointing upward).

Local coordinates are used to locate the point where to get the road normal vector. The vector is normalized.

Parameters
[in]pLocal position
[in,out]normReturned normalized road normal vector

Definition at line 540 of file rttrack.cpp.

Here is the call graph for this function: