Update genparoptv1 for simuv4

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

Former-commit-id: e19d0e51c8bc30e4a3ecd1e35464cc5ec3275067
Former-commit-id: 21216627ac47ec502a3bfe729b35c77e602be71e
This commit is contained in:
wdbee 2014-11-29 12:14:30 +00:00
parent cc73725af7
commit 7eb37d6bea
7 changed files with 79 additions and 17 deletions

View file

@ -52,6 +52,7 @@ TGeneticParameter::TGeneticParameter():
Changed(0),
Selected(false),
LeftRight(false),
SameSign(true),
Label(NULL),
Section(NULL),
Parameter(NULL),
@ -74,7 +75,7 @@ TGeneticParameter::TGeneticParameter
float ParamWeight,
float ParamScale,
float ParamRound,
bool TwoSided
int TwoSided
)
{
Handle = MetaDataFile;
@ -123,7 +124,19 @@ TGeneticParameter::TGeneticParameter
Range = Max - Min;
}
LeftRight = TwoSided;
if (TwoSided != 0)
{
LeftRight = true;
if (TwoSided > 0)
SameSign = true;
else
SameSign = false;
}
else
{
SameSign = true;
LeftRight = false;
}
};
@ -165,7 +178,16 @@ int TGeneticParameter::Set(const char* Part, int Index)
sprintf(ParamSection,"%s/%d",Part,Index);
GfParmSetNum(Handle, ParamSection, PRM_ACTIVE, 0, (float) Active);
GfParmSetNum(Handle, ParamSection, PRM_TWOSIDE, 0, (float) LeftRight);
if (LeftRight)
{
if (SameSign)
GfParmSetNum(Handle, ParamSection, PRM_TWOSIDE, 0, 1);
else
GfParmSetNum(Handle, ParamSection, PRM_TWOSIDE, 0, -1);
}
else
GfParmSetNum(Handle, ParamSection, PRM_TWOSIDE, 0, 0);
GfParmSetStr(Handle, ParamSection, PRM_LABEL, Label);
GfParmSetStr(Handle, ParamSection, PRM_SECT, Section);
@ -198,7 +220,21 @@ int TGeneticParameter::Get(bool First, const char* Part)
GfParmListSeekNext(Handle, ParamSection);
Active = 0 < GfParmGetCurNum(Handle, ParamSection, PRM_ACTIVE, 0, 1);
LeftRight = 0 < GfParmGetCurNum(Handle, ParamSection, PRM_TWOSIDE, 0, 0);
int Flags = GfParmGetCurNum(Handle, ParamSection, PRM_TWOSIDE, 0, 0);
if (Flags != 0)
{
LeftRight = true;
if (Flags > 0)
SameSign = true;
else
SameSign = false;
}
else
{
SameSign = true;
LeftRight = false;
}
char* Value = (char *) GfParmGetCurStr(Handle, ParamSection, PRM_LABEL, Label);
if (Label)
@ -268,7 +304,11 @@ int TGeneticParameter::GetVal(void* SetupHandle, bool First, bool Local)
Val = GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val);
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
Val = (Val + GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
if (SameSign)
Val = (Val + GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
else
Val = (Val - GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
}
else
@ -284,7 +324,11 @@ int TGeneticParameter::GetVal(void* SetupHandle, bool First, bool Local)
Val = GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val);
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
Val = (Val + GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
if (SameSign)
Val = (Val + GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
else
Val = (Val - GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
}
else
@ -313,7 +357,11 @@ int TGeneticParameter::SetVal(void* SetupHandle, int Index)
GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
if(SameSign)
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
else
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, -Val, Min, Max);
}
else
return GfParmSetNum(SetupHandle, ParamSection, Parameter, Unit, Val, Min, Max);

View file

@ -37,7 +37,7 @@
#define SECT_PH_RGHT "Right"
#define PRM_ACTIVE "active"
#define PRM_TWOSIDE "twosided"
#define PRM_TWOSIDE "twosided" // 0: no 1: same sign; -1 opposite sign
#define PRM_LABEL "label"
#define PRM_SECT "section"
#define PRM_SUBSECT "subsection"
@ -205,7 +205,7 @@ class TGeneticParameter
float ParamScale, // Scales the random variation of the value
float ParamRound, // Defines the rounding
// (to be able to write it in xml without loss of information)
bool TwoSided = false // If there are left and right parameters to be set
int TwoSided = 0 // If there are left and right parameters to be set
);
@ -250,6 +250,7 @@ class TGeneticParameter
// (to avoid multiple variations)
bool LeftRight;
bool SameSign;
char *Label;
char *Section;

