diff --git a/src/drivers/simplix/src/unitclothoid.cpp b/src/drivers/simplix/src/unitclothoid.cpp index 37eca6e5b..170175fb2 100644 --- a/src/drivers/simplix/src/unitclothoid.cpp +++ b/src/drivers/simplix/src/unitclothoid.cpp @@ -10,7 +10,7 @@ // File : unitclothoid.cpp // Created : 2007.11.25 // Last changed : 2013.03.02 -// Copyright : © 2007-2013 Wolf-Dieter Beelitz +// Copyright : 2007-2013 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de // Version : 4.00.000 //--------------------------------------------------------------------------* diff --git a/src/drivers/simplix/src/unitdriver.cpp b/src/drivers/simplix/src/unitdriver.cpp index e52a864b1..61bd10e46 100644 --- a/src/drivers/simplix/src/unitdriver.cpp +++ b/src/drivers/simplix/src/unitdriver.cpp @@ -90,6 +90,7 @@ const char* TDriver::MyBotName = "simplix"; // Name of this bot const char* TDriver::ROBOT_DIR = "drivers/simplix";// Sub path to dll const char* TDriver::SECT_PRIV = "simplix private";// Private section const char* TDriver::DEFAULTCARTYPE = "car1-trb1";// Default car type +int TDriver::RobotType = 0; bool TDriver::AdvancedParameters = false; // Advanced parameters bool TDriver::UseOldSkilling = false; // Use old skilling bool TDriver::UseSCSkilling = false; // Use supercar skilling @@ -293,6 +294,7 @@ TDriver::TDriver(int Index): oCarHasABS(false), oCarHasESP(false), oCarHasTCL(false), + oCarHasTYC(false), oTclRange(10.0), oTclSlip(1.6), oTclFactor(1.0), @@ -380,6 +382,7 @@ TDriver::TDriver(int Index): oSideScaleMu(0.97f), oSideScaleBrake(0.97f), oSideBorderOuter(0.2f), + oSideBorderInner(0.2f), oXXX(1.0), oRain(false), oRainIntensity(0.0), @@ -423,6 +426,8 @@ TDriver::TDriver(int Index): TDriver::LengthMargin = LENGTH_MARGIN; // Initialize safty margin +// oLastUsedGear = 0; + LogSimplix.debug("\n#<<< TDriver::TDriver()\n\n"); } //==========================================================================* @@ -732,9 +737,9 @@ void TDriver::AdjustDriving( LogSimplix.debug("#oInitialBrakeCoeff %g\n",oInitialBrakeCoeff); } - oLookAheadFactor = + oLookAheadFactor = MIN(0.2, GfParmGetNum(Handle,TDriver::SECT_PRIV,PRV_LOOKAHEADFACTOR,0, - (float)oLookAheadFactor); + (float)oLookAheadFactor)); LogSimplix.debug("#LookAheadFactor %g\n",oLookAheadFactor); oScaleSteer = @@ -755,35 +760,45 @@ void TDriver::AdjustDriving( const char *enabling; + oCarHasTYC = false; + enabling = GfParmGetStr(Handle, SECT_FEATURES, PRM_TIRETEMPDEG, VAL_NO); + if (strcmp(enabling, VAL_YES) == 0) + { + oCarHasTYC = true; + LogSimplix.warning("#Car has TYC yes\n"); + } + else + LogSimplix.warning("#Car has TYC no\n"); + oCarHasABS = false; enabling = GfParmGetStr(Handle, SECT_FEATURES, PRM_ABSINSIMU, VAL_NO); if (strcmp(enabling, VAL_YES) == 0) { oCarHasABS = true; - LogSimplix.info("#Car has ABS yes\n"); + LogSimplix.warning("#Car has ABS yes\n"); } else - LogSimplix.info("#Car has ABS no\n"); + LogSimplix.warning("#Car has ABS no\n"); oCarHasESP = false; enabling = GfParmGetStr(Handle, SECT_FEATURES, PRM_ESPINSIMU, VAL_NO); if (strcmp(enabling, VAL_YES) == 0) { oCarHasESP = true; - LogSimplix.info("#Car has ESP yes\n"); + LogSimplix.warning("#Car has ESP yes\n"); } else - LogSimplix.info("#Car has ESP no\n"); + LogSimplix.warning("#Car has ESP no\n"); oCarHasTCL = false; enabling = GfParmGetStr(Handle, SECT_FEATURES, PRM_TCLINSIMU, VAL_NO); if (strcmp(enabling, VAL_YES) == 0) { oCarHasABS = true; - LogSimplix.info("#Car has TCL yes\n"); + LogSimplix.warning("#Car has TCL yes\n"); } else - LogSimplix.info("#Car has TCL no\n"); + LogSimplix.warning("#Car has TCL no\n"); // For test of simu options override switches here /* @@ -1575,6 +1590,7 @@ void TDriver::Drive() oBrake = FilterBrakeSpeed(oBrake); if (!oCarHasABS) oBrake = FilterABS(oBrake); + oBrake = FilterSkillBrake(oBrake); //if (oBrake > 0.10) // oClutch = 0.4; @@ -1612,9 +1628,14 @@ void TDriver::Drive() CarGearCmd = oGear; CarSteerCmd = (float) oSteer; CarSteerTelemetrie = oTelemetrieMode; + //oLastUsedGear = MIN(1,oGear); if (oTelemetrieMode == 4) fprintf(stderr,"A%+7.2f%% B%+7.2f%% C%+7.2f%% S%+7.2f%% G:%d\n",100*oAccel,100*oBrake,100*oClutch,100*oSteer,oGear); +/* + double Radius = 1/oLanePoint.Crv; + fprintf(stderr,"R:%+7.2f\n",Radius); +*/ // SIMUV4 ... if (oWingControl) @@ -1846,6 +1867,7 @@ void TDriver::FindRacinglines() Param.oCarParam2.oScaleBrake = // Adjust brake scale oSideScaleBrake*Param.oCarParam.oScaleBrake; // to be able to avoid Param.Fix.oBorderOuter += oSideBorderOuter; + Param.Fix.oBorderInner += oSideBorderInner; if (oGeneticOpti || !oRacingLine[oRL_LEFT].LoadSmoothPath // Load a smooth path @@ -2555,7 +2577,7 @@ void TDriver::InitCw() //--------------------------------------------------------------------------* double TDriver::GearRatio() { - return CarGearRatio[UsedGear + CarGearOffset]; + return CarGearRatio[oUsedGear + CarGearOffset]; } //==========================================================================* @@ -2564,7 +2586,7 @@ double TDriver::GearRatio() //--------------------------------------------------------------------------* double TDriver::PrevGearRatio() { - return CarGearRatio[UsedGear + CarGearOffset-1]; + return CarGearRatio[oUsedGear + CarGearOffset-1]; } //==========================================================================* @@ -2573,7 +2595,7 @@ double TDriver::PrevGearRatio() //--------------------------------------------------------------------------* double TDriver::NextGearRatio() { - return CarGearRatio[UsedGear + CarGearOffset+1]; + return CarGearRatio[oUsedGear + CarGearOffset+1]; } //==========================================================================* @@ -2924,26 +2946,32 @@ bool TDriver::EcoShift() //--------------------------------------------------------------------------* void TDriver::GearTronic() { - if ((oJumping > 0.0) && (UsedGear > 0)) + oUsedGear = oCar->_gear; + if (oCar->_gearNext != 0) + oUsedGear = oCar->_gearNext; + + if ((oJumping > 0.0) && (oUsedGear > 0)) return; - if (IsTickover) + if (oUsedGear <= 0) { - oGear = 1; +// if (oLastUsedGear <= 0) + oGear = 1; } else { - if((UsedGear < oLastGear) + + if((oUsedGear < oLastGear) && (EcoShift() || (GearRatio() * CarSpeedLong / oWheelRadius > NextRpm))) { oUnstucking = false; TreadClutch; oGear = NextGear; } - else if(UsedGear > 1) + else if(oUsedGear > 1) { double PrevRpm = - oShift[UsedGear-1] * oShiftMargin + oShift[oUsedGear-1] * oShiftMargin * GearRatio() / PrevGearRatio(); if(GearRatio() * CarSpeedLong / oWheelRadius < PrevRpm) @@ -3138,10 +3166,12 @@ double TDriver::SteerAngle(TLanePoint& AheadPointInfo) AheadDist = 1.5 + oCurrSpeed * 0.04; if (oGoToPit) AheadDist = 2.0; +/* if (AheadDist < oLastAheadDist - 0.05) AheadDist = oLastAheadDist - 0.05; else if (AheadDist > oLastAheadDist + 0.05) AheadDist = oLastAheadDist + 0.05; +*/ oLastAheadDist = AheadDist; double AheadPos = oTrackDesc.CalcPos(oCar, AheadDist); @@ -4009,7 +4039,22 @@ double TDriver::FilterBrake(double Brake) double TDriver::FilterSkillBrake(double Brake) { //Brake *= oBrakeAdjustPerc; + if (RobotType != RTYPE_SIMPLIX_SRW) + return Brake; + +// fprintf(stderr,"wc: %g wemy: %g\n",oCar->_tyreCondition(0),oCar->_tyreEffMu(0)); return Brake; + +/* + oCar->priv.wheel[0].condition; + oCar->priv.wheel[0].effectiveMu; + oCar->priv.wheel[0].slipAccel; + oCar->priv.wheel[0].slipNorm; + oCar->priv.wheel[0].slipSide; + oCar->priv.wheel[0].spinVel; + oCar->priv.wheel[0].state; +*/ + } //==========================================================================* @@ -4268,6 +4313,7 @@ void TDriver::Unstuck() CarAccelCmd = 1.0; // Open the throttle CarClutchCmd = 0.0; // Release clutch oUnstucking = true; // Set flag +// oLastUsedGear = CarGearCmd; } //==========================================================================* @@ -4346,6 +4392,33 @@ void TDriver::SideBorderOuter(float Factor) } //==========================================================================* +//==========================================================================* +// Set additional border to inner side +//--------------------------------------------------------------------------* +void TDriver::SideBorderInner(float Factor) +{ + oSideBorderInner = Factor; +} +//==========================================================================* + +//==========================================================================* +// Calculate the skilling +//--------------------------------------------------------------------------* +double TDriver::WheelConditionFront() +{ + return MIN(oCar->_tyreCondition(0),oCar->_tyreCondition(1)); +} +//==========================================================================* + +//==========================================================================* +// Calculate the skilling +//--------------------------------------------------------------------------* +double TDriver::WheelConditionRear() +{ + return MIN(oCar->_tyreCondition(2),oCar->_tyreCondition(3)); +} +//==========================================================================* + //==========================================================================* // Calculate the skilling //--------------------------------------------------------------------------* diff --git a/src/drivers/simplix/src/unitdriver.h b/src/drivers/simplix/src/unitdriver.h index 793325fea..4553fb894 100644 --- a/src/drivers/simplix/src/unitdriver.h +++ b/src/drivers/simplix/src/unitdriver.h @@ -264,6 +264,7 @@ private: int oLastLap; // Last lap double oClutch; // Clutching int oGear; // Gear + int oUsedGear; // Gear double oSteer; // Steering double oLastSteer; // Steering @@ -309,6 +310,7 @@ private: double oGearEff[MAX_GEARS]; // Efficiency of gears int oExtended; // Information if this robot is extended (oExtended = 1) or not (oExtended = 0). int oLastGear; // Last gear + int oLastUsedGear; // Last used gear bool oLetPass; // Let opoonent pass double oLookAhead; // Look ahead base value double oLookAheadFactor; // Look ahead factor @@ -434,6 +436,7 @@ private: float oSideScaleMu; float oSideScaleBrake; float oSideBorderOuter; + float oSideBorderInner; double oXXX; bool oRain; double oRainIntensity; @@ -445,6 +448,7 @@ private: double oJumpOffset; // Offset for calculation of jumps bool oFirstJump; double oStartSteerFactor; + bool oCarHasTYC; // Flag: Car has tyre condition in simu enabled static int NBBOTS; // Nbr of cars double CurrSimTime; // Current simulation time @@ -453,6 +457,7 @@ private: static const char* SECT_PRIV; // Private section static const char* DEFAULTCARTYPE; // Default car type + static int RobotType; static bool AdvancedParameters; static bool UseOldSkilling; static bool UseSCSkilling; @@ -472,6 +477,7 @@ private: void ScaleSide(float FactorMu, float FactorBrake); void SideBorderOuter(float Factor); + void SideBorderInner(float Factor); void AdjustBrakes(PCarHandle Handle); void AdjustDriving(PCarHandle Handle, double ScaleBrake, double ScaleMu); @@ -482,6 +488,8 @@ private: void Meteorology(); int GetWeather(); + double WheelConditionFront(); + double WheelConditionRear(); void CalcSkilling(); double CalcFriction(const double Crv); double CalcCrv(double Crv); diff --git a/src/drivers/simplix/src/unitfixcarparam.cpp b/src/drivers/simplix/src/unitfixcarparam.cpp index 07845309b..62b214f68 100644 --- a/src/drivers/simplix/src/unitfixcarparam.cpp +++ b/src/drivers/simplix/src/unitfixcarparam.cpp @@ -112,6 +112,13 @@ double TFixCarParam::CalcAcceleration( double TrackTiltAngle) const // Track tilt angle { double MU = Friction * oTyreMu; + if (oDriver->oCarHasTYC) + { + double WcF = oDriver->WheelConditionFront(); + double WcR = oDriver->WheelConditionRear(); + MU = MIN(WcF*MU,WcR*MU); + } + double CD = oCdBody * (1.0 + oTmpCarParam->oDamage / 10000.0) + oCdWing; @@ -186,12 +193,19 @@ double TFixCarParam::CalcBraking Friction *= oDriver->CalcFriction(Crv); double Mu = Friction * oTyreMu; - double Mu_F = Mu; - double Mu_R = Mu; + double MuF = Mu; + double MuR = Mu; - Mu_F = Friction * oTyreMuFront; - Mu_R = Friction * oTyreMuRear; - Mu = MIN(Mu_F,Mu_R); + MuF = Friction * oTyreMuFront; + MuR = Friction * oTyreMuRear; + if (oDriver->oCarHasTYC) + { + double WcF = oDriver->WheelConditionFront(); + double WcR = oDriver->WheelConditionRear(); + Mu = MIN(WcF*MuF,WcR*MuR); + } + else + Mu = MIN(MuF,MuR); // From SD: double Cd = oCdBody * @@ -221,7 +235,7 @@ double TFixCarParam::CalcBraking double Ffrnt = oCaFrontWing * AvgV2; double Frear = oCaRearWing * AvgV2; - Froad = 0.95 * Fdown * Mu + Ffrnt * Mu_F + Frear * Mu_R; + Froad = 0.95 * Fdown * Mu + Ffrnt * MuF + Frear * MuR; double Flat = oTmpCarParam->oMass * Glat; double Ftan = oTmpCarParam->oMass * Gtan - Cd * AvgV2; @@ -291,12 +305,19 @@ double TFixCarParam::CalcBrakingPit Friction *= oDriver->CalcFriction(Crv); double Mu = Friction * oTyreMu; - double Mu_F = Mu; - double Mu_R = Mu; + double MuF = Mu; + double MuR = Mu; - Mu_F = Friction * oTyreMuFront; - Mu_R = Friction * oTyreMuRear; - Mu = MIN(Mu_F,Mu_R); + MuF = Friction * oTyreMuFront; + MuR = Friction * oTyreMuRear; + if (oDriver->oCarHasTYC) + { + double WcF = oDriver->WheelConditionFront(); + double WcR = oDriver->WheelConditionRear(); + Mu = MIN(WcF*MuF,WcR*MuR); + } + else + Mu = MIN(MuF,MuR); // From TORCS: double Cd = oCdBody * @@ -325,7 +346,7 @@ double TFixCarParam::CalcBrakingPit double Ffrnt = oCaFrontWing * AvgV2; double Frear = oCaRearWing * AvgV2; - Froad = Fdown * Mu + Ffrnt * Mu_F + Frear * Mu_R; + Froad = Fdown * Mu + Ffrnt * MuF + Frear * MuR; double Flat = oTmpCarParam->oMass * Glat; double Ftan = oTmpCarParam->oMass * Gtan - Cd * AvgV2; @@ -423,7 +444,14 @@ double TFixCarParam::CalcMaxSpeed double MuF = Friction * oTyreMuFront * CarParam.oScaleMu; double MuR = Friction * oTyreMuRear * CarParam.oScaleMu; - Mu = MIN(MuF,MuR) / oTmpCarParam->oSkill; + if (oDriver->oCarHasTYC) + { + double WcF = oDriver->WheelConditionFront(); + double WcR = oDriver->WheelConditionRear(); + Mu = MIN(WcF*MuF,WcR*MuR) / oTmpCarParam->oSkill; + } + else + Mu = MIN(MuF,MuR) / oTmpCarParam->oSkill; Den = (AbsCrv - ScaleBump * CrvZ) - (oCaFrontWing * MuF + oCaRearWing * MuR diff --git a/src/drivers/simplix/src/unitglobal.h b/src/drivers/simplix/src/unitglobal.h index 74dbc3d3c..a6430853a 100644 --- a/src/drivers/simplix/src/unitglobal.h +++ b/src/drivers/simplix/src/unitglobal.h @@ -344,7 +344,6 @@ enum #define WheelSegFriction(x) (oCar->_wheelSeg(x)->surface->kFriction) #define WheelSegRoughness(x) (oCar->_wheelSeg(x)->surface->kRoughness) #define WheelSegRollRes(x) (oCar->_wheelSeg(x)->surface->kRollRes) -#define UsedGear (oCar->_gear) // ... Shortcuts for TORCS // Shortcuts for this robot ... diff --git a/src/drivers/simplix/src/unitmain.cpp b/src/drivers/simplix/src/unitmain.cpp index 8d7eed822..6af10b064 100644 --- a/src/drivers/simplix/src/unitmain.cpp +++ b/src/drivers/simplix/src/unitmain.cpp @@ -342,6 +342,7 @@ void SetUpSimplix_sc() void SetUpSimplix_srw() { cRobotType = RTYPE_SIMPLIX_SRW; + TDriver::RobotType = cRobotType; SetParameters(NBBOTS, "srw-sector-p4"); TDriver::AdvancedParameters = true; TDriver::UseSCSkilling = true; // Use supercar skilling @@ -539,6 +540,8 @@ int moduleWelcomeV1_00 SetUpSimplix_trb1(); else if (strncmp(RobName,"simplix_sc",strlen("simplix_sc")) == 0) SetUpSimplix_sc(); + else if (strncmp(RobName,"simplix_srw",strlen("simplix_srw")) == 0) + SetUpSimplix_srw(); else if (strncmp(RobName,"simplix_36GP",strlen("simplix_36GP")) == 0) SetUpSimplix_36GP(); else if (strncmp(RobName,"simplix_mpa1",strlen("simplix_mpa1")) == 0) @@ -801,7 +804,8 @@ static int InitFuncPt(int Index, void *Pt) cInstances[Index-IndexOffset].cRobot->CalcCrvFoo = &TDriver::CalcCrv_simplix_Identity; cInstances[Index-IndexOffset].cRobot->CalcHairpinFoo = &TDriver::CalcHairpin_simplix_Identity; cInstances[Index-IndexOffset].cRobot->ScaleSide(0.95f,0.95f); - cInstances[Index-IndexOffset].cRobot->SideBorderOuter(0.10f); + cInstances[Index-IndexOffset].cRobot->SideBorderOuter(0.30f); + cInstances[Index-IndexOffset].cRobot->SideBorderInner(0.00f); } else if (cRobotType == RTYPE_SIMPLIX_36GP) { diff --git a/src/drivers/simplix/src/unittrack.cpp b/src/drivers/simplix/src/unittrack.cpp index 8ec116dd7..0f3bafb34 100644 --- a/src/drivers/simplix/src/unittrack.cpp +++ b/src/drivers/simplix/src/unittrack.cpp @@ -493,6 +493,15 @@ void TTrackDescription::InitTrack bool PitOnly = false; // Reset flag while(PSide) // Loop all side-segments { +/* + if (S == TR_SIDE_LFT) + { + fprintf(stderr,"%s %d r:%.3f kfr:%.3f krh:%.3f krr:%.3f kkw:%.3f \n",Seg->name,Seg->id,Seg->radius,PSide->surface->kFriction,PSide->surface->kRoughness,PSide->surface->kRollRes,PSide->Kzw); + + if (Seg->id == 565) + fprintf(stderr,"Now!\n"); + } +*/ double Wpit = 0.0; // Initialize double WCurb = 0.0; // additional with double W = PSide->startWidth + T * // Estimate width of section