ABS and TCL as 500 Hz single wheel controlling system in simuV4 as option/feature
Test with car sc-boxer-96 git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5816 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 05e57d5a9545757c74a9985e8ffdb18064b2632a Former-commit-id: 414c8d809e5133ea4c681c3c52857bc6de7c41d8
This commit is contained in:
parent
fcfe8c65ed
commit
edbfd028f2
6 changed files with 156 additions and 5 deletions
|
@ -27,7 +27,30 @@ SimBrakeConfig(void *hdle, const char *section, tBrake *brake)
|
|||
diam = GfParmGetNum(hdle, section, PRM_BRKDIAM, (char*)NULL, 0.2f);
|
||||
area = GfParmGetNum(hdle, section, PRM_BRKAREA, (char*)NULL, 0.002f);
|
||||
mu = GfParmGetNum(hdle, section, PRM_MU, (char*)NULL, 0.30f);
|
||||
brake->coeff = (tdble) (diam * 0.5 * area * mu);
|
||||
|
||||
// Option TCL ...
|
||||
//if (car->features & FEAT_TCLINSIMU)
|
||||
{
|
||||
brake->TCL = 1.0f;
|
||||
brake->TCLMin = 1.0f;
|
||||
}
|
||||
// ... Option TCL
|
||||
// Option ABS ...
|
||||
//if (car->features & FEAT_ABSINSIMU)
|
||||
{
|
||||
brake->ABS = 1.0f;
|
||||
brake->EnableABS
|
||||
= GfParmGetNum(hdle, section, PRM_ABSINSIMU, (char*)NULL, 0.0f) > 0;
|
||||
/*
|
||||
if (brake->EnableABS)
|
||||
fprintf(stderr,"ABS: Enabled\n");
|
||||
else
|
||||
fprintf(stderr,"ABS: Disabled\n");
|
||||
*/
|
||||
}
|
||||
// ... Option ABS
|
||||
|
||||
brake->coeff = (tdble) (diam * 0.5 * area * mu);
|
||||
|
||||
brake->I = GfParmGetNum(hdle, section, PRM_INERTIA, (char*)NULL, 0.13f);
|
||||
brake->radius = diam/2.0f;
|
||||
|
@ -38,6 +61,22 @@ SimBrakeUpdate(tCar *car, tWheel *wheel, tBrake *brake)
|
|||
{
|
||||
brake->Tq = brake->coeff * brake->pressure;
|
||||
|
||||
// Option ABS ...
|
||||
if (car->features & FEAT_ABSINSIMU)
|
||||
{
|
||||
if (brake->EnableABS)
|
||||
brake->Tq *= brake->ABS;
|
||||
}
|
||||
// ... Option ABS
|
||||
// Option TCL ...
|
||||
if (car->features & FEAT_TCLINSIMU)
|
||||
{
|
||||
tdble TCL_BrakeScale = 400.0f; // Make it be a parameter later
|
||||
if ((brake->TCLMin < 1.0) && (brake->TCLMin == brake->TCL))
|
||||
brake->Tq += TCL_BrakeScale/brake->TCL;
|
||||
}
|
||||
// ... Option TCL
|
||||
|
||||
brake->temp -= (tdble) (fabs(car->DynGC.vel.x) * 0.0001 + 0.0002);
|
||||
if (brake->temp < 0 ) brake->temp = 0;
|
||||
brake->temp += (tdble) (brake->pressure * brake->radius * fabs(wheel->spinVel) * 0.00000000005);
|
||||
|
|
|
@ -28,6 +28,21 @@ typedef struct
|
|||
tdble I;
|
||||
tdble radius;
|
||||
tdble temp;
|
||||
|
||||
// Options that can be enabled in simuV4
|
||||
// by parameters in the car type setup file
|
||||
|
||||
// Add variables here (tdble)
|
||||
// TCL ...
|
||||
tdble TCL; // TCL factor
|
||||
tdble TCLMin; // Minimum of TCL factors at all wheels
|
||||
// ... TCL
|
||||
// ABS ...
|
||||
tdble ABS; // ABS factor
|
||||
// ... ABS
|
||||
|
||||
// Add switches here (bool)
|
||||
bool EnableABS; // Switch to enable ABS
|
||||
} tBrake;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
const tdble aMax = 1.0f; /* */
|
||||
static const char *SuspSect[4] = {SECT_FRNTRGTSUSP, SECT_FRNTLFTSUSP, SECT_REARRGTSUSP, SECT_REARLFTSUSP};
|
||||
|
||||
// The "Simu" logger instance
|
||||
GfLogger* PLogSimu = 0;
|
||||
|
||||
void
|
||||
SimCarConfig(tCar *car)
|
||||
{
|
||||
|
@ -66,6 +69,14 @@ SimCarConfig(tCar *car)
|
|||
if (strcmp(enabling, VAL_YES) == 0) {
|
||||
car->features = car->features | FEAT_FIXEDWHEELFORCE;
|
||||
}
|
||||
enabling = GfParmGetStr(hdle, SECT_FEATURES, PRM_TCLINSIMU, VAL_NO);
|
||||
if (strcmp(enabling, VAL_YES) == 0) {
|
||||
car->features = car->features | FEAT_TCLINSIMU;
|
||||
}
|
||||
enabling = GfParmGetStr(hdle, SECT_FEATURES, PRM_ABSINSIMU, VAL_NO);
|
||||
if (strcmp(enabling, VAL_YES) == 0) {
|
||||
car->features = car->features | FEAT_ABSINSIMU;
|
||||
}
|
||||
|
||||
/* continue with car parameters */
|
||||
car->dimension.x = GfParmGetNum(hdle, SECT_CAR, PRM_LEN, (char*)NULL, 4.7f);
|
||||
|
@ -114,10 +125,10 @@ SimCarConfig(tCar *car)
|
|||
wf0 = w * gcfr;
|
||||
wr0 = w * (1 - gcfr);
|
||||
|
||||
car->wheel[FRNT_RGT].weight0 = wf0 * gcfrl * K[FRNT_RGT] / (K[FRNT_RGT] + 0.5*Kfheave);
|
||||
car->wheel[FRNT_LFT].weight0 = wf0 * (1 - gcfrl) * K[FRNT_LFT] / (K[FRNT_LFT] + 0.5*Kfheave);
|
||||
car->wheel[REAR_RGT].weight0 = wr0 * gcrrl * K[REAR_RGT] / (K[REAR_RGT] + 0.5*Krheave);
|
||||
car->wheel[REAR_LFT].weight0 = wr0 * (1 - gcrrl) * K[REAR_LFT] / (K[REAR_LFT] + 0.5*Krheave);
|
||||
car->wheel[FRNT_RGT].weight0 = wf0 * gcfrl * K[FRNT_RGT] / (K[FRNT_RGT] + 0.5f*Kfheave);
|
||||
car->wheel[FRNT_LFT].weight0 = wf0 * (1 - gcfrl) * K[FRNT_LFT] / (K[FRNT_LFT] + 0.5f*Kfheave);
|
||||
car->wheel[REAR_RGT].weight0 = wr0 * gcrrl * K[REAR_RGT] / (K[REAR_RGT] + 0.5f*Krheave);
|
||||
car->wheel[REAR_LFT].weight0 = wr0 * (1 - gcrrl) * K[REAR_LFT] / (K[REAR_LFT] + 0.5f*Krheave);
|
||||
|
||||
/*for (i = 0; i < 2; i++) {
|
||||
SimAxleConfig(car, i, 0.0);
|
||||
|
|
|
@ -49,6 +49,18 @@ SimEngineConfig(tCar *car)
|
|||
car->engine.I_joint = car->engine.I;
|
||||
car->engine.timeInLimiter = 0.0f;
|
||||
|
||||
// Option TCL ...
|
||||
if (car->features & FEAT_TCLINSIMU)
|
||||
{
|
||||
car->engine.TCL = 1.0f;
|
||||
car->engine.EnableTCL = GfParmGetNum(hdle, SECT_ENGINE, PRM_TCLINSIMU, (char*)NULL, 0.0f) > 0;
|
||||
if (car->engine.EnableTCL)
|
||||
fprintf(stderr,"TCL: Enabled\n");
|
||||
else
|
||||
fprintf(stderr,"TCL: Disabled\n");
|
||||
}
|
||||
// ... Option TCL
|
||||
|
||||
sprintf(idx, "%s/%s", SECT_ENGINE, ARR_DATAPTS);
|
||||
car->engine.curve.nbPts = GfParmGetEltNb(hdle, idx);
|
||||
edesc = (struct tEdesc*)malloc((car->engine.curve.nbPts + 1) * sizeof(struct tEdesc));
|
||||
|
@ -156,6 +168,19 @@ SimEngineUpdateTq(tCar *car)
|
|||
engine->timeInLimiter = 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
// Option TCL ...
|
||||
if (car->features & FEAT_TCLINSIMU)
|
||||
{
|
||||
if (engine->EnableTCL)
|
||||
Tq_max *= engine->TCL;
|
||||
/*
|
||||
if (engine->EnableTCL)
|
||||
fprintf(stderr,"TCL: %.1f %%\n", engine->TCL * 100);
|
||||
*/
|
||||
}
|
||||
// ... Option TCL
|
||||
|
||||
if ( (car->features & FEAT_REVLIMIT) && (engine->timeInLimiter > 0.0f) ) {
|
||||
alpha = 0.0;
|
||||
engine->timeInLimiter -= SimDeltaTime;
|
||||
|
|
|
@ -54,6 +54,9 @@ typedef struct
|
|||
tdble exhaust_pressure;
|
||||
tdble exhaust_refract;
|
||||
tdble timeInLimiter; /* time to still spend with fuel cut, in secundum */
|
||||
|
||||
tdble TCL; // Optional TCL
|
||||
bool EnableTCL; // Enable optional TCL
|
||||
} tEngine;
|
||||
|
||||
#endif /* _ENGINE_H_ */
|
||||
|
|
|
@ -169,6 +169,18 @@ void SimWheelUpdateRide(tCar *car, int index)
|
|||
|
||||
// update wheel brake
|
||||
SimBrakeUpdate(car, wheel, &(wheel->brake));
|
||||
|
||||
// Option TCL ...
|
||||
if (car->features & FEAT_TCLINSIMU)
|
||||
{
|
||||
if (index == 3)
|
||||
{ // After using the values for the last wheel
|
||||
tEngine *engine = &(car->engine);
|
||||
engine->TCL = 1.0; // Reset the TCL accel command
|
||||
wheel->brake.TCLMin = 1.0; // Reset the TCL brake command reference value
|
||||
}
|
||||
}
|
||||
// ... Option TCL
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,6 +363,52 @@ void SimWheelUpdateForce(tCar *car, int index)
|
|||
car->carElt->_tyreT_out(index) = wheel->Ttire;
|
||||
car->carElt->_tyreCondition(index) = tireCond;
|
||||
}
|
||||
|
||||
// Option TCL ...
|
||||
if (car->features & FEAT_TCLINSIMU)
|
||||
{
|
||||
tdble TCL_SlipScale = 0.1f; // Make it be a parameter later
|
||||
tdble TCL_BrakeScale = 1/60.0f; // Make it be a parameter later
|
||||
tdble TCL_AccelScale = 0.5f; // Make it be a parameter later
|
||||
|
||||
tEngine *engine = &(car->engine); // Get engine
|
||||
if (sx < -TCL_SlipScale) // Slip is over our limit
|
||||
{ // Store the TCL_Brake command for this wheel
|
||||
wheel->brake.TCL = 1 + TCL_BrakeScale/sx;
|
||||
if (wheel->brake.TCLMin > wheel->brake.TCL)
|
||||
{ // We need the minimum for all driven wheels later
|
||||
engine->TCL = TCL_AccelScale * wheel->brake.TCL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Keep the minimum for all dSriven wheels
|
||||
engine->TCL = (tdble) MIN(1.0,engine->TCL);
|
||||
}
|
||||
}
|
||||
// ... Optional TCL
|
||||
|
||||
// Optional ABS ...
|
||||
if (car->features & FEAT_ABSINSIMU)
|
||||
{
|
||||
tdble ABS_SlipScale = 0.1f; // Make it be a parameter later
|
||||
tdble ABS_BrakeScale = 1.0f; // Make it be a parameter later
|
||||
|
||||
// If slip is over the limit, set brake command for this wheel
|
||||
if (sx > ABS_SlipScale)
|
||||
wheel->brake.ABS = 1 - ABS_BrakeScale * sx;
|
||||
else
|
||||
wheel->brake.ABS = 1.0f;
|
||||
/**/
|
||||
if (wheel->brake.EnableABS)
|
||||
{
|
||||
if (index == 0)
|
||||
fprintf(stderr,"\nABS: %.1f %% ", wheel->brake.ABS * 100);
|
||||
else
|
||||
fprintf(stderr," %.1f %% ", wheel->brake.ABS * 100);
|
||||
}
|
||||
/**/
|
||||
}
|
||||
// ... Optional ABS
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue