TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
rttrack.cpp File Reference


Common functions for robots. More...

#include <portability.h>
#include <stdlib.h>
#include <math.h>
#include <tgf.h>
#include <car.h>
#include <track.h>
#include <robottools.h>
Include dependency graph for rttrack.cpp:

Go to the source code of this file.

Functions

tdble RtTrackGetWidth (tTrackSeg *seg, tdble toStart)
 Get the track width at the specified point.
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.
template<typename T>
static void rtTrackGlobal2Local (tTrackSeg *segment, T X, T Y, tTrkLocPos *p, int type)
void RtTrackGlobal2LocalD (tTrackSeg *segment, double X, double Y, tTrkLocPos *p, int type)
 Convert global coordinates to a local track position using double intermediates.
void RtTrackGlobal2Local (tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
 Convert global coordinates to a local track position.
static tTrackSeg * resolveTrackSeg (const tTrkLocPos *p, tdble *toRight)
 Resolve the effective segment and rebase the lateral coordinate to it.
tdble RtTrackHeightL (tTrkLocPos *p)
 Returns the absolute height in meters of the road at the Local position p.
tTrackSeg * RtTrackGetSideNeighbourSeg (tTrackSeg *main, tTrackSeg *current, int tr_side)
 Get the neighbour segment of the given current segment.
tTrackSeg * RtTrackGetSeg (tTrkLocPos *p)
 Get the effective segment of the given position starting from a segment of type TR_MAIN, searching to the sides.
tdble RtTrackHeightG (tTrackSeg *seg, tdble X, tdble Y)
 Returns the absolute height in meters of the road at the Global position (segment, X, Y)
void RtTrackSideNormalG (tTrackSeg *seg, tdble X, tdble Y, int side, t3Dd *norm)
 Compute the horizontal inward border normal using the supplied segment.
tdble RtTrackSideTgAngleL (tTrkLocPos *p)
 Used to get the tangent angle for a track position The angle is given in radian.
void RtTrackSurfaceNormalL (tTrkLocPos *p, t3Dd *norm)
 Used to get the normal vector of the road (pointing upward).
tdble RtGetDistFromStart (tCarElt *car)
 Get distance along the track from the start/finish line.
tdble RtGetDistFromStart2 (tTrkLocPos *p)
 Get distance along the track from the start/finish line.
int RtDistToPit (struct CarElt *car, tTrack *track, tdble *dL, tdble *dW)
 Get the distance to the pit stop.
static void RtReadCarPitSetupEntry (tCarPitSetupValue *v, const char *path, const char *key, void *hdle, bool minmaxonly)
void RtInitCarPitSetup (void *hdle, tCarPitSetup *s, bool minmaxonly)
 Initialize tCarPitSetup from data in parameter set given in handle hdle.
void RtGetCarPitSetupFilename (rtCarPitSetupType type, int robidx, const char *carname, const char *trackname, char *filename, const int len)
 Compose filename from given strings.
static void RtParmSetNum (void *hdlesetup, const char *path, const char *key, const char *unit, tCarPitSetupValue *v)
 Robottool internal: Set parameter if min != max, save as well min and max values.
void RtSaveCarPitSetupFile (void *hdlecar, tCarPitSetup *s, const char *filepath, const char *carname)
 Save adjustable setup entries to a file, merging them with hdlecar's restrictions.
void RtSaveCarPitSetup (void *hdlecar, tCarPitSetup *s, rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
 Save a custom setup in the robot's local setups directory.
bool RtCarPitSetupExists (rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
 Checks if a specific car setup is available.
bool RtLoadCarPitSetupFilename (void *hdlecar, const char *filepath, tCarPitSetup *s, bool minmaxonly)
 Load a custom setup and merge its entries with hdlecar's restrictions.
bool RtLoadCarPitSetup (void *hdlecar, tCarPitSetup *s, rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname, bool minmaxonly)
 Load a custom setup from the robot's local setups directory.
void * RtLoadOriginalCarSettings (const char *carname)
 Gets a handle to a parameter file containing the original TORCS car setup, that means the car setup merged with the cars category setup.
bool RtInitCarPitSetupFromDefault (tCarPitSetup *s, const char *carname)
 Initialize the given tCarPitSetup with the original TORCS setup, that means the car setup merged with the cars category setup.
void * RtParmReadSetup (rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
 Load a custom car setup file for a given robot, car, track and session (race, practice, qualifying, ...) type.

Variables

static const char * CarPitSetupFilenames [6] = { "practice", "qualifying", "race", "backup1", "backup2", "backup3" }
 Array with names for rtCarPitSetupType enumeration.

Detailed Description


Common functions for robots.

Author
Bernhard Wymann, Eric Espie

Definition in file rttrack.cpp.

Function Documentation

◆ resolveTrackSeg()

tTrackSeg * resolveTrackSeg ( const tTrkLocPos * p,
tdble * toRight )
static

Resolve the effective segment and rebase the lateral coordinate to it.

The search starts at the supplied segment, continues only toward its outer side segments, and does not modify the supplied position.

Parameters
[in]pLocal position relative to the supplied segment
[out]toRightLateral position relative to the resolved segment's right side
Returns
Effective segment for the given position

Definition at line 312 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtParmSetNum()

void RtParmSetNum ( void * hdlesetup,
const char * path,
const char * key,
const char * unit,
tCarPitSetupValue * v )
static

Robottool internal: Set parameter if min != max, save as well min and max values.

Parameters
[in,out]hdlesetupHandle to parameter set to write into
[in]pathpath of parameter
[in]keykey name
[in]unitunit to convert the result to (NULL if SI wanted)
[in]vtCarPitSetupValue to set

Definition at line 868 of file rttrack.cpp.

Here is the call graph for this function:

◆ RtReadCarPitSetupEntry()

void RtReadCarPitSetupEntry ( tCarPitSetupValue * v,
const char * path,
const char * key,
void * hdle,
bool minmaxonly )
static

Definition at line 729 of file rttrack.cpp.

Here is the call graph for this function:

◆ rtTrackGlobal2Local()

template<typename T>
void rtTrackGlobal2Local ( tTrackSeg * segment,
T X,
T Y,
tTrkLocPos * p,
int type )
static

Definition at line 142 of file rttrack.cpp.

Here is the call graph for this function:

Variable Documentation

◆ CarPitSetupFilenames

const char* CarPitSetupFilenames[6] = { "practice", "qualifying", "race", "backup1", "backup2", "backup3" }
static

Array with names for rtCarPitSetupType enumeration.

Definition at line 835 of file rttrack.cpp.