TORCS  1.3.9
The Open Racing Car Simulator
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 
35 typedef struct
36 {
37  /* driver's interface */
39  void *params;
41 
43 
44  /* components */
45  tAxle axle[2];
46  tWheel wheel[4];
50  tWing wing[2];
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  tPosd VelColl; /* resulting velocity after collision */
67  tDynPt preDynGC; /* previous one */
68  tTrkLocPos trkPos; /* current track position */
69  tdble airSpeed2; /* current air speed (squared) for aerodynamic forces */
70 
71  /* internals */
74  tDynPt corner[4]; /* x,y,z for static relative pos, ax,ay,az for dyn. world coord */
75  int collision;
80  sgMat4 posMat;
81  DtShapeRef shape; /* for collision */
82  int blocked; // Flag to show if the car has had already a collision in the same timestep.
83  int dammage;
84 
85  tDynPt restPos; /* target rest position after the car is broken */
86 
88  tdble speed; // total speed = sqrt(vx*vx + vy*vy + vz*vz)
89 
90  tdble localTemperature; // Environment temperature for the car
91  tdble localPressure; // Environment pressure for the car
92 } tCar;
93 
94 #if 0
95 
96 #define CHECK_VAR(_var_, _msg_) do { \
97  if (isnan(_var_) || isinf(_var_)) { \
98  printf("%s = %f in %s line %d\n", _msg_, _var_, __FILE__, __LINE__); \
99  assert (0); \
100  exit(0); \
101  } \
102 } while (0)
103 
104 #define DUMP_CAR(_car_) do { \
105  printf("DynGC.acc.x = %f\n", (_car_)->DynGC.acc.x); \
106  printf("DynGC.acc.y = %f\n", (_car_)->DynGC.acc.y); \
107  printf("DynGC.acc.y = %f\n", (_car_)->DynGC.acc.y); \
108  printf("DynGC.vel.x = %f\n", (_car_)->DynGC.vel.x); \
109  printf("DynGC.vel.y = %f\n", (_car_)->DynGC.vel.y); \
110  printf("DynGCg.pos.x = %f\n", (_car_)->DynGCg.pos.x); \
111  printf("DynGCg.pos.y = %f\n", (_car_)->DynGCg.pos.y); \
112  printf("DynGCg.acc.x = %f\n", (_car_)->DynGCg.acc.x); \
113  printf("DynGCg.acc.y = %f\n", (_car_)->DynGCg.acc.y); \
114  printf("DynGCg.vel.x = %f\n", (_car_)->DynGCg.vel.x); \
115  printf("DynGCg.vel.y = %f\n", (_car_)->DynGCg.vel.y); \
116  printf("DynGCg.pos.x = %f\n", (_car_)->DynGCg.pos.x); \
117  printf("DynGCg.pos.y = %f\n", (_car_)->DynGCg.pos.y); \
118  printf("aero.drag = %f\n", (_car_)->aero.drag); \
119 } while (0)
120 
121 
122 #define CHECK(_car_) do { \
123  if (isnan((_car_)->DynGC.acc.x) || isinf((_car_)->DynGC.acc.x) || \
124  isnan((_car_)->DynGC.acc.y) || isinf((_car_)->DynGC.acc.y) || \
125  isnan((_car_)->DynGC.vel.x) || isinf((_car_)->DynGC.vel.x) || \
126  isnan((_car_)->DynGC.vel.y) || isinf((_car_)->DynGC.vel.y) || \
127  isnan((_car_)->DynGC.acc.x) || isinf((_car_)->DynGC.acc.x) || \
128  isnan((_car_)->DynGCg.acc.y) || isinf((_car_)->DynGCg.acc.y) || \
129  isnan((_car_)->DynGCg.vel.x) || isinf((_car_)->DynGCg.vel.x) || \
130  isnan((_car_)->DynGCg.vel.y) || isinf((_car_)->DynGCg.vel.y) || \
131  isnan((_car_)->DynGCg.pos.x) || isinf((_car_)->DynGCg.pos.x) || \
132  isnan((_car_)->DynGCg.pos.y) || isinf((_car_)->DynGCg.pos.y) || \
133  isnan((_car_)->aero.drag) || isinf((_car_)->aero.drag)) { \
134  printf("Problem for %s in %s line %d\n", (_car_)->carElt->_name, __FILE__, __LINE__); \
135  DUMP_CAR(_car_); \
136  assert (0); \
137  /* GfScrShutdown(); */ \
138  exit(0); \
139  } \
140 } while (0)
141 
142 #else
143 
144 #define CHECK_VAR(_var_, _msg_)
145 #define CHECK(_car_)
146 
147 #endif
148 
149 #endif /* _CAR__H_ */
150 
151 
152 
153 
154 
155 
156 
157 
tdble wheeltrack
Definition: carstruct.h:79
tdble fuel
Definition: carstruct.h:63
void * params
Definition: carstruct.h:39
tDynPt preDynGC
Definition: carstruct.h:67
int collision
Definition: carstruct.h:75
tDynPt DynGC
Definition: carstruct.h:64
tdble wheelbase
Definition: carstruct.h:78
Definition: axle.h:27
Location on the track in local coordinates.
Definition: track.h:418
tdble Minv
Definition: carstruct.h:57
Car structure (tCarElt).
Definition: car.h:455
Definition: carstruct.h:35
tCarCtrl * ctrl
Definition: carstruct.h:38
Definition: aero.h:36
tDynPt restPos
Definition: carstruct.h:85
t3Dd Iinv
Definition: carstruct.h:60
t3Dd dimension
Definition: carstruct.h:55
tSteer steer
Definition: carstruct.h:47
Definition: wheel.h:25
tAero aero
Definition: carstruct.h:49
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
tTrkLocPos trkPos
Definition: carstruct.h:68
tdble speed
Definition: carstruct.h:88
tCarElt * carElt
Definition: carstruct.h:40
tdble Cosz
Definition: carstruct.h:72
DtShapeRef shape
Definition: carstruct.h:81
Definition: engine.h:39
t3Dd collpos
Definition: carstruct.h:77
6 DOF position.
Definition: tgf.h:130
tDynPt DynGCg
Definition: carstruct.h:65
tBrakeSyst brkSyst
Definition: carstruct.h:48
tdble tank
Definition: carstruct.h:58
t3Dd normal
Definition: carstruct.h:76
tdble localTemperature
Definition: carstruct.h:90
tdble airSpeed2
Definition: carstruct.h:69
sgMat4 posMat
Definition: carstruct.h:80
int collisionAware
Definition: carstruct.h:87
tdble Sinz
Definition: carstruct.h:73
Definition: steer.h:23
tTransmission transmission
Definition: carstruct.h:51
Definition: aero.h:23
tEngine engine
Definition: carstruct.h:52
int dammage
Definition: carstruct.h:83
tPosd VelColl
Definition: carstruct.h:66
3D point.
Definition: tgf.h:115
tdble mass
Definition: carstruct.h:56
int blocked
Definition: carstruct.h:82
t3Dd statGC
Definition: carstruct.h:59
tdble localPressure
Definition: carstruct.h:91
Dynamic point structure.
Definition: tgf.h:142
Info returned by driver during the race.
Definition: car.h:344
void * DtShapeRef
Definition: solid.h:40
tCarCtrl preCtrl
Definition: carstruct.h:42