- update shadow's driver
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6637 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 57038fa4d00c5e9ddf03f6a7efca1a2d4891fa7e Former-commit-id: 53b202e1b9b9e272f12d252a9845bb6d0569e2f3
This commit is contained in:
parent
d562effd02
commit
bb11e1b1fa
2 changed files with 30 additions and 129 deletions
|
@ -30,6 +30,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
static const int BUFSIZE = 256;
|
||||||
|
|
||||||
#define FLY_COUNT 20
|
#define FLY_COUNT 20
|
||||||
|
|
||||||
|
@ -44,10 +45,6 @@
|
||||||
//==========================================================================*
|
//==========================================================================*
|
||||||
// Statics
|
// Statics
|
||||||
//--------------------------------------------------------------------------*
|
//--------------------------------------------------------------------------*
|
||||||
//int TDriver::NBBOTS = MAX_NBBOTS; // Nbr of drivers/robots
|
|
||||||
//const char* TDriver::ROBOT_DIR = "drivers/shadow"; // Sub path to dll
|
|
||||||
//const char* TDriver::DEFAULTCARTYPE = "car1-trb1"; // Default car type
|
|
||||||
const char* TDriver::robot_name="shadow_trb1";
|
|
||||||
int TDriver::RobotType = 0;
|
int TDriver::RobotType = 0;
|
||||||
bool TDriver::AdvancedParameters = false; // Advanced parameters
|
bool TDriver::AdvancedParameters = false; // Advanced parameters
|
||||||
bool TDriver::UseOldSkilling = false; // Use old skilling
|
bool TDriver::UseOldSkilling = false; // Use old skilling
|
||||||
|
@ -74,35 +71,6 @@ const float TDriver::ABS_MINSPEED = 3.0f; // [m/s] Below this speed t
|
||||||
const float TDriver::ABS_SLIP = 2.5f;
|
const float TDriver::ABS_SLIP = 2.5f;
|
||||||
const float TDriver::ABS_RANGE = 5.0f;
|
const float TDriver::ABS_RANGE = 5.0f;
|
||||||
|
|
||||||
//double TDriver::LengthMargin; // safety margin long.
|
|
||||||
//bool TDriver::Qualification; // Global flag
|
|
||||||
/*static const char *WheelSect[4] = // TORCS defined sections
|
|
||||||
{SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL};
|
|
||||||
static const char *WingSect[2] =
|
|
||||||
{SECT_FRNTWING, SECT_REARWING};*/
|
|
||||||
//==========================================================================*
|
|
||||||
|
|
||||||
//==========================================================================*
|
|
||||||
// Buffers
|
|
||||||
//
|
|
||||||
// Q: qualifying
|
|
||||||
// F: Free
|
|
||||||
// L: Avoid to left
|
|
||||||
// R: Avoid to right
|
|
||||||
//--------------------------------------------------------------------------*
|
|
||||||
/*#define BUFLEN 256
|
|
||||||
static char PathToWriteToBuffer[BUFLEN]; // for path we write to*/
|
|
||||||
//static char PathFilenameBuffer[256]; // for path and filename
|
|
||||||
/*static char TrackNameBuffer[BUFLEN]; // for track name
|
|
||||||
static char TrackLoadQualifyBuffer[BUFLEN]; // for track filename Q
|
|
||||||
static char TrackLoadBuffer[BUFLEN]; // for track filename F
|
|
||||||
static char TrackLoadLeftBuffer[BUFLEN]; // for track filename L
|
|
||||||
static char TrackLoadRightBuffer[BUFLEN]; // for track filename R
|
|
||||||
static char PitLoadBuffer[BUFLEN]; // for pit track filename F
|
|
||||||
static char PitLoadLeftBuffer[BUFLEN]; // for pit track filename L
|
|
||||||
static char PitLoadRightBuffer[BUFLEN]; // for pit track filename R*/
|
|
||||||
//==========================================================================*
|
|
||||||
|
|
||||||
//==========================================================================*
|
//==========================================================================*
|
||||||
// Skilling: Randomness
|
// Skilling: Randomness
|
||||||
//--------------------------------------------------------------------------*
|
//--------------------------------------------------------------------------*
|
||||||
|
@ -135,7 +103,7 @@ static const double s_sgMin[] = { 0.00, 10 };
|
||||||
static const double s_sgMax[] = { 0.03, 100 };
|
static const double s_sgMax[] = { 0.03, 100 };
|
||||||
static const int s_sgSteps[] = { 10, 18 };
|
static const int s_sgSteps[] = { 10, 18 };
|
||||||
|
|
||||||
TDriver::TDriver(int Index, const int robot_type):
|
TDriver::TDriver(int Index):
|
||||||
m_CarType(0),
|
m_CarType(0),
|
||||||
m_driveType(DT_RWD),
|
m_driveType(DT_RWD),
|
||||||
m_gearUpRpm(9000),
|
m_gearUpRpm(9000),
|
||||||
|
@ -200,75 +168,12 @@ TDriver::TDriver(int Index, const int robot_type):
|
||||||
m_FuelNeeded(0),
|
m_FuelNeeded(0),
|
||||||
|
|
||||||
m_Strategy(NULL),
|
m_Strategy(NULL),
|
||||||
|
m_pShared(NULL),
|
||||||
|
|
||||||
m_raceType(0)
|
m_raceType(0)
|
||||||
{
|
{
|
||||||
INDEX = Index;
|
INDEX = Index;
|
||||||
|
|
||||||
switch(robot_type)
|
|
||||||
{
|
|
||||||
case SHADOW_TRB1:
|
|
||||||
robot_name = "shadow_trb1";
|
|
||||||
Frc = 0.95;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_SC:
|
|
||||||
robot_name = "shadow_sc";
|
|
||||||
Frc = 0.90;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_SRW:
|
|
||||||
robot_name = "shadow_srw";
|
|
||||||
WingControl = true;
|
|
||||||
Frc = 0.95;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_LS1:
|
|
||||||
robot_name = "shadow_ls1";
|
|
||||||
Frc = 0.85;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_LS2:
|
|
||||||
robot_name = "shadow_ls2";
|
|
||||||
Frc = 0.85;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_36GP:
|
|
||||||
robot_name = "shadow_36GP";
|
|
||||||
Frc = 0.75;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_67GP:
|
|
||||||
robot_name = "shadow_67GP";
|
|
||||||
Frc = 0.75;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_RS:
|
|
||||||
robot_name = "shadow_rs";
|
|
||||||
Frc = 0.98;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_LP1:
|
|
||||||
robot_name = "shadow_lp1";
|
|
||||||
Frc = 0.90;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_MPA1:
|
|
||||||
robot_name = "shadow_mpa1";
|
|
||||||
Frc = 0.88;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_MPA11:
|
|
||||||
robot_name = "shadow_mpa11";
|
|
||||||
Frc = 0.88;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SHADOW_MPA12:
|
|
||||||
robot_name = "shadow_mpa12";
|
|
||||||
Frc = 0.88;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int i = 0; i < 50; i++ )
|
for( int i = 0; i < 50; i++ )
|
||||||
{
|
{
|
||||||
m_brkCoeff[i] = 0.5;//0.12;
|
m_brkCoeff[i] = 0.5;//0.12;
|
||||||
|
@ -293,6 +198,9 @@ TDriver::~TDriver()
|
||||||
if (m_Strategy != NULL)
|
if (m_Strategy != NULL)
|
||||||
delete m_Strategy;
|
delete m_Strategy;
|
||||||
|
|
||||||
|
if(m_pShared !=NULL)
|
||||||
|
delete m_pShared;
|
||||||
|
|
||||||
LogSHADOW.debug("\n#<<< TDriver::~TDriver()\n\n");
|
LogSHADOW.debug("\n#<<< TDriver::~TDriver()\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,11 +218,6 @@ static void* MergeParamFile( void* hParams, const char* fileName )
|
||||||
GFPARM_MMODE_RELSRC | GFPARM_MMODE_RELDST);
|
GFPARM_MMODE_RELSRC | GFPARM_MMODE_RELDST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDriver::SetShared( Shared* pShared )
|
|
||||||
{
|
|
||||||
m_pShared = pShared;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================*
|
//==========================================================================*
|
||||||
|
|
||||||
//==========================================================================*
|
//==========================================================================*
|
||||||
|
@ -360,14 +263,12 @@ void TDriver::GetSkillingParameters()
|
||||||
// Global skilling from Andrew Sumner ...
|
// Global skilling from Andrew Sumner ...
|
||||||
// Check if skilling is enabled
|
// Check if skilling is enabled
|
||||||
int SkillEnabled = 0;
|
int SkillEnabled = 0;
|
||||||
char PathFilenameBuffer[512];
|
char PathFilenameBuffer[1024];
|
||||||
|
|
||||||
// Do not skill if optimisation is working
|
snprintf(PathFilenameBuffer, 1024, "%sdrivers/%s/default.xml", GetDataDir(), MyBotName);
|
||||||
//if (!GeneticOpti)
|
|
||||||
{
|
|
||||||
snprintf(PathFilenameBuffer, 512, "%sdrivers/%s/default.xml", GetDataDir(), robot_name);
|
|
||||||
LogSHADOW.debug("#PathFilename: %s\n", PathFilenameBuffer); // itself
|
LogSHADOW.debug("#PathFilename: %s\n", PathFilenameBuffer); // itself
|
||||||
void* SkillHandle = GfParmReadFile(PathFilenameBuffer, GFPARM_RMODE_REREAD);
|
void* SkillHandle = GfParmReadFile(PathFilenameBuffer, GFPARM_RMODE_REREAD);
|
||||||
|
|
||||||
if (SkillHandle)
|
if (SkillHandle)
|
||||||
{
|
{
|
||||||
SkillEnabled = (int) MAX(0,MIN(1,(int) GfParmGetNum(SkillHandle, "skilling", "enable", (char *) NULL, 0.0)));
|
SkillEnabled = (int) MAX(0,MIN(1,(int) GfParmGetNum(SkillHandle, "skilling", "enable", (char *) NULL, 0.0)));
|
||||||
|
@ -377,7 +278,6 @@ void TDriver::GetSkillingParameters()
|
||||||
}
|
}
|
||||||
|
|
||||||
GfParmReleaseHandle(SkillHandle);
|
GfParmReleaseHandle(SkillHandle);
|
||||||
}
|
|
||||||
|
|
||||||
if (SkillEnabled > 0) // If skilling is enabled
|
if (SkillEnabled > 0) // If skilling is enabled
|
||||||
{ // Get Skill level
|
{ // Get Skill level
|
||||||
|
@ -408,7 +308,7 @@ void TDriver::GetSkillingParameters()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get individual skilling
|
// Get individual skilling
|
||||||
snprintf(PathFilenameBuffer, 256, "%sdrivers/%s/%d/skill.xml", GetDataDir(), robot_name, INDEX);
|
snprintf(PathFilenameBuffer, 256, "%sdrivers/%s/%d/skill.xml", GetDataDir(), MyBotName, INDEX);
|
||||||
LogSHADOW.debug("#PathFilename: %s\n", PathFilenameBuffer); // itself
|
LogSHADOW.debug("#PathFilename: %s\n", PathFilenameBuffer); // itself
|
||||||
SkillHandle = GfParmReadFile(PathFilenameBuffer, GFPARM_RMODE_REREAD);
|
SkillHandle = GfParmReadFile(PathFilenameBuffer, GFPARM_RMODE_REREAD);
|
||||||
|
|
||||||
|
@ -441,11 +341,15 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl
|
||||||
void* hCarParm = 0;
|
void* hCarParm = 0;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char trackName[256];
|
char trackName[256];
|
||||||
|
char carName[256];
|
||||||
track = pTrack;
|
track = pTrack;
|
||||||
|
|
||||||
// Initialize the base param path
|
const char *car_sect = SECT_GROBJECTS "/" LST_RANGES "/" "1";
|
||||||
//const char* BaseParamPath = TDriver::robot_name;
|
strncpy(carName, GfParmGetStr(pCarHandle, car_sect, PRM_CAR, ""), sizeof(carName));
|
||||||
//const char* PathFilename = PathFilenameBuffer;
|
char *p = strrchr(carName, '.');
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
SkillGlobal = Skill = DecelAdjustPerc = DriverAggression = SkillAdjustLimit = 0.0;
|
SkillGlobal = Skill = DecelAdjustPerc = DriverAggression = SkillAdjustLimit = 0.0;
|
||||||
GetSkillingParameters();
|
GetSkillingParameters();
|
||||||
|
@ -472,8 +376,8 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl
|
||||||
// set up the base param path.
|
// set up the base param path.
|
||||||
//
|
//
|
||||||
|
|
||||||
snprintf(buf, BUFSIZE, "drivers/%s/%s/default.xml", robot_name, m_CarType);
|
snprintf(buf, BUFSIZE, "drivers/%s/%s/default.xml", MyBotName, carName);
|
||||||
LogSHADOW.info("#Path for default.xml = drivers/%s/%s/default.xml\n", robot_name, m_CarType);
|
LogSHADOW.info("#Path for default.xml = drivers/%s/%s/default.xml\n", MyBotName, carName);
|
||||||
|
|
||||||
*ppCarParmHandle = GfParmReadFile(buf, GFPARM_RMODE_STD);
|
*ppCarParmHandle = GfParmReadFile(buf, GFPARM_RMODE_STD);
|
||||||
|
|
||||||
|
@ -486,7 +390,7 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl
|
||||||
if (!m_Rain)
|
if (!m_Rain)
|
||||||
{
|
{
|
||||||
// default params for car type (e.g. clkdtm)
|
// default params for car type (e.g. clkdtm)
|
||||||
snprintf( buf, BUFSIZE, "drivers/%s/%s/%s.xml", robot_name, m_CarType, trackName );
|
snprintf( buf, BUFSIZE, "drivers/%s/%s/%s.xml", MyBotName, carName, trackName );
|
||||||
LogSHADOW.info("#Override params for car type with params of track: %s\n", buf);
|
LogSHADOW.info("#Override params for car type with params of track: %s\n", buf);
|
||||||
hCarParm = MergeParamFile(hCarParm, buf);
|
hCarParm = MergeParamFile(hCarParm, buf);
|
||||||
}
|
}
|
||||||
|
@ -494,13 +398,13 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl
|
||||||
if (m_Rain)
|
if (m_Rain)
|
||||||
{
|
{
|
||||||
// Override params for car type with params of track and weather
|
// Override params for car type with params of track and weather
|
||||||
snprintf(buf, BUFSIZE, "drivers/%s/%s/%s-%d.xml", robot_name, m_CarType, trackName, m_WeatherCode);
|
snprintf(buf, BUFSIZE, "drivers/%s/%s/%s-%d.xml", MyBotName, carName, trackName, m_WeatherCode);
|
||||||
LogSHADOW.info("#Override params for car type with params of track and weather: %s\n", buf);
|
LogSHADOW.info("#Override params for car type with params of track and weather: %s\n", buf);
|
||||||
hCarParm = MergeParamFile(hCarParm, buf);
|
hCarParm = MergeParamFile(hCarParm, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// override params for car type on track of specific race type.
|
// override params for car type on track of specific race type.
|
||||||
snprintf( buf, sizeof(buf), "drivers/%s/%s/track-%s-%s.xml", robot_name, m_CarType, trackName, raceType[pS->_raceType] );
|
snprintf( buf, sizeof(buf), "drivers/%s/%s/track-%s-%s.xml", MyBotName, carName, trackName, raceType[pS->_raceType] );
|
||||||
LogSHADOW.info("#Override params for car type with params of track and race type: %s\n", buf);
|
LogSHADOW.info("#Override params for car type with params of track and race type: %s\n", buf);
|
||||||
hCarParm = MergeParamFile(hCarParm, buf);
|
hCarParm = MergeParamFile(hCarParm, buf);
|
||||||
|
|
||||||
|
@ -651,6 +555,8 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl
|
||||||
oCarHasESP = true;
|
oCarHasESP = true;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
m_pShared = new Shared();
|
||||||
|
|
||||||
MyTrack::SideMod sideMod;
|
MyTrack::SideMod sideMod;
|
||||||
sideMod.side = -1;
|
sideMod.side = -1;
|
||||||
const char* pStr = GfParmGetStr(hCarParm, SECT_PRIV, PRV_SIDE_MOD, "");
|
const char* pStr = GfParmGetStr(hCarParm, SECT_PRIV, PRV_SIDE_MOD, "");
|
||||||
|
@ -720,7 +626,7 @@ void TDriver::NewRace( tCarElt* pCar, tSituation* pS )
|
||||||
char* pTrackName = strrchr(m_track.GetTrack()->filename, '/') + 1;
|
char* pTrackName = strrchr(m_track.GetTrack()->filename, '/') + 1;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
snprintf( buf, 256, "drivers/%s/%s.spr", robot_name, pTrackName );
|
snprintf( buf, 256, "drivers/%s/%s.spr", MyBotName, pTrackName );
|
||||||
|
|
||||||
initCw();
|
initCw();
|
||||||
LogSHADOW.debug(" CW = %.3f\n", m_cm.CD_BODY);
|
LogSHADOW.debug(" CW = %.3f\n", m_cm.CD_BODY);
|
||||||
|
|
|
@ -118,8 +118,6 @@ class SimpleStrategy;
|
||||||
// Speed Dreams-Interface
|
// Speed Dreams-Interface
|
||||||
//--------------------------------------------------------------------------*
|
//--------------------------------------------------------------------------*
|
||||||
static const int MAX_NBBOTS = 100;
|
static const int MAX_NBBOTS = 100;
|
||||||
static const int MAXNBBOTS = MAX_NBBOTS; // Number of drivers/robots
|
|
||||||
static const int BUFSIZE = 256;
|
|
||||||
|
|
||||||
enum { SHADOW_TRB1=1, SHADOW_SC, SHADOW_SRW, SHADOW_LS1, SHADOW_LS2, SHADOW_36GP,
|
enum { SHADOW_TRB1=1, SHADOW_SC, SHADOW_SRW, SHADOW_LS1, SHADOW_LS2, SHADOW_36GP,
|
||||||
SHADOW_67GP, SHADOW_RS, SHADOW_LP1, SHADOW_MPA1, SHADOW_MPA11, SHADOW_MPA12 };
|
SHADOW_67GP, SHADOW_RS, SHADOW_LP1, SHADOW_MPA1, SHADOW_MPA11, SHADOW_MPA12 };
|
||||||
|
@ -144,10 +142,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TDriver(int index, const int robot_type); // Constructor
|
TDriver(int index); // Constructor
|
||||||
~TDriver(); // Destructor
|
~TDriver(); // Destructor
|
||||||
|
|
||||||
void SetShared( Shared* pShared );
|
|
||||||
void InitTrack(tTrack* track, void* carHandle, void** carParmHandle, tSituation* s);
|
void InitTrack(tTrack* track, void* carHandle, void** carParmHandle, tSituation* s);
|
||||||
void NewRace(tCarElt* car, tSituation* s );
|
void NewRace(tCarElt* car, tSituation* s );
|
||||||
|
|
||||||
|
@ -204,15 +201,11 @@ public:
|
||||||
|
|
||||||
static int NBBOTS; // Nbr of cars
|
static int NBBOTS; // Nbr of cars
|
||||||
double CurrSimTime; // Current simulation time
|
double CurrSimTime; // Current simulation time
|
||||||
static const char *robot_name;
|
|
||||||
double Frc; // Friction coefficient
|
double Frc; // Friction coefficient
|
||||||
//bool UseBrakeLimit; // Enable/disable brakelimit
|
//bool UseBrakeLimit; // Enable/disable brakelimit
|
||||||
|
|
||||||
double wheelRadius;
|
double wheelRadius;
|
||||||
|
|
||||||
static const char* ROBOT_DIR; // Sub path to dll
|
|
||||||
static const char* DEFAULTCARTYPE; // Default car type
|
|
||||||
|
|
||||||
static int RobotType;
|
static int RobotType;
|
||||||
static bool AdvancedParameters;
|
static bool AdvancedParameters;
|
||||||
static bool UseOldSkilling;
|
static bool UseOldSkilling;
|
||||||
|
@ -298,6 +291,8 @@ public:
|
||||||
double m_LastAccel;
|
double m_LastAccel;
|
||||||
int m_LastPosIdx; // Last brake position
|
int m_LastPosIdx; // Last brake position
|
||||||
|
|
||||||
|
const char* MyBotName; // Name of this bot
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ProcessOtherCars( int index, tCarElt* car, double spd, tSituation* s );
|
void ProcessOtherCars( int index, tCarElt* car, double spd, tSituation* s );
|
||||||
void AvoidOtherCars( int index, tCarElt* car, double k, double& carTargetSpd, tSituation* s, bool& inTraffic, bool& lapper );
|
void AvoidOtherCars( int index, tCarElt* car, double k, double& carTargetSpd, tSituation* s, bool& inTraffic, bool& lapper );
|
||||||
|
@ -352,8 +347,8 @@ private:
|
||||||
double BUMP_MOD;
|
double BUMP_MOD;
|
||||||
int SPDC_NORMAL;
|
int SPDC_NORMAL;
|
||||||
int SPDC_TRAFFIC;
|
int SPDC_TRAFFIC;
|
||||||
int SPDC_EXTRA;
|
int SPDC_EXTRA;
|
||||||
int STEER_CTRL;
|
int STEER_CTRL;
|
||||||
double STEER_K_ACC;
|
double STEER_K_ACC;
|
||||||
double STEER_K_DEC;
|
double STEER_K_DEC;
|
||||||
double STAY_TOGETHER; // dist in m.
|
double STAY_TOGETHER; // dist in m.
|
||||||
|
|
Loading…
Reference in a new issue