TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
Robottools API

API for gathering track information and handling car setups. More...

Collaboration diagram for Robottools API:

Topics

 Robot Telemetry API
 Legacy telemetry wrappers declared in robottools.h.
 Robot Track Tools API
 API to gather information about the track and the cars state relative to the track.
 Robot Setup Tools API
 API to load and store car setups in a unified way, and to support setup changes during pit stops.

Macros

#define RELAXATION2(target, prev, rate)
 Blend a target with the previous unfiltered input.
#define RELAXATION(target, prev, rate)
 Smooth a target using the previous filtered result.

Detailed Description

API for gathering track information and handling car setups.

Include robottools.h.

Track coordinates
Global X/Y/Z positions and lateral distances are in meters. A tTrkLocPos contains a borrowed segment pointer and local coordinates: toStart is a distance in meters on a straight but an angle in radians on a curve. toRight increases toward the left, toLeft increases toward the right, and toMiddle is positive to the left of the segment center. TR_TORIGHT, TR_TOLEFT and TR_TOMIDDLE select which lateral field a local-to-global conversion uses; they are distinct from the TR_LPOS_* output modes of global-to-local conversion. Use a main segment as the search seed. Most helpers require valid segment/position pointers and do not clamp off-road positions or advance a local position into the next segment.
Typical robot queries
tdble heading = RtTrackSideTgAngleL(&car->_trkPos);
tdble distance = RtGetDistFromStart(car); // meters, without completed laps
tdble forward, lateral;
if (RtDistToPit(car, track, &forward, &lateral) == 0) {
// The car has an assigned pit; both distances are now valid.
}
Scalar distance(const Point &p1, const Point &p2)
Definition Point.h:118
float tdble
Floating point type used in TORCS.
Definition tgf.h:47
tdble RtGetDistFromStart(tCarElt *car)
Get distance along the track from the start/finish line.
Definition rttrack.cpp:646
tdble RtTrackSideTgAngleL(tTrkLocPos *p)
Used to get the tangent angle for a track position The angle is given in radian.
Definition rttrack.cpp:539
int RtDistToPit(struct CarElt *car, tTrack *track, tdble *dL, tdble *dW)
Get the distance to the pit stop.
Definition rttrack.cpp:692
int track(tModInfo *modInfo)
Definition trackitf.cpp:85
Setup ownership and units
Setup values and bounds in tCarPitSetup use SI units. Initialize the struct before populating it: missing attributes do not initialize every field. Setup helpers use the Parameter Handling API; handles returned by RtLoadOriginalCarSettings and RtParmReadSetup must be released with GfParmReleaseHandle. Handles passed as master setups are borrowed. See Robot Setup Tools API for saved setup loading and naming, and Robot Track Tools API for geometry queries. The legacy Robot Telemetry API wrappers currently do nothing.

Macro Definition Documentation

◆ RELAXATION

#define RELAXATION ( target,
prev,
rate )
Value:
do { \
target = (prev) + (rate) * ((target) - (prev)) * 0.01; \
prev = (target); \
} while (0)

Smooth a target using the previous filtered result.

Assigns target = prev + (rate/100) * (target-prev), then copies the result to prev. Initialize prev before use. Use distinct assignable variables without side effects; macro arguments can be evaluated more than once.

Parameters
[in,out]targetNew input on entry, filtered result on exit.
[in,out]prevPrevious filtered result; receives the new result.
[in]ratePercentage weight of the new input, normally 0 through 100; not clamped and independent of the simulation time step.

Definition at line 57 of file robottools.h.

◆ RELAXATION2

#define RELAXATION2 ( target,
prev,
rate )
Value:
do { \
tdble __tmp__; \
__tmp__ = target; \
target = (prev) + (rate) * ((target) - (prev)) * 0.01; \
prev = __tmp__; \
} while (0)

Blend a target with the previous unfiltered input.

Assigns target = prev + (rate/100) * (target-prev), then stores the original target in prev. Use distinct assignable variables, without side effects.

Parameters
[in,out]targetNew input on entry, blended result on exit.
[in,out]prevPrevious unfiltered input; receives the original target.
[in]ratePercentage weight of the new input, normally 0 through 100; not clamped and independent of the simulation time step.

Definition at line 39 of file robottools.h.