- update USR's driver for better strategy
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9028 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 7b588bb97b0c6f9443943f5a2d3057a707668d42 Former-commit-id: 78f78c095cbde58ca7888fae75988720b4462b4f
This commit is contained in:
parent
3dde9201fa
commit
8a88659075
6 changed files with 88 additions and 10 deletions
|
@ -138,6 +138,75 @@ void MyCar::readConstSpecs(void* CarHandle)
|
||||||
double tiremufront = MIN(tiremuFL, tiremuFR);
|
double tiremufront = MIN(tiremuFL, tiremuFR);
|
||||||
double tiremurear = MIN(tiremuRL, tiremuRR);
|
double tiremurear = MIN(tiremuRL, tiremuRR);
|
||||||
mTireMu = MIN(tiremufront, tiremurear);
|
mTireMu = MIN(tiremufront, tiremurear);
|
||||||
|
|
||||||
|
if (HASCPD)
|
||||||
|
{
|
||||||
|
char path[256];
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTRGTWHEEL, SECT_COMPOUNDS, SECT_SOFT);
|
||||||
|
tiremuFR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTLFTWHEEL, SECT_COMPOUNDS, SECT_SOFT);
|
||||||
|
tiremuFL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARRGTWHEEL, SECT_COMPOUNDS, SECT_SOFT);
|
||||||
|
tiremuRR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARLFTWHEEL, SECT_COMPOUNDS, SECT_SOFT);
|
||||||
|
tiremuRL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
tiremufront = MIN(tiremuFL, tiremuFR);
|
||||||
|
tiremurear = MIN(tiremuRL, tiremuRR);
|
||||||
|
mTireMuC[1] = MIN(tiremufront, tiremurear);
|
||||||
|
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTRGTWHEEL, SECT_COMPOUNDS, SECT_MEDIUM);
|
||||||
|
tiremuFR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTLFTWHEEL, SECT_COMPOUNDS, SECT_MEDIUM);
|
||||||
|
tiremuFL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARRGTWHEEL, SECT_COMPOUNDS, SECT_MEDIUM);
|
||||||
|
tiremuRR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARLFTWHEEL, SECT_COMPOUNDS, SECT_MEDIUM);
|
||||||
|
tiremuRL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
tiremufront = MIN(tiremuFL, tiremuFR);
|
||||||
|
tiremurear = MIN(tiremuRL, tiremuRR);
|
||||||
|
mTireMuC[2] = MIN(tiremufront, tiremurear);
|
||||||
|
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTRGTWHEEL, SECT_COMPOUNDS, SECT_HARD);
|
||||||
|
tiremuFR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTLFTWHEEL, SECT_COMPOUNDS, SECT_HARD);
|
||||||
|
tiremuFL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARRGTWHEEL, SECT_COMPOUNDS, SECT_HARD);
|
||||||
|
tiremuRR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARLFTWHEEL, SECT_COMPOUNDS, SECT_HARD);
|
||||||
|
tiremuRL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
tiremufront = MIN(tiremuFL, tiremuFR);
|
||||||
|
tiremurear = MIN(tiremuRL, tiremuRR);
|
||||||
|
mTireMuC[3] = MIN(tiremufront, tiremurear);
|
||||||
|
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTRGTWHEEL, SECT_COMPOUNDS, SECT_WET);
|
||||||
|
tiremuFR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTLFTWHEEL, SECT_COMPOUNDS, SECT_WET);
|
||||||
|
tiremuFL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARRGTWHEEL, SECT_COMPOUNDS, SECT_WET);
|
||||||
|
tiremuRR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARLFTWHEEL, SECT_COMPOUNDS, SECT_WET);
|
||||||
|
tiremuRL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
tiremufront = MIN(tiremuFL, tiremuFR);
|
||||||
|
tiremurear = MIN(tiremuRL, tiremuRR);
|
||||||
|
mTireMuC[4] = MIN(tiremufront, tiremurear);
|
||||||
|
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTRGTWHEEL, SECT_COMPOUNDS, SECT_EXTREM_WET);
|
||||||
|
tiremuFR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_FRNTLFTWHEEL, SECT_COMPOUNDS, SECT_EXTREM_WET);
|
||||||
|
tiremuFL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARRGTWHEEL, SECT_COMPOUNDS, SECT_EXTREM_WET);
|
||||||
|
tiremuRR = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
sprintf(path, "%s/%s/%s", SECT_REARLFTWHEEL, SECT_COMPOUNDS, SECT_EXTREM_WET);
|
||||||
|
tiremuRL = GfParmGetNum(CarHandle, path, PRM_MU, (char*)NULL, mTireMu);
|
||||||
|
tiremufront = MIN(tiremuFL, tiremuFR);
|
||||||
|
tiremurear = MIN(tiremuRL, tiremuRR);
|
||||||
|
mTireMuC[5] = MIN(tiremufront, tiremurear);
|
||||||
|
|
||||||
|
int compounds = GfParmGetNum(CarHandle, SECT_TIRESET, PRM_COMPOUNDS_SET, NULL, 1);
|
||||||
|
mTireMu = mTireMuC[compounds];
|
||||||
|
LogUSR.debug("# USR tire mu = %.2f\n", mTireMu);
|
||||||
|
}
|
||||||
|
|
||||||
mBrakePressMax = GfParmGetNum(CarHandle, SECT_BRKSYST, PRM_BRKPRESS, (char*)NULL, 0);
|
mBrakePressMax = GfParmGetNum(CarHandle, SECT_BRKSYST, PRM_BRKPRESS, (char*)NULL, 0);
|
||||||
mBrakeRepartition = GfParmGetNum(CarHandle, SECT_BRKSYST, PRM_BRKREP, (char*)NULL, 0);
|
mBrakeRepartition = GfParmGetNum(CarHandle, SECT_BRKSYST, PRM_BRKREP, (char*)NULL, 0);
|
||||||
mFrontWingAngle = GfParmGetNum(CarHandle, SECT_FRNTWING, PRM_WINGANGLE, (char*)NULL, 0);
|
mFrontWingAngle = GfParmGetNum(CarHandle, SECT_FRNTWING, PRM_WINGANGLE, (char*)NULL, 0);
|
||||||
|
@ -229,6 +298,7 @@ void MyCar::update(double dt)
|
||||||
}
|
}
|
||||||
|
|
||||||
mSegMu = mTires.gripFactor() * mTireMu * mCar->_trkPos.seg->surface->kFriction;
|
mSegMu = mTires.gripFactor() * mTireMu * mCar->_trkPos.seg->surface->kFriction;
|
||||||
|
LogUSR.debug("# USR CarModel Tire Mu = %.3f - SegMu = %.3f\n", mTireMu, mSegMu);
|
||||||
mCW = mBodyCW * (1.0 + mCar->_dammage / 10000.0) + mWingCW;
|
mCW = mBodyCW * (1.0 + mCar->_dammage / 10000.0) + mWingCW;
|
||||||
mToMiddle = mCar->_trkPos.toMiddle;
|
mToMiddle = mCar->_trkPos.toMiddle;
|
||||||
double yawdiff = Utils::normPiPi(mCar->_yaw - mYaw);
|
double yawdiff = Utils::normPiPi(mCar->_yaw - mYaw);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
double bumpSpeed(double curv_z) const;
|
double bumpSpeed(double curv_z) const;
|
||||||
void driveForward() { mGearDirection = 1; }
|
void driveForward() { mGearDirection = 1; }
|
||||||
void driveBackwards() { mGearDirection = -1; }
|
void driveBackwards() { mGearDirection = -1; }
|
||||||
|
void setTireMu(int c) { mTireMu = mTireMuC[c]; }
|
||||||
double v() const { return mSpeed; }
|
double v() const { return mSpeed; }
|
||||||
double vX() const { return mSpeedX; }
|
double vX() const { return mSpeedX; }
|
||||||
double accelFiltered() const { return mAccelFilter.get(); }
|
double accelFiltered() const { return mAccelFilter.get(); }
|
||||||
|
@ -154,6 +155,7 @@ private:
|
||||||
double mCarMass;
|
double mCarMass;
|
||||||
double mTankVol;
|
double mTankVol;
|
||||||
double mTireMu;
|
double mTireMu;
|
||||||
|
double mTireMuC[6];
|
||||||
|
|
||||||
// Aerodynamic constants
|
// Aerodynamic constants
|
||||||
double mFrontCA;
|
double mFrontCA;
|
||||||
|
|
|
@ -182,16 +182,19 @@ void Driver::InitTrack(tTrack* Track, void* carHandle, void** carParmHandle, tSi
|
||||||
if (temp < 13.0 || situation->_totLaps * (double)track->length < 57800.0)
|
if (temp < 13.0 || situation->_totLaps * (double)track->length < 57800.0)
|
||||||
{
|
{
|
||||||
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 1);
|
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 1);
|
||||||
|
mCar.setTireMu(1);
|
||||||
LogUSR.info("Compounds choice SOFT !!!\n");
|
LogUSR.info("Compounds choice SOFT !!!\n");
|
||||||
}
|
}
|
||||||
else if (temp < 25.0 || situation->_totLaps * (double)track->length < 171000.0)
|
else if (temp < 25.0 || situation->_totLaps * (double)track->length < 171000.0)
|
||||||
{
|
{
|
||||||
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 2);
|
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 2);
|
||||||
|
mCar.setTireMu(2);
|
||||||
LogUSR.info("Compounds choice MEDIUM !!!\n");
|
LogUSR.info("Compounds choice MEDIUM !!!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 3);
|
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 3);
|
||||||
|
mCar.setTireMu(3);
|
||||||
LogUSR.info("Compounds choice HARD !!!\n");
|
LogUSR.info("Compounds choice HARD !!!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +203,13 @@ void Driver::InitTrack(tTrack* Track, void* carHandle, void** carParmHandle, tSi
|
||||||
if (mRain > 0 && mRain < 3)
|
if (mRain > 0 && mRain < 3)
|
||||||
{
|
{
|
||||||
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 4);
|
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 4);
|
||||||
|
mCar.setTireMu(4);
|
||||||
LogUSR.info("Compounds choice WET !!!\n");
|
LogUSR.info("Compounds choice WET !!!\n");
|
||||||
}
|
}
|
||||||
else if (mRain > 2)
|
else if (mRain > 2)
|
||||||
{
|
{
|
||||||
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 5);
|
param.setNum(SECT_TIRESET, PRM_COMPOUNDS_SET, 5);
|
||||||
|
mCar.setTireMu(5);
|
||||||
LogUSR.info("Compounds choice EXTREM WET !!!\n");
|
LogUSR.info("Compounds choice EXTREM WET !!!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ void Pit::update()
|
||||||
|
|
||||||
if(mMyCar->HASTYC)
|
if(mMyCar->HASTYC)
|
||||||
{
|
{
|
||||||
pittyres = (mMyCar->tires()->TyreTreadDepth() < 10.00 && remaininglaps > 5.0);
|
pittyres = (mMyCar->tires()->TyreTreadDepth() < 15.00 && remaininglaps > 5.0);
|
||||||
LogUSR.debug(" # Tyre depth = %.2f Pit Tyres change = %i\n", mMyCar->tires()->TyreTreadDepth(), pittyres);
|
LogUSR.debug(" # Tyre depth = %.2f Pit Tyres change = %i\n", mMyCar->tires()->TyreTreadDepth(), pittyres);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -491,8 +491,6 @@ double Pit::calcRefuel()
|
||||||
LogUSR.info("USR Fuel per meter %.7f\n", mAvgFuelPerLap / mTrack->length);
|
LogUSR.info("USR Fuel per meter %.7f\n", mAvgFuelPerLap / mTrack->length);
|
||||||
LogUSR.info("USR Tire pitstops %i\n", tirespitstops);
|
LogUSR.info("USR Tire pitstops %i\n", tirespitstops);
|
||||||
LogUSR.info("USR Tire wear per meter %.7f\n", mMyCar->tires()->avgWearPerMeter());
|
LogUSR.info("USR Tire wear per meter %.7f\n", mMyCar->tires()->avgWearPerMeter());
|
||||||
LogUSR.info("USR Tire distance = %.2f - Tire Laps = %.2f\n", mMyCar->tires()->TyreTreadDepth() / mCar->_remainingLaps * mTrack->length,
|
|
||||||
mMyCar->tires()->distLeft() / mTrack->length);
|
|
||||||
|
|
||||||
return stintfuel - mCar->_fuel;
|
return stintfuel - mCar->_fuel;
|
||||||
}
|
}
|
||||||
|
@ -545,26 +543,31 @@ void Pit::pitCommand()
|
||||||
if (remainingLaps <= 10 && mRain < 2)
|
if (remainingLaps <= 10 && mRain < 2)
|
||||||
{
|
{
|
||||||
mCar->pitcmd.tiresetChange = tCarPitCmd::SOFT;
|
mCar->pitcmd.tiresetChange = tCarPitCmd::SOFT;
|
||||||
|
mMyCar->setTireMu(1);
|
||||||
LogUSR.info("Change Tire SOFT !\n");
|
LogUSR.info("Change Tire SOFT !\n");
|
||||||
}
|
}
|
||||||
else if (remainingLaps <= 25 && mRain < 2)
|
else if (remainingLaps <= 25 && mRain < 2)
|
||||||
{
|
{
|
||||||
mCar->pitcmd.tiresetChange = tCarPitCmd::MEDIUM;
|
mCar->pitcmd.tiresetChange = tCarPitCmd::MEDIUM;
|
||||||
|
mMyCar->setTireMu(2);
|
||||||
LogUSR.info("Change Tire MEDIUM !\n");
|
LogUSR.info("Change Tire MEDIUM !\n");
|
||||||
}
|
}
|
||||||
else if(mRain < 2)
|
else if(mRain < 2)
|
||||||
{
|
{
|
||||||
mCar->pitcmd.tiresetChange = tCarPitCmd::HARD;
|
mCar->pitcmd.tiresetChange = tCarPitCmd::HARD;
|
||||||
|
mMyCar->setTireMu(3);
|
||||||
LogUSR.info("Change Tire HARD !\n");
|
LogUSR.info("Change Tire HARD !\n");
|
||||||
}
|
}
|
||||||
else if (mRain < 3)
|
else if (mRain < 3)
|
||||||
{
|
{
|
||||||
mCar->pitcmd.tiresetChange = tCarPitCmd::WET;
|
mCar->pitcmd.tiresetChange = tCarPitCmd::WET;
|
||||||
|
mMyCar->setTireMu(4);
|
||||||
LogUSR.info("Change Tire WET !\n");
|
LogUSR.info("Change Tire WET !\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mCar->pitcmd.tiresetChange = tCarPitCmd::EXTREM_WET;
|
mCar->pitcmd.tiresetChange = tCarPitCmd::EXTREM_WET;
|
||||||
|
mMyCar->setTireMu(5);
|
||||||
LogUSR.info("Change Tire EXTREM WET !\n");
|
LogUSR.info("Change Tire EXTREM WET !\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ private:
|
||||||
double calcRefuel();
|
double calcRefuel();
|
||||||
|
|
||||||
const tTrack* mTrack;
|
const tTrack* mTrack;
|
||||||
const MyCar* mMyCar;
|
MyCar* mMyCar;
|
||||||
tCarElt* mCar;
|
tCarElt* mCar;
|
||||||
const tCarElt* mTeamCar;
|
const tCarElt* mTeamCar;
|
||||||
const tTrackOwnPit* mPit; // pointer to my pit
|
const tTrackOwnPit* mPit; // pointer to my pit
|
||||||
|
|
|
@ -29,7 +29,7 @@ void Tires::init(const tCarElt* car)
|
||||||
{
|
{
|
||||||
mCar = car;
|
mCar = car;
|
||||||
mDistWhenNew = 0;
|
mDistWhenNew = 0;
|
||||||
mWear = 100.0;
|
mWear = 0.0;
|
||||||
mHotTemp = 273.15 + GfParmGetNum(mCar->_carHandle, "private", "hottemp", (char*)NULL, 120.0);
|
mHotTemp = 273.15 + GfParmGetNum(mCar->_carHandle, "private", "hottemp", (char*)NULL, 120.0);
|
||||||
mMuScale = GfParmGetNum(mCar->_carHandle, "private", "mu scale", (char*)NULL, 1.0);
|
mMuScale = GfParmGetNum(mCar->_carHandle, "private", "mu scale", (char*)NULL, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -56,16 +56,14 @@ void Tires::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calc dist to tire change
|
// Calc dist to tire change
|
||||||
double distused = mCar->_distRaced;//- mDistWhenNew;
|
double distused = mCar->_distRaced - mDistWhenNew;
|
||||||
if (distused > 1000.0)
|
if (distused > 1000.0)
|
||||||
{
|
{
|
||||||
mAvgWearPerMeter = mWear / distused;
|
mAvgWearPerMeter = mWear / distused;
|
||||||
//GfLogInfo("USR Tires AvgWear = %.9f\n", mAvgWearPerMeter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//double wearuntilchange = mWear / mAvgWearPerMeter;
|
double wearuntilchange = 100.0 - mWear;
|
||||||
mDistLeft = mWear / mAvgWearPerMeter;
|
mDistLeft = wearuntilchange / mAvgWearPerMeter;
|
||||||
//GfLogInfo("USR Tires mDistleft = %.8f\n", mDistLeft);
|
|
||||||
|
|
||||||
mGripFactor = updateGripFactor();
|
mGripFactor = updateGripFactor();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue