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:
parent
cc73725af7
commit
7eb37d6bea
7 changed files with 79 additions and 17 deletions
|
@ -52,6 +52,7 @@ TGeneticParameter::TGeneticParameter():
|
||||||
Changed(0),
|
Changed(0),
|
||||||
Selected(false),
|
Selected(false),
|
||||||
LeftRight(false),
|
LeftRight(false),
|
||||||
|
SameSign(true),
|
||||||
Label(NULL),
|
Label(NULL),
|
||||||
Section(NULL),
|
Section(NULL),
|
||||||
Parameter(NULL),
|
Parameter(NULL),
|
||||||
|
@ -74,7 +75,7 @@ TGeneticParameter::TGeneticParameter
|
||||||
float ParamWeight,
|
float ParamWeight,
|
||||||
float ParamScale,
|
float ParamScale,
|
||||||
float ParamRound,
|
float ParamRound,
|
||||||
bool TwoSided
|
int TwoSided
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Handle = MetaDataFile;
|
Handle = MetaDataFile;
|
||||||
|
@ -123,7 +124,19 @@ TGeneticParameter::TGeneticParameter
|
||||||
Range = Max - Min;
|
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);
|
sprintf(ParamSection,"%s/%d",Part,Index);
|
||||||
|
|
||||||
GfParmSetNum(Handle, ParamSection, PRM_ACTIVE, 0, (float) Active);
|
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_LABEL, Label);
|
||||||
GfParmSetStr(Handle, ParamSection, PRM_SECT, Section);
|
GfParmSetStr(Handle, ParamSection, PRM_SECT, Section);
|
||||||
|
@ -198,7 +220,21 @@ int TGeneticParameter::Get(bool First, const char* Part)
|
||||||
GfParmListSeekNext(Handle, ParamSection);
|
GfParmListSeekNext(Handle, ParamSection);
|
||||||
|
|
||||||
Active = 0 < GfParmGetCurNum(Handle, ParamSection, PRM_ACTIVE, 0, 1);
|
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);
|
char* Value = (char *) GfParmGetCurStr(Handle, ParamSection, PRM_LABEL, Label);
|
||||||
if (Label)
|
if (Label)
|
||||||
|
@ -268,7 +304,11 @@ int TGeneticParameter::GetVal(void* SetupHandle, bool First, bool Local)
|
||||||
Val = GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val);
|
Val = GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val);
|
||||||
|
|
||||||
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
|
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
|
||||||
|
|
||||||
|
if (SameSign)
|
||||||
Val = (Val + GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
|
Val = (Val + GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
|
||||||
|
else
|
||||||
|
Val = (Val - GfParmGetCurNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -284,7 +324,11 @@ int TGeneticParameter::GetVal(void* SetupHandle, bool First, bool Local)
|
||||||
Val = GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val);
|
Val = GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val);
|
||||||
|
|
||||||
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
|
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
|
||||||
|
|
||||||
|
if (SameSign)
|
||||||
Val = (Val + GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
|
Val = (Val + GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
|
||||||
|
else
|
||||||
|
Val = (Val - GfParmGetNum(SetupHandle, SideParam, Parameter, Unit, Val)) / 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -313,7 +357,11 @@ int TGeneticParameter::SetVal(void* SetupHandle, int Index)
|
||||||
GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
|
GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
|
||||||
|
|
||||||
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
|
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
|
||||||
|
|
||||||
|
if(SameSign)
|
||||||
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
|
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
|
||||||
|
else
|
||||||
|
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, -Val, Min, Max);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return GfParmSetNum(SetupHandle, ParamSection, Parameter, Unit, Val, Min, Max);
|
return GfParmSetNum(SetupHandle, ParamSection, Parameter, Unit, Val, Min, Max);
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#define SECT_PH_RGHT "Right"
|
#define SECT_PH_RGHT "Right"
|
||||||
|
|
||||||
#define PRM_ACTIVE "active"
|
#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_LABEL "label"
|
||||||
#define PRM_SECT "section"
|
#define PRM_SECT "section"
|
||||||
#define PRM_SUBSECT "subsection"
|
#define PRM_SUBSECT "subsection"
|
||||||
|
@ -205,7 +205,7 @@ class TGeneticParameter
|
||||||
float ParamScale, // Scales the random variation of the value
|
float ParamScale, // Scales the random variation of the value
|
||||||
float ParamRound, // Defines the rounding
|
float ParamRound, // Defines the rounding
|
||||||
// (to be able to write it in xml without loss of information)
|
// (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)
|
// (to avoid multiple variations)
|
||||||
|
|
||||||
bool LeftRight;
|
bool LeftRight;
|
||||||
|
bool SameSign;
|
||||||
|
|
||||||
char *Label;
|
char *Label;
|
||||||
char *Section;
|
char *Section;
|
||||||
|
|
|
@ -1092,6 +1092,7 @@ ReImportGeneticParameters()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// C:\Users\wdb\Documents\speed-dreams-2.settings\drivers\simplix_srw\srw-sector-p4
|
||||||
// Build path to meta data file
|
// Build path to meta data file
|
||||||
snprintf(buf,sizeof(buf),"%sdrivers/%s/%s/genetic-template.xml",
|
snprintf(buf,sizeof(buf),"%sdrivers/%s/%s/genetic-template.xml",
|
||||||
GetLocalDir(),Data->RobotName,Data->CarType);
|
GetLocalDir(),Data->RobotName,Data->CarType);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
tdble rho = 1.290f; /* air density, prepare for variable environment */
|
tdble rho = 1.290f; /* air density, prepare for variable environment */
|
||||||
|
|
||||||
// Christos plausibhility check ...
|
// Christos plausibility check ...
|
||||||
tdble Max_Cl_given_Cd (tdble Cd)
|
tdble Max_Cl_given_Cd (tdble Cd)
|
||||||
{
|
{
|
||||||
// if Cd = 1, then all air hitting the surface is stopped.
|
// if Cd = 1, then all air hitting the surface is stopped.
|
||||||
|
|
|
@ -39,11 +39,11 @@ void SimAxleConfig(tCar *car, int index, tdble weight0)
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
SimSuspConfig(hdle, SECT_FRNTARB, &(axle->arbSusp), 0, 0);
|
SimSuspConfig(hdle, SECT_FRNTARB, &(axle->arbSusp), 0, 0);
|
||||||
axle->arbSusp.spring.K = -axle->arbSusp.spring.K;
|
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 {
|
} else {
|
||||||
SimSuspConfig(hdle, SECT_REARARB, &(axle->arbSusp), 0, 0);
|
SimSuspConfig(hdle, SECT_REARARB, &(axle->arbSusp), 0, 0);
|
||||||
axle->arbSusp.spring.K = -axle->arbSusp.spring.K;
|
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);
|
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;
|
car->wheel[index*2+1].axleFz = - sgn * f;
|
||||||
|
|
||||||
/* heave/center spring */
|
/* heave/center spring */
|
||||||
axle->heaveSusp.x = 0.5 * (stl + str);
|
axle->heaveSusp.x = (tdble) (0.5 * (stl + str));
|
||||||
axle->heaveSusp.v = 0.5 * (vtl + vtr);
|
axle->heaveSusp.v = (tdble) (0.5 * (vtl + vtr));
|
||||||
SimSuspUpdate(&(axle->heaveSusp));
|
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].axleFz3rd = f;
|
||||||
car->wheel[index*2+1].axleFz3rd = f;
|
car->wheel[index*2+1].axleFz3rd = f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,7 +682,7 @@ static void OnActivateNetworkClient(void *)
|
||||||
} else {
|
} else {
|
||||||
// Ensure menu system knows about all cars
|
// Ensure menu system knows about all cars
|
||||||
GfDrivers::self()->reload();
|
GfDrivers::self()->reload();
|
||||||
tRmInfo* reInfo = LmRaceEngine().inData();
|
// tRmInfo* reInfo = LmRaceEngine().inData(); // Never used
|
||||||
LmRaceEngine().race()->load(LmRaceEngine().race()->getManager(), true);
|
LmRaceEngine().race()->load(LmRaceEngine().race()->getManager(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -731,7 +731,7 @@ rmCarSettingsMenu(void *pMenu)
|
||||||
|
|
||||||
if (nDriverIdx > -1) {
|
if (nDriverIdx > -1) {
|
||||||
NetDriver driver;
|
NetDriver driver;
|
||||||
char newName[64];
|
// char newName[64]; Never used
|
||||||
char dname[256];
|
char dname[256];
|
||||||
|
|
||||||
// check for car change
|
// check for car change
|
||||||
|
|
|
@ -393,6 +393,18 @@ RmOptimizationScreenSetParameterText(int N, char** Labels, char** Values, char**
|
||||||
GfuiLabelSetText(HScreen, ParameterRangeIds[I], "");
|
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)
|
if (!AnyTextDisplayed)
|
||||||
{
|
{
|
||||||
void *hmenu = GfuiMenuLoad("optimizationscreen.xml");
|
void *hmenu = GfuiMenuLoad("optimizationscreen.xml");
|
||||||
|
|
Loading…
Reference in a new issue