View file

@ -1092,6 +1092,7 @@ ReImportGeneticParameters()
}
else
{
// C:\Users\wdb\Documents\speed-dreams-2.settings\drivers\simplix_srw\srw-sector-p4
// Build path to meta data file
snprintf(buf,sizeof(buf),"%sdrivers/%s/%s/genetic-template.xml",
GetLocalDir(),Data->RobotName,Data->CarType);

View file

@ -23,7 +23,7 @@
tdble rho = 1.290f; /* air density, prepare for variable environment */
// Christos plausibhility check ...
// Christos plausibility check ...
tdble Max_Cl_given_Cd (tdble Cd)
{
// if Cd = 1, then all air hitting the surface is stopped.

View file

@ -39,11 +39,11 @@ void SimAxleConfig(tCar *car, int index, tdble weight0)
if (index == 0) {
SimSuspConfig(hdle, SECT_FRNTARB, &(axle->arbSusp), 0, 0);
axle->arbSusp.spring.K = -axle->arbSusp.spring.K;
SimSuspConfig(hdle, SECT_FRNTHEAVE, &(axle->heaveSusp), weight0, 0.5*(x0r+x0l));
SimSuspConfig(hdle, SECT_FRNTHEAVE, &(axle->heaveSusp), weight0, (tdble) (0.5*(x0r+x0l)));
} else {
SimSuspConfig(hdle, SECT_REARARB, &(axle->arbSusp), 0, 0);
axle->arbSusp.spring.K = -axle->arbSusp.spring.K;
SimSuspConfig(hdle, SECT_REARHEAVE, &(axle->heaveSusp), weight0, 0.5*(x0r+x0l));
SimSuspConfig(hdle, SECT_REARHEAVE, &(axle->heaveSusp), weight0, (tdble) (0.5*(x0r+x0l)));
}
car->wheel[index*2].feedBack.I += (tdble) (axle->I / 2.0);
@ -78,10 +78,10 @@ void SimAxleUpdate(tCar *car, int index)
car->wheel[index*2+1].axleFz = - sgn * f;
/* heave/center spring */
axle->heaveSusp.x = 0.5 * (stl + str);
axle->heaveSusp.v = 0.5 * (vtl + vtr);
axle->heaveSusp.x = (tdble) (0.5 * (stl + str));
axle->heaveSusp.v = (tdble) (0.5 * (vtl + vtr));
SimSuspUpdate(&(axle->heaveSusp));
f = 0.5 * axle->heaveSusp.force;
f = (tdble) (0.5 * axle->heaveSusp.force);
car->wheel[index*2].axleFz3rd = f;
car->wheel[index*2+1].axleFz3rd = f;
}

View file

@ -682,7 +682,7 @@ static void OnActivateNetworkClient(void *)
} else {
// Ensure menu system knows about all cars
GfDrivers::self()->reload();
tRmInfo* reInfo = LmRaceEngine().inData();
// tRmInfo* reInfo = LmRaceEngine().inData(); // Never used
LmRaceEngine().race()->load(LmRaceEngine().race()->getManager(), true);
}
}
@ -731,7 +731,7 @@ rmCarSettingsMenu(void *pMenu)
if (nDriverIdx > -1) {
NetDriver driver;
char newName[64];
// char newName[64]; Never used
char dname[256];
// check for car change

View file

@ -393,6 +393,18 @@ RmOptimizationScreenSetParameterText(int N, char** Labels, char** Values, char**
GfuiLabelSetText(HScreen, ParameterRangeIds[I], "");
}
for (int I = N; I < 8; I++)
{
freez(Parameters[I]);
GfuiLabelSetText(HScreen, ParameterIds[I], "");
freez(ParameterValues[I]);
GfuiLabelSetText(HScreen, ParameterValueIds[I], "");
freez(ParameterRanges[I]);
GfuiLabelSetText(HScreen, ParameterRangeIds[I], "");
}
if (!AnyTextDisplayed)
{
void *hmenu = GfuiMenuLoad("optimizationscreen.xml");