TORCS  1.3.9
The Open Racing Car Simulator
car.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : car.cpp
4  created : Sun Mar 19 00:05:43 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 
21 
22 #include <stdio.h>
23 
24 #include "sim.h"
25 
26 const tdble aMax = 1.04f; // 60 degrees DOF limit
27 
28 void
30 {
31  void *hdle = car->params;
32  tdble k;
33  tdble w;
34  tdble gcfrl, gcrrl, gcfr;
35  tdble wf0, wr0;
36  tdble overallwidth;
37  int i;
38  tCarElt *carElt = car->carElt;
39 
40  car->dimension.x = GfParmGetNum(hdle, SECT_CAR, PRM_LEN, (char*)NULL, 4.7f);
41  car->dimension.y = GfParmGetNum(hdle, SECT_CAR, PRM_WIDTH, (char*)NULL, 1.9f);
42  overallwidth = GfParmGetNum(hdle, SECT_CAR, PRM_OVERALLWIDTH, (char*)NULL, car->dimension.y);
43  car->dimension.z = GfParmGetNum(hdle, SECT_CAR, PRM_HEIGHT, (char*)NULL, 1.2f);
44  car->mass = GfParmGetNum(hdle, SECT_CAR, PRM_MASS, (char*)NULL, 1500);
45  car->Minv = 1.0 / car->mass;
46  gcfr = GfParmGetNum(hdle, SECT_CAR, PRM_FRWEIGHTREP, (char*)NULL, .5);
47  gcfrl = GfParmGetNum(hdle, SECT_CAR, PRM_FRLWEIGHTREP, (char*)NULL, .5);
48  gcrrl = GfParmGetNum(hdle, SECT_CAR, PRM_RRLWEIGHTREP, (char*)NULL, .5);
49  car->statGC.y = - (gcfr * gcfrl + (1 - gcfr) * gcrrl) * car->dimension.y + car->dimension.y / 2.0;
50  car->statGC.z = GfParmGetNum(hdle, SECT_CAR, PRM_GCHEIGHT, (char*)NULL, .5);
51 
52  car->tank = GfParmGetNum(hdle, SECT_CAR, PRM_TANK, (char*)NULL, 80);
53  car->fuel = GfParmGetNum(hdle, SECT_CAR, PRM_FUEL, (char*)NULL, 80);
54  k = GfParmGetNum(hdle, SECT_CAR, PRM_CENTR, (char*)NULL, 1.0);
55  carElt->_drvPos_x = GfParmGetNum(hdle, SECT_DRIVER, PRM_XPOS, (char*)NULL, 0.0);
56  carElt->_drvPos_y = GfParmGetNum(hdle, SECT_DRIVER, PRM_YPOS, (char*)NULL, 0.0);
57  carElt->_drvPos_z = GfParmGetNum(hdle, SECT_DRIVER, PRM_ZPOS, (char*)NULL, 0.0);
58  carElt->_bonnetPos_x = GfParmGetNum(hdle, SECT_BONNET, PRM_XPOS, (char*)NULL, carElt->_drvPos_x);
59  carElt->_bonnetPos_y = GfParmGetNum(hdle, SECT_BONNET, PRM_YPOS, (char*)NULL, carElt->_drvPos_y);
60  carElt->_bonnetPos_z = GfParmGetNum(hdle, SECT_BONNET, PRM_ZPOS, (char*)NULL, carElt->_drvPos_z);
61 
62  if (car->fuel > car->tank) {
63  car->fuel = car->tank;
64  }
65  k = k * k;
66  car->Iinv.x = 12.0 / (car->mass * (car->dimension.y * car->dimension.y + car->dimension.z * car->dimension.z));
67  car->Iinv.y = 12.0 / (car->mass * (car->dimension.x * car->dimension.x + car->dimension.z * car->dimension.z));
68  car->Iinv.z = 12.0 / (car->mass * (car->dimension.y * car->dimension.y + k * car->dimension.x * car->dimension.x));
69 
70  /* configure components */
71  w = car->mass * G;
72 
73  wf0 = w * gcfr;
74  wr0 = w * (1 - gcfr);
75 
76  car->wheel[FRNT_RGT].weight0 = wf0 * gcfrl;
77  car->wheel[FRNT_LFT].weight0 = wf0 * (1 - gcfrl);
78  car->wheel[REAR_RGT].weight0 = wr0 * gcrrl;
79  car->wheel[REAR_LFT].weight0 = wr0 * (1 - gcrrl);
80 
81  for (i = 0; i < 2; i++) {
82  SimAxleConfig(car, i);
83  }
84 
85  for (i = 0; i < 4; i++) {
86  SimWheelConfig(car, i);
87  }
88 
89  /* Set the origin to GC */
90  car->wheelbase = car->wheeltrack = 0;
91  car->statGC.x = car->wheel[FRNT_RGT].staticPos.x * gcfr + car->wheel[REAR_RGT].staticPos.x * (1 - gcfr);
92 
94  SimEngineConfig(car);
96  SimSteerConfig(car);
98  SimAeroConfig(car);
99  for (i = 0; i < 2; i++) {
100  SimWingConfig(car, i);
101  }
102 
103  carElt->_dimension = car->dimension;
104  carElt->_statGC = car->statGC;
105  carElt->_tank = car->tank;
106  for (i = 0; i < 4; i++) {
107  carElt->priv.wheel[i].relPos = car->wheel[i].relPos;
108  }
109 
110  for (i = 0; i < 4; i++) {
111  car->wheel[i].staticPos.x -= car->statGC.x;
112  car->wheel[i].staticPos.y -= car->statGC.y;
113  }
114  car->wheelbase = (car->wheel[FRNT_RGT].staticPos.x
115  + car->wheel[FRNT_LFT].staticPos.x
116  - car->wheel[REAR_RGT].staticPos.x
117  - car->wheel[REAR_LFT].staticPos.x) / 2.0;
118  car->wheeltrack = (-car->wheel[REAR_LFT].staticPos.y
119  - car->wheel[FRNT_LFT].staticPos.y
120  + car->wheel[FRNT_RGT].staticPos.y
121  + car->wheel[REAR_RGT].staticPos.y) / 2.0;
122 
123  /* set corners pos */
124  car->corner[FRNT_RGT].pos.x = car->dimension.x * .5 - car->statGC.x;
125  car->corner[FRNT_RGT].pos.y = - overallwidth * .5 - car->statGC.y;
126  car->corner[FRNT_RGT].pos.z = 0;
127 
128  car->corner[FRNT_LFT].pos.x = car->dimension.x * .5 - car->statGC.x;
129  car->corner[FRNT_LFT].pos.y = overallwidth * .5 - car->statGC.y;
130  car->corner[FRNT_LFT].pos.z = 0;
131 
132  car->corner[REAR_RGT].pos.x = - car->dimension.x * .5 - car->statGC.x;
133  car->corner[REAR_RGT].pos.y = - overallwidth * .5 - car->statGC.y;
134  car->corner[REAR_RGT].pos.z = 0;
135 
136  car->corner[REAR_LFT].pos.x = - car->dimension.x * .5 - car->statGC.x;
137  car->corner[REAR_LFT].pos.y = overallwidth * .5 - car->statGC.y;
138  car->corner[REAR_LFT].pos.z = 0;
139 }
140 
141 
142 static void
144 {
145  tForces F;
146  int i;
147  tdble m, w, minv;
148  tdble v, R, Rv, Rm, Rx, Ry, Rz;
149 
150  car->preDynGC = car->DynGCg;
151 
152  /* total mass */
153  m = car->mass + car->fuel;
154  minv = 1.0 / m;
155  w = -m * G;
156 
157  /* Weight */
158  sgMat4 dst;
159  sgMakeRotMat4(dst, RAD2DEG(car->DynGC.pos.az), RAD2DEG(car->DynGC.pos.ax), RAD2DEG(car->DynGC.pos.ay));
160  sgMat4 dstInv;
161  sgTransposeNegateMat4(dstInv, dst);
162  sgVec3 weight = {0.0f, 0.0f, w};
163  sgXformVec3(weight, dstInv);
164  F.F.x = weight[SG_X];
165  F.F.y = weight[SG_Y];
166  F.F.z = weight[SG_Z];
167 
168  F.M.x = F.M.y = F.M.z = 0;
169 
170  /* Wheels */
171  for (i = 0; i < 4; i++) {
172  tWheel* wheel = &(car->wheel[i]);
173 
174  /* forces */
175  F.F.x += wheel->forces.x;
176  F.F.y += wheel->forces.y;
177  F.F.z += wheel->forces.z;
178 
179  /* moments */
180  F.M.x += wheel->forces.z * wheel->staticPos.y +
181  wheel->forces.y * wheel->rollCenter;
182  // Eventually TODO: activate fix below and make all cars/robots fit.
183  //car->wheel[i].forces.y * (car->statGC.z + car->wheel[i].rideHeight);
184  F.M.y -= wheel->forces.z * wheel->staticPos.x +
185  wheel->forces.x * (car->statGC.z + wheel->rideHeight);
186  F.M.z += -wheel->forces.x * wheel->staticPos.y +
187  wheel->forces.y * wheel->staticPos.x;
188  }
189 
190  /* Aero Drag */
191  F.F.x += car->aero.drag;
192 
193  /* Wings & Aero Downforce */
194  for (i = 0; i < 2; i++) {
195  /* forces */
196  F.F.z += car->wing[i].forces.z + car->aero.lift[i];
197  F.F.x += car->wing[i].forces.x;
198  /* moments */
199  F.M.y -= car->wing[i].forces.z * car->wing[i].staticPos.x + car->wing[i].forces.x * car->wing[i].staticPos.z;
200  F.M.y -= car->aero.lift[i] * (car->axle[i].xpos - car->statGC.x);
201  }
202 
203  /* Rolling Resistance */
204  v = car->speed;
205  R = 0.0f;
206  for (i = 0; i < 4; i++) {
207  R += car->wheel[i].rollRes;
208  }
209  if (v > 0.00001f) {
210  Rv = R / v;
211  if ((Rv * minv * SimDeltaTime) > v) {
212  Rv = v * m / SimDeltaTime;
213  }
214  } else {
215  Rv = 0.0f;
216  }
217  Rx = Rv * car->DynGC.vel.x;
218  Ry = Rv * car->DynGC.vel.y;
219  Rz = Rv * car->DynGC.vel.z;
220 
221  if ((R * car->wheelbase / 2.0 * car->Iinv.z) > fabs(car->DynGCg.vel.az)) {
222  Rm = car->DynGCg.vel.az / car->Iinv.z;
223  } else {
224  Rm = SIGN(car->DynGCg.vel.az) * R * car->wheelbase / 2.0;
225  }
226 
227  /* compute accelerations */
228  car->DynGC.acc.x = (F.F.x - Rx) * minv;
229  car->DynGC.acc.y = (F.F.y - Ry) * minv;
230  car->DynGC.acc.z = (F.F.z - Rz) * minv;
231 
232  sgVec3 accel = {car->DynGC.acc.x, car->DynGC.acc.y, car->DynGC.acc.z};
233  sgXformVec3(accel, dst);
234 
235  car->DynGCg.acc.x = accel[SG_X];
236  car->DynGCg.acc.y = accel[SG_Y];
237  car->DynGCg.acc.z = accel[SG_Z];
238 
239  car->DynGCg.acc.ax = car->DynGC.acc.ax = F.M.x * car->Iinv.x;
240  car->DynGCg.acc.ay = car->DynGC.acc.ay = F.M.y * car->Iinv.y;
241  car->DynGCg.acc.az = car->DynGC.acc.az = (F.M.z - Rm) * car->Iinv.z;
242 }
243 
244 static void
246 {
247  car->DynGCg.vel.x += car->DynGCg.acc.x * SimDeltaTime;
248  car->DynGCg.vel.y += car->DynGCg.acc.y * SimDeltaTime;
249  car->DynGCg.vel.z += car->DynGCg.acc.z * SimDeltaTime;
250 
251  car->DynGCg.vel.ax += car->DynGCg.acc.ax * SimDeltaTime;
252  car->DynGCg.vel.ay += car->DynGCg.acc.ay * SimDeltaTime;
253  car->DynGCg.vel.az += car->DynGCg.acc.az * SimDeltaTime;
254 
255  /* spin limitation */
256  if (fabs(car->DynGCg.vel.az) > 9.0) {
257  car->DynGCg.vel.az = SIGN(car->DynGCg.vel.az) * 9.0;
258  }
259 
260  car->DynGC.vel.ax = car->DynGCg.vel.ax;
261  car->DynGC.vel.ay = car->DynGCg.vel.ay;
262  car->DynGC.vel.az = car->DynGCg.vel.az;
263 
264  sgMat4 dst;
265  sgMakeRotMat4(dst, RAD2DEG(car->DynGC.pos.az), RAD2DEG(car->DynGC.pos.ax), RAD2DEG(car->DynGC.pos.ay));
266  sgTransposeNegateMat4(dst);
267  sgVec3 vel;
268  sgXformVec3(vel, (float *) &(car->DynGCg.vel), dst);
269  car->DynGC.vel.x = vel[SG_X];
270  car->DynGC.vel.y = vel[SG_Y];
271  car->DynGC.vel.z = vel[SG_Z];
272 }
273 
274 void
276 {
277  sgMat4 dst;
278  sgMakeRotMat4(dst, RAD2DEG(car->DynGC.pos.az), RAD2DEG(car->DynGC.pos.ax), RAD2DEG(car->DynGC.pos.ay));
279 
280  int i;
281 
282  /* Wheels data */
283  for (i = 0; i < 4; i++) {
284  tWheel* wheel = &(car->wheel[i]);
285  sgVec3 dstVec;
286  sgXformVec3(dstVec, (float *) &(wheel->staticPos.x), dst);
287 
288  wheel->pos.x = car->DynGCg.pos.x + dstVec[0];
289  wheel->pos.y = car->DynGCg.pos.y + dstVec[1];
290  wheel->pos.z = car->DynGCg.pos.z + dstVec[2];
291 
292  wheel->bodyVel.x = car->DynGC.vel.x - car->DynGC.vel.az * car->wheel[i].staticPos.y;
293  wheel->bodyVel.y = car->DynGC.vel.y + car->DynGC.vel.az * car->wheel[i].staticPos.x;
294  }
295 }
296 
297 static void
299 {
300  tdble vx, vy;
301 
302  vx = car->DynGCg.vel.x;
303  vy = car->DynGCg.vel.y;
304 
305  car->DynGCg.pos.x += vx * SimDeltaTime;
306  car->DynGCg.pos.y += vy * SimDeltaTime;
307  car->DynGCg.pos.z += car->DynGCg.vel.z * SimDeltaTime;
308 
309  car->DynGCg.pos.ax += car->DynGCg.vel.ax * SimDeltaTime;
310  car->DynGCg.pos.ay += car->DynGCg.vel.ay * SimDeltaTime;
311  car->DynGCg.pos.az += car->DynGCg.vel.az * SimDeltaTime;
312 
313  NORM_PI_PI(car->DynGCg.pos.az);
314 
315  if (car->DynGCg.pos.ax > aMax) car->DynGCg.pos.ax = aMax;
316  if (car->DynGCg.pos.ax < -aMax) car->DynGCg.pos.ax = -aMax;
317  if (car->DynGCg.pos.ay > aMax) car->DynGCg.pos.ay = aMax;
318  if (car->DynGCg.pos.ay < -aMax) car->DynGCg.pos.ay = -aMax;
319 
320  car->DynGC.pos.x = car->DynGCg.pos.x;
321  car->DynGC.pos.y = car->DynGCg.pos.y;
322  car->DynGC.pos.z = car->DynGCg.pos.z;
323 
324  car->DynGC.pos.ax = car->DynGCg.pos.ax;
325  car->DynGC.pos.ay = car->DynGCg.pos.ay;
326  car->DynGC.pos.az = car->DynGCg.pos.az;
327 
328  RtTrackGlobal2Local(car->trkPos.seg, car->DynGCg.pos.x, car->DynGCg.pos.y, &(car->trkPos), TR_LPOS_MAIN);
329 }
330 
331 static void
333 {
334  sgMat4 dst;
335  sgMakeRotMat4(dst, RAD2DEG(car->DynGC.pos.az), RAD2DEG(car->DynGC.pos.ax), RAD2DEG(car->DynGC.pos.ay));
336 
337  tdble Cosz = car->Cosz;
338  tdble Sinz = car->Sinz;
339  int i;
340 
341  for (i = 0; i < 4; i++) {
342  tPosd* corner = &(car->corner[i].pos);
343  sgVec3 localPos;
344 
345  localPos[0] = corner->x + car->statGC.x;
346  localPos[1] = corner->y + car->statGC.y;
347  localPos[2] = corner->z - car->statGC.z;
348 
349  sgVec3 dstVec;
350  sgXformVec3(dstVec, localPos, dst);
351 
352  car->corner[i].pos.ax = car->DynGCg.pos.x + dstVec[0];
353  car->corner[i].pos.ay = car->DynGCg.pos.y + dstVec[1];
354  car->corner[i].pos.az = car->DynGCg.pos.z + dstVec[2];
355 
356  /* add the body rotation to the corner */
357  /* the speed is vel.az * r */
358  /* where r = sqrt(x*x + y*y) */
359  /* the tangent vector is -y / r and x / r */
360  // compute corner velocity at local frame
361  car->corner[i].vel.ax = - car->DynGC.vel.az * localPos[1];
362  car->corner[i].vel.ay = car->DynGC.vel.az * localPos[0];
363  car->corner[i].vel.az = car->DynGC.vel.ax * localPos[1] - car->DynGC.vel.ay * localPos[0];
364 
365  // rotate to global and add global center of mass velocity
366  // note: global to local.
367  car->corner[i].vel.x = car->DynGCg.vel.x
368  + car->corner[i].vel.ax * Cosz - car->corner[i].vel.ay * Sinz;
369  car->corner[i].vel.y = car->DynGCg.vel.y
370  + car->corner[i].vel.ax * Sinz + car->corner[i].vel.ay * Cosz;
371  car->corner[i].vel.z = car->DynGCg.vel.z + car->corner[i].vel.az;
372 
373  // add local center of mass velocity
374  car->corner[i].vel.ax += car->DynGC.vel.x;
375  car->corner[i].vel.ay += car->DynGC.vel.y;
376  car->corner[i].vel.az += car->DynGC.vel.z;
377  }
378 }
379 
380 void
382 {
383  int i;
384  tdble Fzf, Fzr;
385 
386  printf("-----------------------------\nCar: %d %s ---\n", car->carElt->index, car->carElt->_name);
387  printf("Seg: %d (%s) Ts:%f Tr:%f\n",
388  car->trkPos.seg->id, car->trkPos.seg->name, car->trkPos.toStart, car->trkPos.toRight);
389  printf("---\nMx: %f My: %f Mz: %f (N/m)\n", car->DynGC.acc.ax, car->DynGC.acc.ay, car->DynGC.acc.az);
390  printf("Wx: %f Wy: %f Wz: %f (rad/s)\n", car->DynGC.vel.ax, car->DynGC.vel.ay, car->DynGC.vel.az);
391  printf("Ax: %f Ay: %f Az: %f (rad)\n", car->DynGCg.pos.ax, car->DynGCg.pos.ay, car->DynGCg.pos.az);
392  printf("---\nAx: %f Ay: %f Az: %f (Gs)\n", car->DynGC.acc.x/9.81, car->DynGC.acc.y/9.81, car->DynGC.acc.z/9.81);
393  printf("Vx: %f Vy: %f Vz: %f (m/s)\n", car->DynGC.vel.x, car->DynGC.vel.y, car->DynGC.vel.z);
394  printf("Px: %f Py: %f Pz: %f (m)\n---\n", car->DynGCg.pos.x, car->DynGCg.pos.y, car->DynGCg.pos.z);
395  printf("As: %f\n---\n", sqrt(car->airSpeed2));
396  for (i = 0; i < 4; i++) {
397  printf("wheel %d - RH:%f susp:%f zr:%.2f ", i, car->wheel[i].rideHeight, car->wheel[i].susp.x, car->wheel[i].zRoad);
398  printf("sx:%f sa:%f w:%f ", car->wheel[i].sx, car->wheel[i].sa, car->wheel[i].spinVel);
399  printf("fx:%f fy:%f fz:%f\n", car->wheel[i].forces.x, car->wheel[i].forces.y, car->wheel[i].forces.z);
400  }
401  Fzf = (car->aero.lift[0] + car->wing[0].forces.z) / 9.81;
402  Fzr = (car->aero.lift[1] + car->wing[1].forces.z) / 9.81;
403  printf("Aero Fx:%f Fz:%f Fzf=%f Fzr=%f ratio=%f\n", car->aero.drag / 9.81, Fzf + Fzr,
404  Fzf, Fzr, (Fzf + Fzr) / (car->aero.drag + 0.1) * 9.81);
405 
406 }
407 
408 void
409 SimCarUpdate(tCar *car, tSituation * /* s */)
410 {
411  SimCarUpdateForces(car);
412  CHECK(car);
413  SimCarUpdateSpeed(car);
414  CHECK(car);
416  CHECK(car);
417  SimCarUpdatePos(car);
418  CHECK(car);
419  SimCarCollideZ(car);
420  CHECK(car);
422  CHECK(car);
423  car->speed = sqrt(car->DynGC.vel.x*car->DynGC.vel.x + car->DynGC.vel.y*car->DynGC.vel.y + car->DynGC.vel.z*car->DynGC.vel.z);
424 }
425 
426 void
427 SimCarUpdate2(tCar *car, tSituation * /* s */)
428 {
429  if (SimTelemetry == car->carElt->index) SimTelemetryOut(car);
430 }
431 
void SimEngineConfig(tCar *car)
Definition: engine.cpp:23
#define REAR_LFT
rear left
Definition: car.h:41
tdble wheeltrack
Definition: carstruct.h:79
void SimBrakeSystemConfig(tCar *car)
Definition: brake.cpp:48
void SimCarConfig(tCar *car)
Definition: car.cpp:29
static void SimCarUpdatePos(tCar *car)
Definition: car.cpp:298
tdble fuel
Definition: carstruct.h:63
#define FRNT_LFT
front left
Definition: car.h:39
#define FRNT_RGT
front right
Definition: car.h:38
t3Dd forces
Definition: aero.h:39
void * params
Definition: carstruct.h:39
tDynPt preDynGC
Definition: carstruct.h:67
tDynPt corner[4]
Definition: carstruct.h:74
#define SECT_BONNET
Definition: car.h:505
tdble sx
Definition: wheel.h:53
tDynPt DynGC
Definition: carstruct.h:64
int SimTelemetry
Definition: simu.cpp:36
cars situation used to inform the GUI and the drivers
Definition: raceman.h:85
tdble xpos
Definition: axle.h:29
tdble toRight
Distance (+ to left, - to right) relative to the right side of segment.
Definition: track.h:432
tdble y
y coordinate
Definition: tgf.h:132
void SimCarUpdate2(tCar *car, tSituation *)
Definition: car.cpp:427
tdble wheelbase
Definition: carstruct.h:78
#define PRM_LEN
Definition: car.h:512
tdble Minv
Definition: carstruct.h:57
Car structure (tCarElt).
Definition: car.h:455
tAxle axle[2]
Definition: carstruct.h:45
void SimTransmissionConfig(tCar *car)
#define SIGN(x)
Sign of the expression.
Definition: tgf.h:78
Definition: carstruct.h:35
tPosd acc
acceleration
Definition: tgf.h:146
tdble rollRes
Definition: wheel.h:34
void SimCarUpdateWheelPos(tCar *car)
Definition: car.cpp:275
tdble SimDeltaTime
Definition: simu.cpp:35
tdble x
Definition: susp.h:52
void SimWheelConfig(tCar *car, int index)
Definition: wheel.cpp:26
#define REAR_RGT
rear right
Definition: car.h:40
#define PRM_OVERALLWIDTH
Definition: car.h:515
tdble rollCenter
Definition: wheel.h:59
t3Dd staticPos
Definition: aero.h:45
tPosd relPos
Definition: wheel.h:51
tdble ay
angle along y axis
Definition: tgf.h:135
t3Dd F
Forces.
Definition: tgf.h:152
tSuspension susp
Definition: wheel.h:29
void SimCarCollideZ(tCar *car)
Definition: collide.cpp:25
#define RAD2DEG(x)
Radian to degree conversion.
Definition: tgf.h:75
t3Dd Iinv
Definition: carstruct.h:60
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 ...
Definition: rttrack.cpp:156
t3Dd dimension
Definition: carstruct.h:55
Definition: wheel.h:25
#define TR_LPOS_MAIN
Relative to the main segment, mostly used for racing on the main track.
Definition: track.h:427
tPosd relPos
position relative to GC
Definition: car.h:250
const char * name
Segment name.
Definition: track.h:277
#define PRM_HEIGHT
Definition: car.h:516
tdble zRoad
Definition: wheel.h:36
#define PRM_CENTR
Definition: car.h:524
tAero aero
Definition: carstruct.h:49
#define PRM_MASS
Definition: car.h:517
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
void SimWingConfig(tCar *car, int index)
Definition: aero.cpp:110
tTrkLocPos trkPos
Definition: carstruct.h:68
void SimCarCollideXYScene(tCar *car)
Definition: collide.cpp:101
static void SimCarUpdateSpeed(tCar *car)
Definition: car.cpp:245
tPosd staticPos
Definition: wheel.h:57
t3Dd pos
Definition: wheel.h:37
#define PRM_ZPOS
Definition: car.h:566
tdble speed
Definition: carstruct.h:88
tdble x
x coordinate
Definition: tgf.h:131
static void SimCarUpdateForces(tCar *car)
Definition: car.cpp:143
tWheelState wheel[4]
Definition: car.h:290
tCarElt * carElt
Definition: carstruct.h:40
tdble Cosz
Definition: carstruct.h:72
#define PRM_TANK
Definition: car.h:522
tdble lift[2]
Definition: aero.h:27
Forces and moments.
Definition: tgf.h:150
tdble y
y coordinate
Definition: tgf.h:117
tPrivCar priv
private
Definition: car.h:461
tdble z
z coordinate
Definition: tgf.h:118
6 DOF position.
Definition: tgf.h:130
tDynPt DynGCg
Definition: carstruct.h:65
tdble spinVel
Definition: wheel.h:43
int index
car index
Definition: car.h:457
tdble weight0
Definition: wheel.h:61
#define PRM_FRLWEIGHTREP
Definition: car.h:519
#define SECT_DRIVER
Definition: car.h:504
void SimSteerConfig(tCar *car)
Definition: steer.cpp:21
tdble tank
Definition: carstruct.h:58
#define PRM_XPOS
Definition: car.h:564
void SimAeroConfig(tCar *car)
Definition: aero.cpp:23
tTrackSeg * seg
Track segment.
Definition: track.h:420
#define SECT_CAR
Definition: car.h:473
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Definition: params.cpp:2392
tdble airSpeed2
Definition: carstruct.h:69
tdble rideHeight
Definition: wheel.h:35
void SimCarUpdate(tCar *car, tSituation *)
Definition: car.cpp:409
tdble drag
Definition: aero.h:26
const tdble aMax
Definition: car.cpp:26
tdble Sinz
Definition: carstruct.h:73
void SimAtmosphereConfig(tCar *car)
Definition: atmosphere.cpp:22
#define PRM_WIDTH
Definition: car.h:513
#define PRM_YPOS
Definition: car.h:565
tdble az
angle along z axis
Definition: tgf.h:136
tdble toStart
Distance to start of segment (or arc if turn)
Definition: track.h:431
tPosd vel
velocity
Definition: tgf.h:145
tWheel wheel[4]
Definition: carstruct.h:46
#define CHECK(_car_)
Definition: carstruct.h:145
static void SimCarUpdateCornerPos(tCar *car)
Definition: car.cpp:332
#define PRM_GCHEIGHT
Definition: car.h:521
#define PRM_RRLWEIGHTREP
Definition: car.h:520
tdble mass
Definition: carstruct.h:56
t3Dd statGC
Definition: carstruct.h:59
void SimTelemetryOut(tCar *car)
Definition: car.cpp:381
tdble ax
angle along x axis
Definition: tgf.h:134
#define NORM_PI_PI(x)
Angle normalization between -PI and PI.
Definition: tgf.h:88
void SimAxleConfig(tCar *car, int index)
Definition: axle.cpp:23
tWing wing[2]
Definition: carstruct.h:50
tdble sa
Definition: wheel.h:52
tPosd pos
position
Definition: tgf.h:144
tdble x
x coordinate
Definition: tgf.h:116
const tdble G
m/s/s
Definition: tgf.h:70
t3Dd forces
Definition: wheel.h:33
int id
Segment number.
Definition: track.h:278
t3Dd bodyVel
Definition: wheel.h:38
#define PRM_FRWEIGHTREP
Definition: car.h:518
t3Dd M
Moments.
Definition: tgf.h:153
tdble z
z coordinate
Definition: tgf.h:133
#define PRM_FUEL
Definition: car.h:523