TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
carstruct.h
Go to the documentation of this file.
1/***************************************************************************
2
3 file : carstruct.h
4 created : Sun Mar 19 00:06:07 CET 2000
5 copyright : (C) 2000-2013 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#ifndef _CAR__H_
21#define _CAR__H_
22
23#include <plib/sg.h>
24#include <SOLID/solid.h>
25
26#include "aero.h"
27#include "susp.h"
28#include "brake.h"
29#include "axle.h"
30#include "steer.h"
31#include "wheel.h"
32#include "transmission.h"
33#include "engine.h"
34
35typedef struct
36{
37 /* driver's interface */
39 void *params;
41
43
44 /* components */
51 tTransmission transmission; /* includes clutch, gearbox and driveshaft */
53
54 /* static */
55 t3Dd dimension; /* car's mesures */
56 tdble mass; /* mass with pilot (without fuel) */
57 tdble Minv; /* 1 / mass with pilot (without fuel) */
58 tdble tank; /* fuel tank capa */
59 t3Dd statGC; /* static pos of GC */
60 t3Dd Iinv; /* inverse of inertial moment along the car's 3 axis */
61
62 /* dynamic */
63 tdble fuel; /* current fuel load */
64 tDynPt DynGC; /* GC local data except position */
65 tDynPt DynGCg; /* GC global data */
66 double worldPosX; /* high-precision global position accumulator */
67 double worldPosY;
68 tdble publishedPosX; /* last float position mirrored in DynGCg */
70 tPosd VelColl; /* resulting velocity after collision */
71 tDynPt preDynGC; /* previous one */
72 tTrkLocPos trkPos; /* current track position */
73 tdble airSpeed2; /* current air speed (squared) for aerodynamic forces */
74
75 /* internals */
78 tDynPt corner[4]; /* x,y,z for static relative pos, ax,ay,az for dyn. world coord */
84 sgMat4 posMat;
85 DtShapeRef shape; /* for collision */
86 int blocked; // Flag to show if the car has had already a collision in the same timestep.
88
89 tDynPt restPos; /* target rest position after the car is broken */
90
92 tdble speed; // total speed = sqrt(vx*vx + vy*vy + vz*vz)
93
94 tdble localTemperature; // Environment temperature for the car
95 tdble localPressure; // Environment pressure for the car
96} tCar;
97
98#if 0
99
100#define CHECK_VAR(_var_, _msg_) do { \
101 if (isnan(_var_) || isinf(_var_)) { \
102 printf("%s = %f in %s line %d\n", _msg_, _var_, __FILE__, __LINE__); \
103 assert (0); \
104 exit(0); \
105 } \
106} while (0)
107
108#define DUMP_CAR(_car_) do { \
109 printf("DynGC.acc.x = %f\n", (_car_)->DynGC.acc.x); \
110 printf("DynGC.acc.y = %f\n", (_car_)->DynGC.acc.y); \
111 printf("DynGC.acc.y = %f\n", (_car_)->DynGC.acc.y); \
112 printf("DynGC.vel.x = %f\n", (_car_)->DynGC.vel.x); \
113 printf("DynGC.vel.y = %f\n", (_car_)->DynGC.vel.y); \
114 printf("DynGCg.pos.x = %f\n", (_car_)->DynGCg.pos.x); \
115 printf("DynGCg.pos.y = %f\n", (_car_)->DynGCg.pos.y); \
116 printf("DynGCg.acc.x = %f\n", (_car_)->DynGCg.acc.x); \
117 printf("DynGCg.acc.y = %f\n", (_car_)->DynGCg.acc.y); \
118 printf("DynGCg.vel.x = %f\n", (_car_)->DynGCg.vel.x); \
119 printf("DynGCg.vel.y = %f\n", (_car_)->DynGCg.vel.y); \
120 printf("DynGCg.pos.x = %f\n", (_car_)->DynGCg.pos.x); \
121 printf("DynGCg.pos.y = %f\n", (_car_)->DynGCg.pos.y); \
122 printf("aero.drag = %f\n", (_car_)->aero.drag); \
123} while (0)
124
125
126#define CHECK(_car_) do { \
127 if (isnan((_car_)->DynGC.acc.x) || isinf((_car_)->DynGC.acc.x) || \
128 isnan((_car_)->DynGC.acc.y) || isinf((_car_)->DynGC.acc.y) || \
129 isnan((_car_)->DynGC.vel.x) || isinf((_car_)->DynGC.vel.x) || \
130 isnan((_car_)->DynGC.vel.y) || isinf((_car_)->DynGC.vel.y) || \
131 isnan((_car_)->DynGC.acc.x) || isinf((_car_)->DynGC.acc.x) || \
132 isnan((_car_)->DynGCg.acc.y) || isinf((_car_)->DynGCg.acc.y) || \
133 isnan((_car_)->DynGCg.vel.x) || isinf((_car_)->DynGCg.vel.x) || \
134 isnan((_car_)->DynGCg.vel.y) || isinf((_car_)->DynGCg.vel.y) || \
135 isnan((_car_)->DynGCg.pos.x) || isinf((_car_)->DynGCg.pos.x) || \
136 isnan((_car_)->DynGCg.pos.y) || isinf((_car_)->DynGCg.pos.y) || \
137 isnan((_car_)->aero.drag) || isinf((_car_)->aero.drag)) { \
138 printf("Problem for %s in %s line %d\n", (_car_)->carElt->_name, __FILE__, __LINE__); \
139 DUMP_CAR(_car_); \
140 assert (0); \
141 /* GfScrShutdown(); */ \
142 exit(0); \
143 } \
144} while (0)
145
146#else
147
148#define CHECK_VAR(_var_, _msg_)
149#define CHECK(_car_)
150
151#endif
152
153#endif /* _CAR__H_ */
154
155
156
157
158
159
160
161
struct CarElt tCarElt
Car structure (tCarElt).
float tdble
Floating point type used in TORCS.
Definition tgf.h:47
void * DtShapeRef
Definition solid.h:40
3D point.
Definition tgf.h:114
Definition aero.h:24
Definition axle.h:28
Info returned by driver during the race.
Definition car.h:346
int blocked
Definition carstruct.h:86
tdble fuel
Definition carstruct.h:63
tAxle axle[2]
Definition carstruct.h:45
tPosd VelColl
Definition carstruct.h:70
tSteer steer
Definition carstruct.h:47
tWheel wheel[4]
Definition carstruct.h:46
tWing wing[2]
Definition carstruct.h:50
t3Dd dimension
Definition carstruct.h:55
tDynPt DynGCg
Definition carstruct.h:65
tAero aero
Definition carstruct.h:49
tBrakeSyst brkSyst
Definition carstruct.h:48
tdble publishedPosX
Definition carstruct.h:68
t3Dd Iinv
Definition carstruct.h:60
t3Dd collpos
Definition carstruct.h:81
tdble wheeltrack
Definition carstruct.h:83
t3Dd statGC
Definition carstruct.h:59
void * params
Definition carstruct.h:39
DtShapeRef shape
Definition carstruct.h:85
tTransmission transmission
Definition carstruct.h:51
tCarElt * carElt
Definition carstruct.h:40
tdble Sinz
Definition carstruct.h:77
double worldPosX
Definition carstruct.h:66
tdble airSpeed2
Definition carstruct.h:73
tdble speed
Definition carstruct.h:92
tDynPt DynGC
Definition carstruct.h:64
tdble publishedPosY
Definition carstruct.h:69
t3Dd normal
Definition carstruct.h:80
tEngine engine
Definition carstruct.h:52
tdble wheelbase
Definition carstruct.h:82
int collision
Definition carstruct.h:79
tCarCtrl preCtrl
Definition carstruct.h:42
tTrkLocPos trkPos
Definition carstruct.h:72
tDynPt corner[4]
Definition carstruct.h:78
tCarCtrl * ctrl
Definition carstruct.h:38
tdble tank
Definition carstruct.h:58
tdble localPressure
Definition carstruct.h:95
sgMat4 posMat
Definition carstruct.h:84
double worldPosY
Definition carstruct.h:67
tdble localTemperature
Definition carstruct.h:94
tDynPt restPos
Definition carstruct.h:89
tdble Cosz
Definition carstruct.h:76
tdble Minv
Definition carstruct.h:57
int dammage
Definition carstruct.h:87
tDynPt preDynGC
Definition carstruct.h:71
tdble mass
Definition carstruct.h:56
int collisionAware
Definition carstruct.h:91
Dynamic point structure.
Definition tgf.h:142
6 DOF position.
Definition tgf.h:129
Definition steer.h:24
Location on the track in local coordinates.
Definition track.h:434
Definition wheel.h:26
Definition aero.h:37