add color gauges to the G-graph to represent each tires slip
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6254 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 2723ae7daf8fef96a3380a1b1cfb6a5a15073899 Former-commit-id: 9d8a79441e9cbcecd11c661e9498c139a1addb3a
This commit is contained in:
parent
3d8091c201
commit
d5ae0cd2b5
3 changed files with 77 additions and 1 deletions
|
@ -303,6 +303,7 @@ typedef struct {
|
|||
tdble treadDepth; /**< tread depth, between 0 and 1 */
|
||||
tdble critTreadDepth; /**< critical tread depth, when grip falls off suddenly, between 0 and treadDepth */
|
||||
tdble slipNorm; /* normalized slip, the variable of Magic Formula */
|
||||
tdble slipOpt; /* the value of slipNorm giving maximal grip */
|
||||
tdble slipSide;
|
||||
tdble slipAccel;
|
||||
tdble Fx;
|
||||
|
@ -316,6 +317,7 @@ typedef struct {
|
|||
#define _wheelSpinVel(i) priv.wheel[i].spinVel
|
||||
#define _wheelSeg(i) priv.wheel[i].seg
|
||||
#define _wheelSlipNorm(i) priv.wheel[i].slipNorm
|
||||
#define _wheelSlipOpt(i) priv.wheel[i].slipOpt
|
||||
#define _wheelSlipSide(i) priv.wheel[i].slipSide
|
||||
#define _wheelSlipAccel(i) priv.wheel[i].slipAccel
|
||||
#define _wheelFx(i) priv.wheel[i].Fx
|
||||
|
|
|
@ -40,6 +40,7 @@ static const string rgba[4] =
|
|||
|
||||
static const int NB_BOARDS = 3;
|
||||
static const int NB_LBOARDS = 5; // # of leaderboard states
|
||||
static const int NB_GFLAG = 3;
|
||||
static const int NB_DEBUG = 4;
|
||||
|
||||
// Boards work on a OrthoCam with fixed height of 600, width flows
|
||||
|
@ -184,7 +185,7 @@ cGrBoard::selectBoard(int val)
|
|||
GfParmSetNum(grHandle, path, GR_ATT_DEBUG, (char*)NULL, (tdble)debugFlag);
|
||||
break;
|
||||
case 4:
|
||||
GFlag = 1 - GFlag;
|
||||
GFlag = (GFlag + 1) % NB_GFLAG;
|
||||
GfParmSetNum(grHandle, path, GR_ATT_GGRAPH, (char*)NULL, (tdble)GFlag);
|
||||
break;
|
||||
case 5:
|
||||
|
@ -362,6 +363,55 @@ cGrBoard::grDispGGraph()
|
|||
glVertex2f(XC + THNSS, YC);
|
||||
glVertex2f(XC + THNSS, YC + car_->ctrl.clutchCmd * 100.0f);
|
||||
glVertex2f(XC - THNSS, YC + car_->ctrl.clutchCmd * 100.0f);
|
||||
|
||||
// Draw the tire slip color gauges
|
||||
if (GFlag == 2) {
|
||||
tdble s;
|
||||
// FR wheel
|
||||
s = car_->_wheelSlipNorm(0)/car_->_wheelSlipOpt(0);
|
||||
if (s > 1.0) {
|
||||
glColor4f(1.0f, 0.0f, MIN(1.0f, s - 1.0), 0.9f);
|
||||
} else {
|
||||
glColor4f(s, s, 1.0f - s, 0.9f);
|
||||
}
|
||||
glVertex2f(X1 + 40.0f, Y1 + 30.0f);
|
||||
glVertex2f(X1 + 50.0f, Y1 + 30.0f);
|
||||
glVertex2f(X1 + 50.0f, Y1 + 50.0f);
|
||||
glVertex2f(X1 + 40.0f, Y1 + 50.0f);
|
||||
// FL wheel
|
||||
s = car_->_wheelSlipNorm(1)/car_->_wheelSlipOpt(1);
|
||||
if (s > 1.0) {
|
||||
glColor4f(1.0f, 0.0f, MIN(1.0f, s - 1.0), 0.9f);
|
||||
} else {
|
||||
glColor4f(s, s, 1.0f - s, 0.9f);
|
||||
}
|
||||
glVertex2f(X1 - 50.0f, Y1 + 30.0f);
|
||||
glVertex2f(X1 - 40.0f, Y1 + 30.0f);
|
||||
glVertex2f(X1 - 40.0f, Y1 + 50.0f);
|
||||
glVertex2f(X1 - 50.0f, Y1 + 50.0f);
|
||||
// RR wheel
|
||||
s = car_->_wheelSlipNorm(2)/car_->_wheelSlipOpt(2);
|
||||
if (s > 1.0) {
|
||||
glColor4f(1.0f, 0.0f, MIN(1.0f, s - 1.0), 0.9f);
|
||||
} else {
|
||||
glColor4f(s, s, 1.0f - s, 0.9f);
|
||||
}
|
||||
glVertex2f(X1 + 40.0f, Y1 - 50.0f);
|
||||
glVertex2f(X1 + 50.0f, Y1 - 50.0f);
|
||||
glVertex2f(X1 + 50.0f, Y1 - 30.0f);
|
||||
glVertex2f(X1 + 40.0f, Y1 - 30.0f);
|
||||
// RL wheel
|
||||
s = car_->_wheelSlipNorm(3)/car_->_wheelSlipOpt(3);
|
||||
if (s > 1.0) {
|
||||
glColor4f(1.0f, 0.0f, MIN(1.0f, s - 1.0), 0.9f);
|
||||
} else {
|
||||
glColor4f(s, s, 1.0f - s, 0.9f);
|
||||
}
|
||||
glVertex2f(X1 - 50.0f, Y1 - 50.0f);
|
||||
glVertex2f(X1 - 40.0f, Y1 - 50.0f);
|
||||
glVertex2f(X1 - 40.0f, Y1 - 30.0f);
|
||||
glVertex2f(X1 - 50.0f, Y1 - 30.0f);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
|
@ -374,6 +424,7 @@ cGrBoard::grDispGGraph()
|
|||
glColor4fv(emphasized_color_);
|
||||
glVertex2f(X1, Y1);
|
||||
glVertex2f(X2, Y2);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,29 @@ SimWheelConfig(tCar *car, int index)
|
|||
wheel->feedBack.Tq = 0.0f;
|
||||
wheel->feedBack.brkTq = 0.0f;
|
||||
wheel->torques.x = wheel->torques.y = wheel->torques.z = 0.0f;
|
||||
|
||||
/* calculate optimal slip value */
|
||||
tdble s, Bx, low, high;
|
||||
int i;
|
||||
//wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx))
|
||||
Bx = PI_2 / wheel->mfC;
|
||||
low = high = Bx;
|
||||
while (wheel->mfC * atan(low * (1.0f - wheel->mfE) + wheel->mfE * atan(low)) > PI_2) {
|
||||
low *= 0.9;
|
||||
}
|
||||
while (wheel->mfC * atan(high * (1.0f - wheel->mfE) + wheel->mfE * atan(high)) < PI_2) {
|
||||
high *=1.1;
|
||||
}
|
||||
for (i = 0; i < 32; i++) {
|
||||
Bx = 0.5 * (low + high);
|
||||
if (wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx)) < PI_2) {
|
||||
low = Bx;
|
||||
} else {
|
||||
high = Bx;
|
||||
}
|
||||
}
|
||||
s = 0.5 * (low + high) / wheel->mfB;
|
||||
car->carElt->_wheelSlipOpt(index) = s;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue