TORCS  1.3.9
The Open Racing Car Simulator
simu.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : simu.cpp
4  created : Sun Mar 19 00:07:53 CET 2000
5  copyright : (C) 2000-2017 by Eric Espie, Bernhard Wymann
6  email : torcs@free.fr
7  version : $Id$
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <memory.h>
23 #include <math.h>
24 #ifdef WIN32
25 #include <windows.h>
26 #include <float.h>
27 #define isnan _isnan
28 #endif
29 
30 #include <tgf.h>
31 #include <robottools.h>
32 #include "sim.h"
33 
37 static int SimNbCars = 0;
38 
42 
43 /*
44  * Check the input control from robots
45  */
46 static void
48 {
49  tTransmission *trans = &(car->transmission);
50  tClutch *clutch = &(trans->clutch);
51 
52  /* sanity check */
53 #if defined WIN32 || defined sun
54  if (isnan(car->ctrl->accelCmd)) car->ctrl->accelCmd = 0;
55  if (isnan(car->ctrl->brakeCmd)) car->ctrl->brakeCmd = 0;
56  if (isnan(car->ctrl->clutchCmd)) car->ctrl->clutchCmd = 0;
57  if (isnan(car->ctrl->steer)) car->ctrl->steer = 0;
58 #else
59  if (isnan(car->ctrl->accelCmd) || isinf(car->ctrl->accelCmd)) car->ctrl->accelCmd = 0;
60  if (isnan(car->ctrl->brakeCmd) || isinf(car->ctrl->brakeCmd)) car->ctrl->brakeCmd = 0;
61  if (isnan(car->ctrl->clutchCmd) || isinf(car->ctrl->clutchCmd)) car->ctrl->clutchCmd = 0;
62  if (isnan(car->ctrl->steer) || isinf(car->ctrl->steer)) car->ctrl->steer = 0;
63 #endif
64 
65  /* When the car is broken try to send it on the track side */
66  if (car->carElt->_state & RM_CAR_STATE_BROKEN) {
67  car->ctrl->accelCmd = 0.0f;
68  car->ctrl->brakeCmd = 0.1f;
69  car->ctrl->gear = 0;
70  if (car->trkPos.toRight > car->trkPos.seg->width / 2.0) {
71  car->ctrl->steer = 0.1f;
72  } else {
73  car->ctrl->steer = -0.1f;
74  }
75  } else if (car->carElt->_state & RM_CAR_STATE_ELIMINATED) {
76  car->ctrl->accelCmd = 0.0f;
77  car->ctrl->brakeCmd = 0.1f;
78  car->ctrl->gear = 0;
79  if (car->trkPos.toRight > car->trkPos.seg->width / 2.0) {
80  car->ctrl->steer = 0.1f;
81  } else {
82  car->ctrl->steer = -0.1f;
83  }
84  } else if (car->carElt->_state & RM_CAR_STATE_FINISH) {
85  /* when the finish line is passed, continue at "slow" pace */
86  car->ctrl->accelCmd = MIN(car->ctrl->accelCmd, 0.20);
87  if (car->DynGC.vel.x > 30.0) {
88  car->ctrl->brakeCmd = MAX(car->ctrl->brakeCmd, 0.05);
89  }
90  }
91 
92  /* check boundaries */
93  if (car->ctrl->accelCmd > 1.0) {
94  car->ctrl->accelCmd = 1.0;
95  } else if (car->ctrl->accelCmd < 0.0) {
96  car->ctrl->accelCmd = 0.0;
97  }
98  if (car->ctrl->brakeCmd > 1.0) {
99  car->ctrl->brakeCmd = 1.0;
100  } else if (car->ctrl->brakeCmd < 0.0) {
101  car->ctrl->brakeCmd = 0.0;
102  }
103  if (car->ctrl->clutchCmd > 1.0) {
104  car->ctrl->clutchCmd = 1.0;
105  } else if (car->ctrl->clutchCmd < 0.0) {
106  car->ctrl->clutchCmd = 0.0;
107  }
108  if (car->ctrl->steer > 1.0) {
109  car->ctrl->steer = 1.0;
110  } else if (car->ctrl->steer < -1.0) {
111  car->ctrl->steer = -1.0;
112  }
113 
114  clutch->transferValue = 1.0 - car->ctrl->clutchCmd;
115 }
116 
117 /* Initial configuration */
118 void
119 SimConfig(tCarElt *carElt, RmInfo *info)
120 {
121  tCar *car = &(SimCarTable[carElt->index]);
122 
123  memset(car, 0, sizeof(tCar));
124 
125  car->carElt = carElt;
126  car->DynGCg = car->DynGC = carElt->_DynGC;
127  car->trkPos = carElt->_trkPos;
128  car->ctrl = &carElt->ctrl;
129  car->params = carElt->_carHandle;
130 
131  SimCarConfig(car);
132 
133  SimCarCollideConfig(car, info->track);
134  sgMakeCoordMat4(carElt->pub.posMat, carElt->_pos_X, carElt->_pos_Y, carElt->_pos_Z - carElt->_statGC_z,
135  RAD2DEG(carElt->_yaw), RAD2DEG(carElt->_roll), RAD2DEG(carElt->_pitch));
136 }
137 
138 /* After pit stop */
139 void SimReConfig(tCarElt *carElt)
140 {
141  tCar *car = &(SimCarTable[carElt->index]);
142  if (carElt->pitcmd.fuel > 0) {
143  car->fuel += carElt->pitcmd.fuel;
144  if (car->fuel > car->tank) car->fuel = car->tank;
145  }
146 
147  if (carElt->pitcmd.repair > 0) {
148  car->dammage -= carElt->pitcmd.repair;
149  if (car->dammage < 0) car->dammage = 0;
150  }
151 
152  int i;
153  SimSteerReConfig(car);
155 
156  for (i = 0; i < 2; i++) {
157  SimWingReConfig(car, i);
158  SimAxleReConfig(car, i);
159  }
160 
161  for (i = 0; i < 4; i++) {
162  SimWheelReConfig(car, i);
163  if (carElt->pitcmd.tireChange == tCarPitCmd::ALL) {
164  SimWheelResetWear(car, i);
165  }
166  }
167 
169 }
170 
171 
172 static void
174 {
175  int i;
176  tCarElt *carElt;
177  tTrkLocPos trkPos;
178  int trkFlag;
179  tdble travelTime;
180  tdble dang;
181 
182  static tdble PULL_Z_OFFSET = 3.0;
183  static tdble PULL_SPD = 0.5;
184 
185  carElt = car->carElt;
186 
187  if (carElt->_state & RM_CAR_STATE_PULLUP) {
188  carElt->_pos_Z += car->restPos.vel.z * SimDeltaTime;
189  carElt->_yaw += car->restPos.vel.az * SimDeltaTime;
190  carElt->_roll += car->restPos.vel.ax * SimDeltaTime;
191  carElt->_pitch += car->restPos.vel.ay * SimDeltaTime;
192  sgMakeCoordMat4(carElt->pub.posMat, carElt->_pos_X, carElt->_pos_Y, carElt->_pos_Z - carElt->_statGC_z,
193  RAD2DEG(carElt->_yaw), RAD2DEG(carElt->_roll), RAD2DEG(carElt->_pitch));
194 
195  if (carElt->_pos_Z > (car->restPos.pos.z + PULL_Z_OFFSET)) {
196  carElt->_state &= ~RM_CAR_STATE_PULLUP;
197  carElt->_state |= RM_CAR_STATE_PULLSIDE;
198  // Moved pullside velocity computation down due to floating point error accumulation.
199  }
200  return;
201  }
202 
203 
204  if (carElt->_state & RM_CAR_STATE_PULLSIDE) {
205  // Recompute speed to avoid missing the parking point due to error accumulation (the pos might be
206  // in the 0-10000 range, depending on the track and vel*dt is around 0-0.001, so basically all
207  // but the most significant digits are lost under bad conditions, happens e.g on e-track-4).
208  // Should not lead to a division by zero because the pullside process stops if the car is within
209  // [0.5, 0.5]. Do not move it back.
210  travelTime = DIST(car->restPos.pos.x, car->restPos.pos.y, carElt->_pos_X, carElt->_pos_Y) / PULL_SPD;
211  car->restPos.vel.x = (car->restPos.pos.x - carElt->_pos_X) / travelTime;
212  car->restPos.vel.y = (car->restPos.pos.y - carElt->_pos_Y) / travelTime;
213 
214  carElt->_pos_X += car->restPos.vel.x * SimDeltaTime;
215  carElt->_pos_Y += car->restPos.vel.y * SimDeltaTime;
216  sgMakeCoordMat4(carElt->pub.posMat, carElt->_pos_X, carElt->_pos_Y, carElt->_pos_Z - carElt->_statGC_z,
217  RAD2DEG(carElt->_yaw), RAD2DEG(carElt->_roll), RAD2DEG(carElt->_pitch));
218 
219  if ((fabs(car->restPos.pos.x - carElt->_pos_X) < 0.5) && (fabs(car->restPos.pos.y - carElt->_pos_Y) < 0.5)) {
220  carElt->_state &= ~RM_CAR_STATE_PULLSIDE;
221  carElt->_state |= RM_CAR_STATE_PULLDN;
222  }
223  return;
224  }
225 
226 
227  if (carElt->_state & RM_CAR_STATE_PULLDN) {
228  carElt->_pos_Z -= car->restPos.vel.z * SimDeltaTime;
229  sgMakeCoordMat4(carElt->pub.posMat, carElt->_pos_X, carElt->_pos_Y, carElt->_pos_Z - carElt->_statGC_z,
230  RAD2DEG(carElt->_yaw), RAD2DEG(carElt->_roll), RAD2DEG(carElt->_pitch));
231 
232  if (carElt->_pos_Z < car->restPos.pos.z) {
233  carElt->_state &= ~RM_CAR_STATE_PULLDN;
234  carElt->_state |= RM_CAR_STATE_OUT;
235  }
236  return;
237  }
238 
239 
240  if (carElt->_state & (RM_CAR_STATE_NO_SIMU & ~RM_CAR_STATE_PIT)) {
241  return;
242  }
243 
244  if (carElt->_state & RM_CAR_STATE_PIT) {
245  if ((s->_maxDammage) && (car->dammage > s->_maxDammage)) {
246  // Broken during pit stop.
247  carElt->_state &= ~RM_CAR_STATE_PIT;
248  carElt->_pit->pitCarIndex = TR_PIT_STATE_FREE;
249  } else {
250  return;
251  }
252  }
253 
254  if ((s->_maxDammage) && (car->dammage > s->_maxDammage)) {
255  carElt->_state |= RM_CAR_STATE_BROKEN;
256  } else {
257  carElt->_state |= RM_CAR_STATE_OUTOFGAS;
258  }
259 
260  carElt->_gear = car->transmission.gearbox.gear = 0;
261  carElt->_enginerpm = car->engine.rads = 0;
262 
263  if (!(carElt->_state & RM_CAR_STATE_DNF)) {
264  if (fabs(carElt->_speed_x) > 1.0) {
265  return;
266  }
267  }
268 
269  carElt->_state |= RM_CAR_STATE_PULLUP;
270  // RM_CAR_STATE_NO_SIMU evaluates to > 0 from here, so we remove the car from the
271  // collision detection.
272  SimCollideRemoveCar(car, s->_ncars);
273 
274  carElt->priv.simcollision = carElt->priv.collision = car->collision = 0;
275  for(i = 0; i < 4; i++) {
276  carElt->_skid[i] = 0;
277  carElt->_wheelSpinVel(i) = 0;
278  carElt->_brakeTemp(i) = 0;
279  }
280 
281  carElt->pub.DynGC = car->DynGC;
282  carElt->_speed_x = 0;
283 
284  // Compute the target zone for the wrecked car.
285  trkPos = car->trkPos;
286  if (trkPos.toRight > trkPos.seg->width / 2.0) {
287  while (trkPos.seg->lside != 0) {
288  trkPos.seg = trkPos.seg->lside;
289  }
290  trkPos.toLeft = -3.0;
291  trkFlag = TR_TOLEFT;
292  } else {
293  while (trkPos.seg->rside != 0) {
294  trkPos.seg = trkPos.seg->rside;
295  }
296  trkPos.toRight = -3.0;
297  trkFlag = TR_TORIGHT;
298  }
299 
300  trkPos.type = TR_LPOS_SEGMENT;
301  RtTrackLocal2Global(&trkPos, &(car->restPos.pos.x), &(car->restPos.pos.y), trkFlag);
302  car->restPos.pos.z = RtTrackHeightL(&trkPos) + carElt->_statGC_z;
303  car->restPos.pos.az = RtTrackSideTgAngleL(&trkPos);
304  car->restPos.pos.ax = 0;
305  car->restPos.pos.ay = 0;
306 
307  car->restPos.vel.z = PULL_SPD;
308  travelTime = (car->restPos.pos.z + PULL_Z_OFFSET - carElt->_pos_Z) / car->restPos.vel.z;
309  dang = car->restPos.pos.az - carElt->_yaw;
310  NORM_PI_PI(dang);
311  car->restPos.vel.az = dang / travelTime;
312  dang = car->restPos.pos.ax - carElt->_roll;
313  NORM_PI_PI(dang);
314  car->restPos.vel.ax = dang / travelTime;
315  dang = car->restPos.pos.ay - carElt->_pitch;
316  NORM_PI_PI(dang);
317  car->restPos.vel.ay = dang / travelTime;
318 }
319 
320 
321 
322 void
323 SimUpdate(tSituation *s, double deltaTime, int telemetry)
324 {
325  int i;
326  int ncar;
327  tCarElt *carElt;
328  tCar *car;
329 
330  SimDeltaTime = deltaTime;
332  for (ncar = 0; ncar < s->_ncars; ncar++) {
333  SimCarTable[ncar].collision = 0;
334  SimCarTable[ncar].blocked = 0;
335  }
336 
337  for (ncar = 0; ncar < s->_ncars; ncar++) {
338  car = &(SimCarTable[ncar]);
339  carElt = car->carElt;
340 
341  if (carElt->_state & RM_CAR_STATE_NO_SIMU) {
342  RemoveCar(car, s);
343  continue;
344  } else if (((s->_maxDammage) && (car->dammage > s->_maxDammage)) ||
345  (car->fuel == 0) ||
346  (car->carElt->_state & RM_CAR_STATE_ELIMINATED)) {
347  RemoveCar(car, s);
348  if (carElt->_state & RM_CAR_STATE_NO_SIMU) {
349  continue;
350  }
351  }
352 
353  if (s->_raceState & RM_RACE_PRESTART) {
354  car->ctrl->gear = 0;
355  }
356 
357  SimAtmosphereUpdate(car, s);
358  CHECK(car);
359  ctrlCheck(car);
360  CHECK(car);
361  SimSteerUpdate(car);
362  CHECK(car);
363  SimGearboxUpdate(car);
364  CHECK(car);
365  SimEngineUpdateTq(car);
366  CHECK(car);
367 
368  if (!(s->_raceState & RM_RACE_PRESTART)) {
369 
371  CHECK(car);
373  CHECK(car);
374  SimAeroUpdate(car, s);
375  CHECK(car);
376  for (i = 0; i < 2; i++){
377  SimWingUpdate(car, i, s);
378  }
379  CHECK(car);
380  for (i = 0; i < 4; i++){
381  SimWheelUpdateRide(car, i);
382  }
383  CHECK(car);
384  for (i = 0; i < 2; i++){
385  SimAxleUpdate(car, i);
386  }
387  CHECK(car);
388  for (i = 0; i < 4; i++){
389  SimWheelUpdateForce(car, i);
390  SimWheelUpdateTire(car, i);
391 
392  // Reset tire damage in pre simulation state (when the model is thrown in the world)
393  if (s->_raceState == 0) {
394  SimWheelResetWear(car, i);
395  }
396  }
397  CHECK(car);
399  CHECK(car);
401  CHECK(car);
402  SimCarUpdate(car, s);
403  CHECK(car);
404  } else {
405  SimEngineUpdateRpm(car, 0.0);
406  }
407  }
408 
410 
411  /* printf ("%f - ", s->currentTime); */
412 
413  for (ncar = 0; ncar < s->_ncars; ncar++) {
414  car = &(SimCarTable[ncar]);
415  CHECK(car);
416  carElt = car->carElt;
417 
418  if (carElt->_state & RM_CAR_STATE_NO_SIMU) {
419  continue;
420  }
421 
422  CHECK(car);
423  SimCarUpdate2(car, s); /* telemetry */
424 
425  /* copy back the data to carElt */
426 
427  carElt->pub.DynGC = car->DynGC;
428  carElt->pub.DynGCg = car->DynGCg;
429  carElt->pub.speed = car->speed;
430  sgMakeCoordMat4(carElt->pub.posMat, carElt->_pos_X, carElt->_pos_Y, carElt->_pos_Z - carElt->_statGC_z,
431  RAD2DEG(carElt->_yaw), RAD2DEG(carElt->_roll), RAD2DEG(carElt->_pitch));
432  carElt->_trkPos = car->trkPos;
433 
434  for (i = 0; i < 4; i++) {
435  tWheelState* const wheelState = &(carElt->priv.wheel[i]);
436  const tWheel* const wheel = &(car->wheel[i]);
437 
438  wheelState->relPos = wheel->relPos;
439  wheelState->seg = wheel->trkPos.seg;
440  wheelState->brakeTemp = wheel->brake.temp;
441  wheelState->currentGraining = wheel->currentGraining;
442  wheelState->currentPressure = wheel->currentPressure;
443  wheelState->currentTemperature = wheel->currentTemperature;
444  wheelState->currentWear = wheel->currentWear;
445 
446  carElt->pub.corner[i] = car->corner[i].pos;
447  }
448 
449  carElt->_gear = car->transmission.gearbox.gear;
450  carElt->_enginerpm = car->engine.rads;
451  carElt->_fuel = car->fuel;
452  carElt->priv.collision |= car->collision;
453  carElt->priv.simcollision = car->collision;
454  carElt->_dammage = car->dammage;
455  carElt->priv.localPressure = car->localPressure;
458  }
459 }
460 
461 
462 void
463 SimInit(int nbcars, tTrack* track, tdble fuelFactor, tdble damageFactor, tdble tireFactor)
464 {
465  rulesFuelFactor = fuelFactor;
466  rulesDamageFactor = damageFactor;
467  rulesTireFactor = tireFactor;
468  SimNbCars = nbcars;
469  SimCarTable = (tCar*)calloc(nbcars, sizeof(tCar));
471 }
472 
473 void
475 {
476  tCar *car;
477  int ncar;
478 
480  if (SimCarTable) {
481  for (ncar = 0; ncar < SimNbCars; ncar++) {
482  car = &(SimCarTable[ncar]);
483  SimEngineShutdown(car);
484  }
485  free(SimCarTable);
486  SimCarTable = 0;
487  }
488 }
489 
490 
492 {
493  // If min == max there is nothing to adjust
494  if (fabs(v->max - v->min) >= 0.0001f) {
495  // Ensure that value is in intended borders
496  if (v->value > v->max) {
497  v->value = v->max;
498  } else if (v->value < v->min) {
499  v->value = v->min;
500  }
501  return true;
502  }
503 
504  v->value = v->max;
505  return false;
506 }
tdble RtTrackHeightL(tTrkLocPos *p)
Returns the absolute height in meters of the road at the Local position p.
Definition: rttrack.cpp:314
tPosd corner[4]
Definition: car.h:222
void SimCarConfig(tCar *car)
Definition: car.cpp:29
#define RM_CAR_STATE_DNF
Car did not finish.
Definition: car.h:212
tdble fuel
Definition: carstruct.h:63
int gear
[-1,6] for gear selection
Definition: car.h:349
void SimCarCollideCars(tSituation *s)
Definition: collide.cpp:748
Race Manager General Info.
Definition: raceman.h:218
void SimTransmissionUpdate(tCar *car)
int brakeRepartitionCmd
Brake balance "clicks", positive is to the front.
Definition: car.h:359
void * params
Definition: carstruct.h:39
tDynPt corner[4]
Definition: carstruct.h:74
int collision
Definition: carstruct.h:75
tdble max
Definition: car.h:377
tDynPt DynGC
Definition: carstruct.h:64
tdble currentTemperature
Definition: wheel.h:98
void SimWheelUpdateRide(tCar *car, int index)
Definition: wheel.cpp:166
cars situation used to inform the GUI and the drivers
Definition: raceman.h:85
tdble brakeCmd
Brake command [0.0, 1.0].
Definition: car.h:347
tdble toRight
Distance (+ to left, - to right) relative to the right side of segment.
Definition: track.h:432
sgMat4 posMat
position matrix
Definition: car.h:195
tdble y
y coordinate
Definition: tgf.h:132
static void RemoveCar(tCar *car, tSituation *s)
Definition: simu.cpp:173
void SimCarUpdate2(tCar *car, tSituation *)
Definition: car.cpp:427
tdble rulesTireFactor
Definition: simu.cpp:41
#define RM_CAR_STATE_OUT
Car out of race.
Definition: car.h:216
#define RM_CAR_STATE_OUTOFGAS
Out of Gas.
Definition: car.h:219
#define RM_CAR_STATE_BROKEN
Engine no more working.
Definition: car.h:218
TireChange tireChange
Definition: car.h:445
tdble width
Width of the segment (if constant width)
Definition: track.h:316
void SimWheelUpdateForce(tCar *car, int index)
Definition: wheel.cpp:211
tCarCtrl ctrl
private
Definition: car.h:462
void SimWheelUpdateRotation(tCar *car)
Definition: wheel.cpp:373
int brakeRepartitionCmd
Definition: car.h:316
Location on the track in local coordinates.
Definition: track.h:418
void RtTrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y, int flag)
Calculate global coordinates from a local position relative to the given track segment (segment...
Definition: rttrack.cpp:80
Car structure (tCarElt).
Definition: car.h:455
tCarPitCmd pitcmd
private
Definition: car.h:463
void SimGearboxUpdate(tCar *car)
bool SimAdjustPitCarSetupParam(tCarPitSetupValue *v)
Definition: simu.cpp:491
Robots Tools.
int telemetry(tModInfo *modInfo)
Definition: carstruct.h:35
Track structure.
Definition: track.h:502
tCarCtrl * ctrl
Definition: carstruct.h:38
#define RM_CAR_STATE_PULLSIDE
Car pulled out in the air.
Definition: car.h:214
void SimBrakeSystemUpdate(tCar *car)
Definition: brake.cpp:73
tdble clutchCmd
Clutch command [0.0, 1.0].
Definition: car.h:348
void SimCarUpdateWheelPos(tCar *car)
Definition: car.cpp:275
void SimCarCollideShutdown(int nbcars)
Definition: collide.cpp:522
tDynPt restPos
Definition: carstruct.h:85
void SimWheelUpdateTire(tCar *car, int index)
Definition: wheel.cpp:421
tdble currentTemperature
Definition: car.h:262
void SimAxleReConfig(tCar *car, int index)
Definition: axle.cpp:49
void SimEngineUpdateTq(tCar *car)
Definition: engine.cpp:112
tPosd relPos
Definition: wheel.h:51
tBrake brake
Definition: wheel.h:30
#define DIST(x1, y1, x2, y2)
Distance between two points.
Definition: tgf.h:97
tdble ay
angle along y axis
Definition: tgf.h:135
#define RM_CAR_STATE_NO_SIMU
Do not simulate the car.
Definition: car.h:217
#define RAD2DEG(x)
Radian to degree conversion.
Definition: tgf.h:75
int simcollision
For rules etc.
Definition: car.h:307
tdble currentGraining
Definition: car.h:264
void SimCarCollideConfig(tCar *car, tTrack *track)
Definition: collide.cpp:700
#define RM_CAR_STATE_PULLDN
Car pulled out in the air.
Definition: car.h:215
tdble rulesDamageFactor
Definition: simu.cpp:40
int type
Type of description:
Definition: track.h:421
tTrkLocPos trkPos
Definition: wheel.h:49
Definition: wheel.h:25
void SimUpdate(tSituation *s, double deltaTime, int telemetry)
Definition: simu.cpp:323
tPosd relPos
position relative to GC
Definition: car.h:250
tdble localPressure
Definition: car.h:314
tdble steer
Steer command [-1.0, 1.0].
Definition: car.h:345
tdble toLeft
Distance (- to left, + to right) relative to left side of segment.
Definition: track.h:434
tdble SimEngineUpdateRpm(tCar *car, tdble axleRpm)
Definition: engine.cpp:162
double currentWear
Definition: wheel.h:99
tdble currentPressure
Definition: car.h:261
tDynPt DynGC
GC data (car axis)
Definition: car.h:192
void SimAeroUpdate(tCar *car, tSituation *s)
Definition: aero.cpp:37
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
tTrkLocPos trkPos
Definition: carstruct.h:68
static void ctrlCheck(tCar *car)
Definition: simu.cpp:47
Definition: Endpoint.h:36
void SimEngineShutdown(tCar *car)
Definition: engine.cpp:212
tdble value
Definition: car.h:375
void SimTransmissionReConfig(tCar *car)
tdble speed
Definition: carstruct.h:88
tdble x
x coordinate
Definition: tgf.h:131
tWheelState wheel[4]
Definition: car.h:290
void SimSteerUpdate(tCar *car)
Definition: steer.cpp:41
tCarElt * carElt
Definition: carstruct.h:40
The Gaming Framework API.
void SimAxleUpdate(tCar *car, int index)
Definition: axle.cpp:66
tTrack * track
Current track.
Definition: raceman.h:222
tdble transferValue
Definition: transmission.h:47
#define TR_TOLEFT
Definition: track.h:415
tPublicCar pub
public
Definition: car.h:459
void SimBrakeSystemReConfig(tCar *car)
Definition: brake.cpp:59
void SimWheelReConfig(tCar *car, int index)
Definition: wheel.cpp:137
Dynamic wheel information.
Definition: car.h:249
void SimAtmosphereUpdate(tCar *car, tSituation *s)
Definition: atmosphere.cpp:28
tdble currentGraining
Definition: wheel.h:100
tPrivCar priv
private
Definition: car.h:461
tDynPt DynGCg
Definition: carstruct.h:65
int index
car index
Definition: car.h:457
#define RM_RACE_PRESTART
Definition: raceman.h:68
tBrakeSyst brkSyst
Definition: carstruct.h:48
tdble tank
Definition: carstruct.h:58
void SimConfig(tCarElt *carElt, RmInfo *info)
Definition: simu.cpp:119
void SimCarCollideInit(tTrack *track)
Definition: collide.cpp:720
tTrackSeg * seg
Track segment.
Definition: track.h:420
void SimShutdown(void)
Definition: simu.cpp:474
tdble accelCmd
Accelerator command [0.0, 1.0].
Definition: car.h:346
struct trackSeg * lside
Definition: track.h:406
int collision
Collision value for graphics and sound, clearing is managed by consumers.
Definition: car.h:306
int track(tModInfo *modInfo)
Definition: trackitf.cpp:85
tTrackSeg * seg
Track segment where the wheel is.
Definition: car.h:254
int repCmdMaxClicks
Definition: brake.h:39
#define RM_CAR_STATE_ELIMINATED
Eliminated due to rules infringement.
Definition: car.h:220
tdble currentWear
Definition: car.h:263
void SimCarUpdate(tCar *car, tSituation *)
Definition: car.cpp:409
#define RM_CAR_STATE_PIT
Car currently stopped in pits.
Definition: car.h:211
tClutch clutch
Definition: transmission.h:53
tdble SimDeltaTime
Definition: simu.cpp:35
tdble az
angle along z axis
Definition: tgf.h:136
tTransmission transmission
Definition: carstruct.h:51
tdble rulesFuelFactor
Definition: simu.cpp:39
void SimWheelResetWear(tCar *car, int index)
Definition: wheel.cpp:504
tPosd vel
velocity
Definition: tgf.h:145
void SimWingReConfig(tCar *car, int index)
Definition: aero.cpp:131
tdble speed
Definition: car.h:194
void SimSteerReConfig(tCar *car)
Definition: steer.cpp:31
#define TR_PIT_STATE_FREE
Definition: track.h:444
tWheel wheel[4]
Definition: carstruct.h:46
void SimInit(int nbcars, tTrack *track, tdble fuelFactor, tdble damageFactor, tdble tireFactor)
Definition: simu.cpp:463
tEngine engine
Definition: carstruct.h:52
static int SimNbCars
Definition: simu.cpp:37
#define TR_LPOS_SEGMENT
Relative to the segment which the point is located, including border and sides, mostly used for conta...
Definition: track.h:428
#define CHECK(_car_)
Definition: carstruct.h:145
#define TR_TORIGHT
Definition: track.h:413
tdble fuel
Definition: car.h:436
int dammage
Definition: carstruct.h:83
Definition: Endpoint.h:36
tdble min
Definition: car.h:376
int blocked
Definition: carstruct.h:82
tdble rads
Definition: engine.h:46
tdble ax
angle along x axis
Definition: tgf.h:134
struct trackSeg * rside
Definition: track.h:406
tdble localPressure
Definition: carstruct.h:91
tCar * SimCarTable
Definition: simu.cpp:34
#define NORM_PI_PI(x)
Angle normalization between -PI and PI.
Definition: tgf.h:88
void SimCollideRemoveCar(tCar *car, int nbcars)
Definition: collide.cpp:496
void SimWingUpdate(tCar *car, int index, tSituation *s)
Definition: aero.cpp:147
int repCmdMaxClicks
Definition: car.h:315
tdble brakeTemp
brake temperature from 0 (cool) to 1.0 (hot)
Definition: car.h:252
tGearbox gearbox
Definition: transmission.h:52
#define RM_CAR_STATE_PULLUP
Car pulled out in the air.
Definition: car.h:213
tPosd pos
position
Definition: tgf.h:144
int repair
Definition: car.h:437
tdble RtTrackSideTgAngleL(tTrkLocPos *p)
Used to get the tangent angle for a track position The angle is given in radian.
Definition: rttrack.cpp:514
tdble temp
Definition: brake.h:29
void SimReConfig(tCarElt *carElt)
Definition: simu.cpp:139
tdble currentPressure
Definition: wheel.h:97
int SimTelemetry
Definition: simu.cpp:36
tDynPt DynGCg
GC data (world axis)
Definition: car.h:193
#define RM_CAR_STATE_FINISH
Car having passed the finish line.
Definition: car.h:210
tdble z
z coordinate
Definition: tgf.h:133