diff --git a/src/drivers/shadow/src/CarModel.cpp b/src/drivers/shadow/src/CarModel.cpp index 9abb558a6..190996f1b 100644 --- a/src/drivers/shadow/src/CarModel.cpp +++ b/src/drivers/shadow/src/CarModel.cpp @@ -20,6 +20,7 @@ #include "CarModel.h" #include "Quadratic.h" #include "Utils.h" +#include "Driver.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -283,6 +284,14 @@ double CarModel::CalcBreaking(double k0, double kz0, double k1, double kz1, doub double Ftanroad = -sqrt(Froad * Froad - Flatroad * Flatroad) + Ftan; double acc = Ftanroad / M; + + if (TDriver::UseBrakeLimit) + { + double Radius = 1.0 / fabs(Kz); + double factor = MIN(1.0,MAX(0.39, (Radius - 190.0) / 100.0)); + acc = MAX(acc, TDriver::BrakeLimit * factor); + } + double inner = MX(0, v * v - 2 * acc * dist ); double oldU = u; u = sqrt(inner); diff --git a/src/drivers/shadow/src/Driver.cpp b/src/drivers/shadow/src/Driver.cpp index 2799204a5..ce5bf635e 100644 --- a/src/drivers/shadow/src/Driver.cpp +++ b/src/drivers/shadow/src/Driver.cpp @@ -189,12 +189,13 @@ TDriver::TDriver(int Index, const int robot_type): { case SHADOW_TRB1: robot_name = "shadow_trb1"; + TDriver::UseBrakeLimit = false; Frc = 0.95; break; case SHADOW_SC: robot_name = "shadow_sc"; - Frc = 0.90; + Frc = 0.85; break; case SHADOW_SRW: @@ -530,6 +531,8 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl LogSHADOW.debug("FLY_HEIGHT %g\n", FLY_HEIGHT ); LogSHADOW.debug( "BUMP_MOD %d\n", BUMP_MOD ); + AdjustBrakes(hCarParm); + const char *enabling; HasTYC = false; @@ -2358,6 +2361,32 @@ void TDriver::initBrake() LogSHADOW.debug("\n#<<< Shadow2 Init Brake\n\n"); } +//==========================================================================* + +//==========================================================================* +// Adjust brakes +//--------------------------------------------------------------------------* +void TDriver::AdjustBrakes(void *pCarHandle) +{ + if ((TDriver::UseBrakeLimit) || (TDriver::UseGPBrakeLimit)) + { + TDriver::BrakeLimit = GfParmGetNum(pCarHandle, SECT_PRIV, PRV_BRAKE_LIMIT, 0, (float) TDriver::BrakeLimit); + LogSHADOW.debug("#BrakeLimit %g\n", TDriver::BrakeLimit); + + TDriver::BrakeLimitBase = GfParmGetNum(pCarHandle, SECT_PRIV,PRV_BRAKE_LIMIT_BASE,0, (float) TDriver::BrakeLimitBase); + LogSHADOW.debug("#BrakeLimitBase %g\n", TDriver::BrakeLimitBase); + + TDriver::BrakeLimitScale = GfParmGetNum(pCarHandle, SECT_PRIV, PRV_BRAKE_LIMIT_SCALE, 0, (float) TDriver::BrakeLimitScale); + LogSHADOW.debug("#BrakeLimitScale %g\n", TDriver::BrakeLimitScale); + + TDriver::SpeedLimitBase = GfParmGetNum(pCarHandle, SECT_PRIV, PRV_SPEED_LIMIT_BASE, 0, (float) TDriver::SpeedLimitBase); + LogSHADOW.debug("#SpeedLimitBase %g\n", TDriver::SpeedLimitBase); + + TDriver::SpeedLimitScale = GfParmGetNum(pCarHandle, SECT_PRIV, PRV_SPEED_LIMIT_SCALE, 0, (float) TDriver::SpeedLimitScale); + LogSHADOW.debug("#SpeedLimitScale %g\n", TDriver::SpeedLimitScale); + } +}; + void TDriver::initCa() { LogSHADOW.debug("\n#Shadow Init InitCA >>>\n\n"); diff --git a/src/drivers/shadow/src/Driver.h b/src/drivers/shadow/src/Driver.h index 79b8f015e..acfca8a6f 100644 --- a/src/drivers/shadow/src/Driver.h +++ b/src/drivers/shadow/src/Driver.h @@ -79,6 +79,11 @@ #define PRV_NEED_SIN "use sin long" #define PRV_USED_ACC "acc exit" #define PRV_SKILL_OFFSET "offset skill" +#define PRV_BRAKE_LIMIT "brake limit" +#define PRV_BRAKE_LIMIT_BASE "brake limit base" +#define PRV_BRAKE_LIMIT_SCALE "brake limit scale" +#define PRV_SPEED_LIMIT_BASE "speed limit base" +#define PRV_SPEED_LIMIT_SCALE "speed limit scale" #define NBR_BRAKECOEFF 50 // Number of brake coeffs @@ -235,6 +240,8 @@ public: void CalcSkilling_shadow_LP1(); void AdjustSkilling(void* pCarHandle); + void AdjustBrakes(void *pCarHandle); + void GetSkillingParameters(const char* BaseParamPath, const char* PathFilename); double CalcFriction_shadow_Identity(double Crv);