- update simuV4

- update USR for tyre & degradation
- update DanDroid for tyre & degradation
- update shadow for tyre & degradation

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7516 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: d4cd162f051d38d34003a1d30798a2e2abac293f
Former-commit-id: 6fd5ccf2aae610fb2bb0dfe976d761507041840e
This commit is contained in:
torcs-ng 2021-05-20 21:00:41 +00:00
parent 2705a7a9eb
commit 98419bb92b
10 changed files with 2271 additions and 2167 deletions

File diff suppressed because it is too large Load diff

View file

@ -124,6 +124,12 @@ class TDriver {
double filterTCL_FWD();
double filterTCL_RWD();
double filterTCLSideSlip(double accel);
double TyreConditionFront();
double TyreConditionRear();
double TyreCondition();
double TyreTreadDepthFront();
double TyreTreadDepthRear();
double TyreTreadDepth();
void readPrivateSection(PCarSettings *CarParmHandle);
void readConstSpecs(PCarHandle CarHandle);
void readVarSpecs(PCarSettings CarParmHandle);
@ -142,6 +148,7 @@ class TDriver {
void driverMsg(std::string desc);
void driverMsgValue(int priority, std::string desc, double value);
// Per robot global data
int mDrvPath;
int mDrvPath_prev;
@ -336,6 +343,10 @@ class TDriver {
double mOVT_FRONTSPACE;
double mOVT_FRONTMARGIN;
double mSTARTCLUTCHRATE;
bool mHASTYC;
bool mHASABS;
bool mHASTCL;
bool mHASESP;
};
#endif // _DRIVER_H_

View file

@ -392,7 +392,7 @@ void CarModel::update( const tCarElt* car, const tSituation* sit )
WEARTREAD = MN(MN(car->priv.wheel[0].treadDepth, car->priv.wheel[1].treadDepth),
MN(car->priv.wheel[2].treadDepth, car->priv.wheel[3].treadDepth));
LogSHADOW.debug("GRIP F = %.3f - GRIP R = %.3f - EFFECTIVEMU = %.3f - WEARTREAD = %.5f\n", GRIP_SCALE_F, GRIP_SCALE_R, EFFECTIVEMU, WEARTREAD);
LogSHADOW.debug("GRIP F = %.3f - GRIP R = %.3f - EFFECTIVEMU = %.3f - WEARTREAD = %.5f - Temperature = %.3f\n", GRIP_SCALE_F, GRIP_SCALE_R, EFFECTIVEMU, WEARTREAD, MN(car->priv.wheel[0].temp_mid, car->priv.wheel[1].temp_mid));
}
updateWheels( car, sit );

View file

@ -115,15 +115,17 @@ double TFixCarParam::CalcAcceleration(
double TcF = oDriver->TyreConditionFront();
double TcR = oDriver->TyreConditionRear();
MU = MIN(TcF*MU,TcR*MU);
LogSimplix.info(" Friction F = %.3f - Friction R = %.3f - Tyre mu = %.3f - Tyre temperature = %.5f\n", TcF, TcR, oCar->priv.wheel[0].effectiveMu,
oCar->priv.wheel[0].temp_mid);
}
double CD = oCdBody *
(1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing;
double CD = oCdBody *
(1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing;
double Crv = (0.25*Crv0 + 0.75*Crv1);
double Crvz = (0.25*Crvz0 + 0.75*Crvz1);
double Crvz = (0.25*Crvz0 + 0.75*Crvz1);
if (Crvz > 0)
Crvz = 0;
Crvz = 0;
double Gdown = G * cos(TrackRollAngle);
double Glat = G * sin(TrackRollAngle);
@ -139,28 +141,28 @@ double TFixCarParam::CalcAcceleration(
double AvgV = (U + V) * 0.5;
double AvgV2 = AvgV * AvgV;
double Fdown = oTmpCarParam->oMass * Gdown
+ (oTmpCarParam->oMass * Crvz + oCa) * AvgV2;
double Fdown = oTmpCarParam->oMass * Gdown
+ (oTmpCarParam->oMass * Crvz + oCa) * AvgV2;
double Froad = Fdown * MU;
double Flat = oTmpCarParam->oMass * Glat;
double Ftan = oTmpCarParam->oMass * Gtan - CD * AvgV2;
double Flatroad = fabs(oTmpCarParam->oMass * AvgV2 * Crv - Flat);
if (Flatroad > Froad)
Flatroad = Froad;
Flatroad = Froad;
double Ftanroad = sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan;
double Ftanroad = sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan;
double Acc = Ftanroad / oTmpCarParam->oMass;
double MaxAcc = MIN(11.5,AccFromSpd.CalcY(AvgV));
double Acc = Ftanroad / oTmpCarParam->oMass;
double MaxAcc = MIN(11.5,AccFromSpd.CalcY(AvgV));
if (Acc > MaxAcc)
Acc = MaxAcc;
Acc = MaxAcc;
double Inner = MAX(0, U * U + 2 * Acc * Dist);
V = sqrt(Inner);
if (fabs(V - OldV) < 0.001)
break;
OldV = V;
double Inner = MAX(0, U * U + 2 * Acc * Dist);
V = sqrt(Inner);
if (fabs(V - OldV) < 0.001)
break;
OldV = V;
}
return V;
}
@ -206,13 +208,13 @@ double TFixCarParam::CalcBraking
Mu = MIN(MuF,MuR);
// From SD:
double Cd = oCdBody *
(1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing;
double Cd = oCdBody *
(1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing;
Crv *= oDriver->CalcCrv(fabs(Crv));
if (Crvz > 0)
Crvz = 0;
Crvz = 0;
double Gdown = G * cos(TrackRollAngle) * cos(TrackTiltAngle);
double Glat = fabs(G * sin(TrackRollAngle));
@ -224,41 +226,41 @@ double TFixCarParam::CalcBraking
for (int I = 0; I < 10; I++)
{
double AvgV = (U + V) * 0.5;
double AvgV2 = AvgV * AvgV;
double AvgV = (U + V) * 0.5;
double AvgV2 = AvgV * AvgV;
double Froad;
double Fdown = oTmpCarParam->oMass * Gdown
+ (oTmpCarParam->oMass * Crvz + (oCaFrontGroundEffect + oCaRearGroundEffect)) * AvgV2;
double Ffrnt = oCaFrontWing * AvgV2;
double Frear = oCaRearWing * AvgV2;
double Froad;
double Fdown = oTmpCarParam->oMass * Gdown
+ (oTmpCarParam->oMass * Crvz + (oCaFrontGroundEffect + oCaRearGroundEffect)) * AvgV2;
double Ffrnt = oCaFrontWing * AvgV2;
double Frear = oCaRearWing * AvgV2;
Froad = 0.95 * Fdown * Mu + Ffrnt * MuF + Frear * MuR;
Froad = 0.95 * Fdown * Mu + Ffrnt * MuF + Frear * MuR;
double Flat = oTmpCarParam->oMass * Glat;
double Ftan = oTmpCarParam->oMass * Gtan - Cd * AvgV2;
double Flat = oTmpCarParam->oMass * Glat;
double Ftan = oTmpCarParam->oMass * Gtan - Cd * AvgV2;
double Flatroad = MAX(0.0,oTmpCarParam->oMass * AvgV2 * fabs(Crv) - Flat);
if (Flatroad > Froad)
Flatroad = Froad;
double Flatroad = MAX(0.0,oTmpCarParam->oMass * AvgV2 * fabs(Crv) - Flat);
if (Flatroad > Froad)
Flatroad = Froad;
double Ftanroad = -sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan;
double Ftanroad = -sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan;
Acc = CarParam.oScaleBrake * Ftanroad
/ (oTmpCarParam->oMass * ( 3 + oTmpCarParam->oSkill) / 4);
if (TDriver::UseBrakeLimit)
{
double Radius = 1.0 / fabs(Crv);
double factor = MIN(1.0,MAX(0.39, (Radius - 190.0) / 100.0));
Acc = MAX(Acc,TDriver::BrakeLimit * factor);
}
Acc = CarParam.oScaleBrake * Ftanroad
/ (oTmpCarParam->oMass * ( 3 + oTmpCarParam->oSkill) / 4);
double Inner = MAX(0, V * V - 2 * Acc * Dist);
double OldU = U;
U = sqrt(Inner);
if (fabs(U - OldU) < 0.001)
break;
if (TDriver::UseBrakeLimit)
{
double Radius = 1.0 / fabs(Crv);
double factor = MIN(1.0,MAX(0.39, (Radius - 190.0) / 100.0));
Acc = MAX(Acc,TDriver::BrakeLimit * factor);
}
double Inner = MAX(0, V * V - 2 * Acc * Dist);
double OldU = U;
U = sqrt(Inner);
if (fabs(U - OldU) < 0.001)
break;
}
double MidSpeed = (U + Speed)/2;
@ -273,7 +275,7 @@ double TFixCarParam::CalcBraking
else
LogSimplix.error("U: %g < B: %g\n",U*3.6,BrakeTargetSpeed*3.6);
*/
// Sanity check
// Sanity check
return (float) MAX(ResultTargetSpeed,Speed);
}
//==========================================================================*
@ -318,13 +320,13 @@ double TFixCarParam::CalcBrakingPit
Mu = MIN(MuF,MuR);
// From TORCS:
double Cd = oCdBody *
(1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing;
double Cd = oCdBody *
(1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing;
Crv *= oDriver->CalcCrv(fabs(Crv));
if (Crvz > 0)
Crvz = 0;
Crvz = 0;
double Gdown = G * cos(TrackRollAngle);
double Glat = G * sin(TrackRollAngle);
@ -335,41 +337,41 @@ double TFixCarParam::CalcBrakingPit
for (int I = 0; I < 10; I++)
{
double AvgV = (U + V) * 0.5;
double AvgV2 = AvgV * AvgV;
double AvgV = (U + V) * 0.5;
double AvgV2 = AvgV * AvgV;
double Froad;
double Fdown = oTmpCarParam->oMass * Gdown
+ (oTmpCarParam->oMass * Crvz + (oCaFrontGroundEffect + oCaRearGroundEffect)) * AvgV2;
double Ffrnt = oCaFrontWing * AvgV2;
double Frear = oCaRearWing * AvgV2;
double Froad;
double Fdown = oTmpCarParam->oMass * Gdown
+ (oTmpCarParam->oMass * Crvz + (oCaFrontGroundEffect + oCaRearGroundEffect)) * AvgV2;
double Ffrnt = oCaFrontWing * AvgV2;
double Frear = oCaRearWing * AvgV2;
Froad = Fdown * Mu + Ffrnt * MuF + Frear * MuR;
Froad = Fdown * Mu + Ffrnt * MuF + Frear * MuR;
double Flat = oTmpCarParam->oMass * Glat;
double Ftan = oTmpCarParam->oMass * Gtan - Cd * AvgV2;
double Flat = oTmpCarParam->oMass * Glat;
double Ftan = oTmpCarParam->oMass * Gtan - Cd * AvgV2;
double Flatroad = fabs(oTmpCarParam->oMass * AvgV2 * Crv - Flat);
if (Flatroad > Froad)
Flatroad = Froad;
double Flatroad = fabs(oTmpCarParam->oMass * AvgV2 * Crv - Flat);
if (Flatroad > Froad)
Flatroad = Froad;
double Ftanroad = -sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan;
double Ftanroad = -sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan;
double Acc = CarParam.oScaleBrakePit * Ftanroad
/ oTmpCarParam->oMass;
double Acc = CarParam.oScaleBrakePit * Ftanroad
/ oTmpCarParam->oMass;
//if (TDriver::UseBrakeLimit)
{
double Radius = 1.0 / fabs(Crv);
double factor = MIN(1.0,MAX(0.39, (Radius - 190.0) / 100.0));
Acc = MAX(Acc,TDriver::BrakeLimit * factor);
}
//if (TDriver::UseBrakeLimit)
{
double Radius = 1.0 / fabs(Crv);
double factor = MIN(1.0,MAX(0.39, (Radius - 190.0) / 100.0));
Acc = MAX(Acc,TDriver::BrakeLimit * factor);
}
double Inner = MAX(0, V * V - 2 * Acc * Dist);
double OldU = U;
U = sqrt(Inner);
if (fabs(U - OldU) < 0.001)
break;
double Inner = MAX(0, V * V - 2 * Acc * Dist);
double OldU = U;
U = sqrt(Inner);
if (fabs(U - OldU) < 0.001)
break;
}
double MidSpeed = (U + Speed)/2;
@ -414,8 +416,8 @@ double TFixCarParam::CalcMaxSpeed
if (oDriver->oCarNeedsSinLong)
{
if (SinLat < SinLong)
Sin = SinLong;
if (SinLat < SinLong)
Sin = SinLong;
}
double AbsCrv0 = MAX(0.001, fabs(Crv0));
@ -424,17 +426,17 @@ double TFixCarParam::CalcMaxSpeed
double factor = 1.0;
if (AbsCrv < 1/200.0)
CrvZ *= oDriver->oCrvZScale;
CrvZ *= oDriver->oCrvZScale;
if (AbsCrv > AbsCrv1)
{
if (oDriver->oUseAccelOut)
factor = 1.015;
if (oDriver->oUseAccelOut)
factor = 1.015;
AbsCrv *= oDriver->CalcCrv(AbsCrv);
}
else
{
factor = 0.985;
factor = 0.985;
AbsCrv *= oDriver->CalcCrv(AbsCrv);
}
@ -460,19 +462,19 @@ double TFixCarParam::CalcMaxSpeed
Mu = MIN(MuF,MuR) / oTmpCarParam->oSkill;
Den = (AbsCrv - ScaleBump * CrvZ)
- (oCaFrontWing * MuF + oCaRearWing * MuR
+ oCaFrontGroundEffect * MuF + oCaRearGroundEffect * MuR) / oTmpCarParam->oMass;
- (oCaFrontWing * MuF + oCaRearWing * MuR
+ oCaFrontGroundEffect * MuF + oCaRearGroundEffect * MuR) / oTmpCarParam->oMass;
if (Den < 0.00001)
Den = 0.00001;
if (AbsCrv > 0.002)
{
if (Sin * SGN(Crv0) < 0)
{
Sin *= 8.0;
Sin = SGN(Sin) * MIN(0.05,fabs(Sin));
}
if (Sin * SGN(Crv0) < 0)
{
Sin *= 8.0;
Sin = SGN(Sin) * MIN(0.05,fabs(Sin));
}
}
double Speed = factor * sqrt((Cos * G * Mu + Sin * G * SGN(Crv0) + CrvZ) / Den);
@ -491,8 +493,8 @@ double TFixCarParam::CalcMaxSpeed
double TFixCarParam::CalcMaxLateralF
(double Speed, double Friction, double Crvz) const
{
double Fdown = oTmpCarParam->oMass * G
+ (oTmpCarParam->oMass * Crvz + oCa) * Speed * Speed;
double Fdown = oTmpCarParam->oMass * G
+ (oTmpCarParam->oMass * Crvz + oCa) * Speed * Speed;
return Fdown * Friction * oTyreMu;
}
//==========================================================================*

View file

@ -211,6 +211,12 @@ void MyCar::update(double dt)
mMass = mCarMass + mFuelWeightFactor * mCar->_fuel;
mSpeedX = mCar->_speed_x;
mTires.update();
if(HASTYC)
{
LogUSR.debug("Friction : %.8f- Tyre temperature = %.3f\n", mTires.TyreCondition(), mCar->priv.wheel[0].temp_mid);
}
mSegMu = mTires.gripFactor() * mTireMu * mCar->_trkPos.seg->surface->kFriction;
mCW = mBodyCW * (1.0 + mCar->_dammage / 10000.0) + mWingCW;
mToMiddle = mCar->_trkPos.toMiddle;

View file

@ -76,21 +76,11 @@ void Tires::update()
double Tires::updateGripFactor() const
{
double gripFactor = 1.0 * mMuScale;
/*double initialTemp = 273.15 + 20.0;
double windowLowTemp = 273.15 + 80.0;
double idealTemp = mCar->info.wheel[0].idealTemperature;
for(int i = 0; i < 4; i++)
if(HasTYC)
{
double currTemp = mCar->priv.wheel[i].currentTemperature;
double currGrain = mCar->priv.wheel[i].currentGraining;
double di = (currTemp >= windowLowTemp ? 1.0 : currTemp - idealTemp) / (idealTemp - initialTemp);
if (currTemp > mHotTemp)
di = ((idealTemp - (currTemp - mHotTemp) * 7) - idealTemp) / (idealTemp - initialTemp);
gripFactor += ((1.0 - (std::min((di * di), 1.0))) / 4.0 + 3.0 / 4.0) * (1.0 - currGrain / 10.0);
}*/
gripFactor *= TyreCondition();
}
return gripFactor;
}

View file

@ -33,7 +33,7 @@ void SimAtmospherePreConfig(tTrack *track)
tm *g = gmtime(&simuTime);
simuMonth = 1 + g->tm_mon;
SimRain = track->local.rain;
SimRain = track->local.rain * 1e-9;
SimTimeOfDay = track->local.timeofday;
SimClouds = track->local.clouds;
Tair = track->local.airtemperature + 273.15f;

View file

@ -124,7 +124,6 @@ extern tdble simDammageFactor[];
extern tdble simSkidFactor[];
extern tdble SimRain;
extern tdble SimWater;
extern tdble SimTimeOfDay;
extern int SimDay;
extern tdble SimHumidity;

View file

@ -39,6 +39,7 @@ t3Dd vectStart[16];
t3Dd vectEnd[16];
tdble SimRain = 0;
tdble SimWater = 0;
tdble SimTimeOfDay = 0;
int SimClouds = 0;

View file

@ -113,9 +113,11 @@ void SimWheelConfig(tCar *car, int index)
coldmufactor = MIN(MAX(coldmufactor, 0.0f), 1.0f);
wheel->muTmult = (1 - coldmufactor) / ((wheel->Topt - 273) * (wheel->Topt - 273));
wheel->heatingm = GfParmGetNum(hdle, WheelSect[index], PRM_HEATINGMULT, (char*)NULL, (tdble) 6e-5);
wheel->heatingm -=SimRain;
wheel->aircoolm = GfParmGetNum(hdle, WheelSect[index], PRM_AIRCOOLINGMULT, (char*)NULL, (tdble) 12e-4);
wheel->speedcoolm = GfParmGetNum(hdle, WheelSect[index], PRM_SPEEDCOOLINGMULT, (char*)NULL, (tdble) 0.25);
wheel->wearrate = GfParmGetNum(hdle, WheelSect[index], PRM_WEARRATE, (char*)NULL, (tdble) 1.5e-8);
wheel->wearrate -= SimRain;
wheel->wearrate = MIN(MAX(wheel->wearrate, 0.0f), 0.1f);
wheel->critTreadDepth = GfParmGetNum(hdle, WheelSect[index], PRM_FALLOFFTREADDEPTH, (char*)NULL, (tdble) 0.03);
wheel->critTreadDepth = MIN(MAX(wheel->critTreadDepth, 0.0001f), 0.9999f);
@ -128,6 +130,9 @@ void SimWheelConfig(tCar *car, int index)
wheel->muTDmult[1] = (tdble) ((1.0 - wheel->muTDoffset[1]) / (1.0 - wheel->critTreadDepth));
wheel->muTDoffset[1] = wheel->muTDoffset[1] - wheel->muTDmult[1] * wheel->critTreadDepth;
GfLogInfo(" # Sim heatingm = %.9f\n", wheel->heatingm);
GfLogInfo(" # Sim wearrate = %.9f\n", wheel->wearrate);
/* components */
SimSuspConfig(car, hdle, SuspSect[index], &(wheel->susp), index);
SimBrakeConfig(hdle, BrkSect[index], &(wheel->brake));