Bugfix simplix

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

Former-commit-id: 825ad14684e57f7478092d3b40452c83614558a3
Former-commit-id: a47cd1e6dd3d240081b1e9afbe39fb6e9039751d
This commit is contained in:
wdbee 2014-12-01 16:22:22 +00:00
parent 7eb37d6bea
commit a72e54aa1f
16 changed files with 106 additions and 59 deletions

View file

@ -169,25 +169,25 @@ void KDriver::drive(tSituation * s) {
if (IsStuck()) {
Unstuck();
} else {
car_->_steerCmd = GetSteer(s);
car_->_steerCmd = (tdble) GetSteer(s);
car_->_gearCmd = GetGear();
CalcSpeed();
car_->_brakeCmd = FilterABS(
car_->_brakeCmd = (tdble) (FilterABS(
FilterBrakeSpeed(
FilterBColl(
FilterBPit(
GetBrake()))));
GetBrake())))));
if (car_->_brakeCmd == 0.0) {
car_->_accelCmd = FilterAccel(
car_->_accelCmd = (tdble) (FilterAccel(
FilterTCL(
FilterTrk(
FilterOverlap(
GetAccel()))));
GetAccel())))));
} else {
car_->_accelCmd = 0.0;
}
car_->_clutchCmd = GetClutch();
car_->_clutchCmd = (tdble) (GetClutch());
} // if IsStuck
#if 0
@ -849,7 +849,7 @@ double KDriver::FilterBColl(const double brake) {
*/
int KDriver::pitCommand(tSituation * s) {
car_->_pitRepair = strategy_->PitRepair();
car_->_pitFuel = strategy_->PitRefuel();
car_->_pitFuel = (tdble) (strategy_->PitRefuel());
// This should be the only place where the pit stop is set to false!
pit_->set_pitstop(false);
return ROB_PIT_IM; // return immediately.
@ -1050,7 +1050,7 @@ void KDriver::InitCa() {
double h = 0.0;
for (int i = 0; i < 4; ++i)
h += GfParmGetNum(car_->_carHandle, WheelSect[i],
PRM_RIDEHEIGHT, NULL, 0.2);
PRM_RIDEHEIGHT, NULL, 0.2f);
h *= 1.5;
h = pow(h, 4);
h = 2.0 * exp(-3.0 * h);
@ -1626,8 +1626,8 @@ vec2f KDriver::TargetPoint() {
return s;
}
s.x = (seg->vertex[TR_SL].x + seg->vertex[TR_SR].x) / 2.0;
s.y = (seg->vertex[TR_SL].y + seg->vertex[TR_SR].y) / 2.0;
s.x = (tdble) ((seg->vertex[TR_SL].x + seg->vertex[TR_SR].x) / 2.0);
s.y = (tdble) ((seg->vertex[TR_SL].y + seg->vertex[TR_SR].y) / 2.0);
if (seg->type == TR_STR) {
vec2f n((seg->vertex[TR_EL].x - seg->vertex[TR_ER].x) / seg->length,
@ -1900,7 +1900,7 @@ double KDriver::InitSkill(tSituation * s) {
void KDriver::Unstuck() {
car_->_steerCmd = - my_cardata_->getCarAngle() / car_->_steerLock;
car_->_steerCmd = (tdble) (- my_cardata_->getCarAngle() / car_->_steerLock);
car_->_gearCmd = -1; // Reverse gear.
car_->_accelCmd = 1.0; // 100% accelerator pedal.
car_->_brakeCmd = 0.0; // No brakes.

View file

@ -477,7 +477,7 @@ void LRaceLine::Interpolate(int Step, int rl) {
void LRaceLine::InitTrack(const tTrack * const track, void **parm_handle,
const tSituation *s, const double filterSideSkill) {
min_corner_inverse_ = GfParmGetNum(*parm_handle, KILO_SECT_PRIV,
KILO_ATT_MINCORNER, NULL, 0.002);
KILO_ATT_MINCORNER, NULL, 0.002f);
corner_speed_ = GfParmGetNum(*parm_handle, KILO_SECT_PRIV,
KILO_ATT_CORNERSP, NULL, 15.0);
avoid_speed_adjust_ = GfParmGetNum(*parm_handle, KILO_SECT_PRIV,
@ -818,8 +818,8 @@ void LRaceLine::GetPoint(const double offset, const double lookahead,
vec2f * const rt) const {
double dLane = (width_ / 2.0 - offset) / width_;
vec2f last;
last.x = dLane * seg_[this_].txRight + (1.0 - dLane) * seg_[this_].txLeft;
last.y = dLane * seg_[this_].tyRight + (1.0 - dLane) * seg_[this_].tyLeft;
last.x = (tdble) (dLane * seg_[this_].txRight + (1.0 - dLane) * seg_[this_].txLeft);
last.y = (tdble) (dLane * seg_[this_].tyRight + (1.0 - dLane) * seg_[this_].tyLeft);
int ndiv = next_;
double dLength = 0.0;
@ -827,8 +827,8 @@ void LRaceLine::GetPoint(const double offset, const double lookahead,
* MIN(1.0, MAX(0.8, car_->_speed_x / target_speed_));
int iLookaheadLimit = static_cast<int>(la / div_length_);
for (int count = 0; count < iLookaheadLimit && dLength < la; count++) {
rt->x = dLane * seg_[ndiv].txRight + (1 - dLane) * seg_[ndiv].txLeft;
rt->y = dLane * seg_[ndiv].tyRight + (1 - dLane) * seg_[ndiv].tyLeft;
rt->x = (tdble) (dLane * seg_[ndiv].txRight + (1 - dLane) * seg_[ndiv].txLeft);
rt->y = (tdble) (dLane * seg_[ndiv].tyRight + (1 - dLane) * seg_[ndiv].tyLeft);
vec2f d = (*rt) - last;
dLength += Mag(d.x, d.y);

View file

@ -70,7 +70,7 @@ void KStrategy::SetFuelAtRaceStart(const tTrack * const t,
GfParmGetNum(*carParmHandle, SECT_ENGINE, PRM_FUELCONS, NULL, 1.0f);
const double fuel =
GfParmGetNum(*carParmHandle, KILO_SECT_PRIV, KILO_ATT_FUELPERLAP,
NULL, t->length * MAX_FUEL_PER_METER * fuel_cons_factor);
NULL, (tdble) (t->length * MAX_FUEL_PER_METER * fuel_cons_factor));
expected_fuel_per_lap_ = fuel;
// Pittime is pittime without refuel.
pittime_ = GfParmGetNum(*carParmHandle, KILO_SECT_PRIV,
@ -98,15 +98,15 @@ void KStrategy::SetFuelAtRaceStart(const tTrack * const t,
PRM_FUEL, NULL, 0.0);
if (s->_raceType == RM_TYPE_RACE) {
if (initial_fuel) {
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, initial_fuel);
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, (tdble) initial_fuel);
} else {
// Add fuel dependent on index to avoid fuel stop in the same lap.
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL,
last_fuel_ + index * expected_fuel_per_lap_);
(tdble) (last_fuel_ + index * expected_fuel_per_lap_));
}
} else {
// Use fuel for whole 'race', ie qualy or practice N laps.
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, fuelForRace);
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, (tdble) fuelForRace);
}
} // SetFuelAtRaceStart

View file

@ -392,7 +392,7 @@ void TClothoidLane::SetOffset
+ MAX(0.0,MIN(oFixCarParam.oMaxBorderInner,
oFixCarParam.oBorderScale * fabs(Crv) - 1));
double BorderOuter = oFixCarParam.oBorderOuter;
if (Crv >= 0) // turn to left
{
if (LaneType == ltLeft)
@ -667,16 +667,16 @@ bool TClothoidLane::SaveToFile(const char* Filename)
fprintf(F, "%d\n",oTrack->Count());
fprintf(F, "%g\n",oTrack->Length());
fprintf(F, "%g\n",oTrack->Length()/oTrack->Count());
fprintf(F, "%g\n",oTrack->Width());
for (int I = 0; I < oTrack->Count(); I++)
{
TPathPt& P = oPathPoints[I]; // Points in this lane
const TVec3d& C = P.Pt();
const TVec3d& N = P.Norm();
fprintf(F, "%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n",
I,C.x, C.y, C.z, N.x, N.y, N.z, P.WtoL(), P.Offset, P.WtoR(),
P.Point.x, P.Point.y);
fprintf(F, "%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n",
I,C.x, C.y, C.z, N.x, N.y, N.z, P.WToL, P.Offset, P.WToR,
P.Point.x, P.Point.y, P.AccSpd);
}
fclose(F);

View file

@ -79,7 +79,7 @@
#include "unitstrategy.h"
#include "unittrack.h"
//#define EXPORT_RACINGLINE
#define EXPORT_RACINGLINE
//==========================================================================*
// Statics
@ -1621,6 +1621,7 @@ void TDriver::Drive()
GetPosInfo(Pos,oLanePoint); // Info about pts on track
oTargetSpeed = oLanePoint.Speed; // Target for speed control
double InitialTS = oTargetSpeed;
if (!oCarHasTCL)
oTargetSpeed = FilterStart(oTargetSpeed); // Filter Start
//fprintf(stderr,"oTargetSpeed %.2f km/h\n",oTargetSpeed*3.6),
@ -1741,6 +1742,9 @@ void TDriver::Drive()
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);
// fprintf(stderr,"Pos:%+7.2f ITS%+7.2f TS%+7.2f CS%+7.2f wc: %g wemy: %g\n",Pos,InitialTS,oTargetSpeed,oCurrSpeed,oCar->_tyreCondition(0),oCar->_tyreEffMu(0));
/*
double Radius = 1/oLanePoint.Crv;
fprintf(stderr,"R:%+7.2f\n",Radius);
@ -1916,7 +1920,7 @@ void TDriver::FindRacinglines()
(&oTrackDesc, Param, // as main racingline
TClothoidLane::TOptions(oBase,oBaseScale,oBumpMode));
#ifdef EXPORT_RACINGLINE
oRacingLine[oRL_FREE].SaveToFile("RL_FREE.tk3");
oRacingLine[oRL_FREE].SaveToFile("RL_FREE.tk5");
#endif
if (oGeneticOpti)
oRacingLine[oRL_FREE].ClearRacingline(oTrackLoad);
@ -1952,7 +1956,7 @@ void TDriver::FindRacinglines()
(&oTrackDesc, Param, // as main racingline
TClothoidLane::TOptions(oBase,oBaseScale,oBumpMode));
#ifdef EXPORT_RACINGLINE
oRacingLine[oRL_FREE].SaveToFile("RL_FREE.tk3");
oRacingLine[oRL_FREE].SaveToFile("RL_FREE.t5");
#endif
if (oGeneticOpti)
oRacingLine[oRL_FREE].ClearRacingline(oTrackLoad);
@ -1990,7 +1994,7 @@ void TDriver::FindRacinglines()
(&oTrackDesc, Param,
TClothoidLane::TOptions(oBase,oBaseScale,oBumpMode, FLT_MAX, -oAvoidWidth, true));
#ifdef EXPORT_RACINGLINE
oRacingLine[oRL_LEFT].SaveToFile("RL_LEFT.tk3");
oRacingLine[oRL_LEFT].SaveToFile("RL_LEFT.tk5");
#endif
if (oGeneticOpti)
oRacingLine[oRL_LEFT].ClearRacingline(oTrackLoadLeft);
@ -2015,7 +2019,7 @@ void TDriver::FindRacinglines()
(&oTrackDesc, Param,
TClothoidLane::TOptions(oBase,oBaseScale, oBumpMode, -oAvoidWidth, FLT_MAX, true));
#ifdef EXPORT_RACINGLINE
oRacingLine[oRL_RIGHT].SaveToFile("RL_RIGHT.tk3");
oRacingLine[oRL_RIGHT].SaveToFile("RL_RIGHT.tk5");
#endif
if (oGeneticOpti)
oRacingLine[oRL_RIGHT].ClearRacingline(oTrackLoadRight);
@ -2036,9 +2040,9 @@ void TDriver::FindRacinglines()
MaxPitDist = oStrategy->oPit->oPitLane[I].PitDist();
}
#ifdef EXPORT_RACINGLINE
oStrategy->oPit->oPitLane[oRL_FREE].SaveToFile("RL_PIT_FREE.tk3");
oStrategy->oPit->oPitLane[oRL_LEFT].SaveToFile("RL_PIT_LEFT.tk3");
oStrategy->oPit->oPitLane[oRL_RIGHT].SaveToFile("RL_PIT_RIGHT.tk3");
oStrategy->oPit->oPitLane[oRL_FREE].SaveToFile("RL_PIT_FREE.tk5");
oStrategy->oPit->oPitLane[oRL_LEFT].SaveToFile("RL_PIT_LEFT.tk5");
oStrategy->oPit->oPitLane[oRL_RIGHT].SaveToFile("RL_PIT_RIGHT.tk5");
#endif
oStrategy->oDistToSwitch = MaxPitDist + 125; // Distance to pit entry
LogSimplix.debug("\n\n#Dist to switch: %.02f\n\n", oStrategy->oDistToSwitch);

View file

@ -458,10 +458,15 @@ double TFixCarParam::CalcMaxSpeed
if (Den < 0.00001)
Den = 0.00001;
if (Sin * SGN(Crv0) < 0)
if (AbsCrv > 0.01)
{
if (Sin * SGN(Crv0) < 0)
Sin *= 8.0;
}
double Speed = factor * sqrt((Cos * G * Mu + Sin * G * SGN(Crv0) + CrvZ) / Den);
// fprintf(stderr,"S:%g f:%g C:%g M:%g S:%g AbsCrv:%g Crv0:%d CrvZ:%g Den:%g\n",
// Speed,factor,Cos,Mu,Sin,AbsCrv,SGN(Crv0),CrvZ,Den);
if (oDriver->CarCharacteristic.IsValidX(Speed))
Speed *= oDriver->CarCharacteristic.CalcOffset(Speed);

View file

@ -4,7 +4,7 @@
created : Sun Feb 22 23:43:00 CET 2009
last changed : Sun May 29 23:00:00 CET 2011
copyright : (C) 2009-2011 by Wolf-Dieter Beelitz
email : wdb@wdbee.de
email : wdbee@users.sourceforge.net
version : 1.1
***************************************************************************/
@ -24,7 +24,7 @@
It can handle teams with more drivers than cars per pit.
You can see how to use in the simplix robots.
@author <a href=mailto:wdb@wdbee.de>Wolf-Dieter Beelitz</a>
@author <a href=mailto:wdbee@users.sourceforge.net>Wolf-Dieter Beelitz</a>
@version
@ingroup robottools
*/

View file

@ -3,7 +3,7 @@
file : rttimeanalysis.cpp
created : Sun Jun 07 11:15:00 CET 2009
copyright : (C) 2009 by Wolf-Dieter Beelitz
email : wdb@wdbee.de
email : wdbee@users.sourceforge.net
version :
***************************************************************************/
@ -20,7 +20,7 @@
/** @file
This is a collection of useful functions for time analysis
@author <a href=mailto:wdb@wdbee.de>Wolf-Dieter Beelitz</a>
@author <a href=mailto:wdbee@users.sourceforge.net>Wolf-Dieter Beelitz</a>
@version
@ingroup robottools
*/

View file

@ -4,7 +4,7 @@
created : Sun Feb 22 23:43:00 CET 2009
last changed : Sun May 29 23:00:00 CET 2011
copyright : (C) 2009-2011 by Wolf-Dieter Beelitz
email : wdb@wdbee.de
email : wdbee@users.sourceforge.net
version : 1.1
***************************************************************************/
@ -24,7 +24,7 @@
It can handle teams with more drivers than cars per pit.
You can see how to use in the simplix robots.
@author <a href=mailto:wdb@wdbee.de>Wolf-Dieter Beelitz</a>
@author <a href=mailto:wdbee@users.sourceforge.net>Wolf-Dieter Beelitz</a>
@version
@ingroup robottools
*/

View file

@ -3,7 +3,7 @@
file : timeanalysis.h
created : Sun Jun 07 11:15:00 CET 2009
copyright : (C) 2009 by Wolf-Dieter Beelitz
email : wdb@wdbee.de
email : wdbee@users.sourceforge.net
version :
***************************************************************************/
@ -20,7 +20,7 @@
/** @file
This is a collection of useful functions for time analysis
@author <a href=mailto:wdb@wdbee.de>Wolf-Dieter Beelitz</a>
@author <a href=mailto:wdbee@users.sourceforge.net>Wolf-Dieter Beelitz</a>
@version
@ingroup robottools
*/

View file

@ -3,7 +3,7 @@
-------------------
created : Wed Nov 12 17:54:00:00 CEST 2014
copyright : (C) 2014 by Wolf-Dieter Beelitz
email : wdb at wdbee.de
email : wdbee@users.sourceforge.net
version : $Id:$
***************************************************************************/

View file

@ -3,7 +3,7 @@
-------------------
created : Wed Nov 12 17:54:00:00 CEST 2014
copyright : (C) 2014 by Wolf-Dieter Beelitz
email : wdb at wdbee.de
email : wdbee@users.sourceforge.net
version : $Id$
***************************************************************************/

View file

@ -247,18 +247,53 @@ TGF_API void GfPoolMove(tMemoryPool* oldPool, tMemoryPool* newPool);
//============================================================================*
// Definitions of the replacements for the new Memory Manager
//----------------------------------------------------------------------------*
#define malloc _tgf_win_malloc
#define calloc _tgf_win_calloc
#define realloc _tgf_win_realloc
#define free _tgf_win_free
#define accept _tgf_win_accept
#define doaccept GfMemoryManagerDoAccept
#define dofree GfMemoryManagerDoFree
#ifdef strdup
#undef strdup
#if defined(WIN32)
// Windows ...
#if defined(__MINGW32__)
// MinGW ...
#define malloc(x) _tgf_win_malloc((x))
#define calloc(x,y) _tgf_win_calloc((x),(y))
#define realloc(x,y) _tgf_win_realloc((x),(y))
#define free(x) _tgf_win_free((x))
#define doaccept() GfMemoryManagerDoAccept()
#define dofree() GfMemoryManagerDoFree()
#ifdef strdup
#undef strdup
#endif
#define strdup(x) _tgf_win_strdup((x))
#define _strdup(x) _tgf_win_strdup((x))
// ... MinGW
#else
// VC++ ...
#define malloc _tgf_win_malloc
#define calloc _tgf_win_calloc
#define realloc _tgf_win_realloc
#define free _tgf_win_free
#define doaccept() GfMemoryManagerDoAccept()
#define dofree() GfMemoryManagerDoFree()
#ifdef strdup
#undef strdup
#endif
#define strdup _tgf_win_strdup
#define _strdup _tgf_win_strdup
// ... VC++
#endif
// ... Windows
#else
// Linux ...
#define malloc(x) _tgf_win_malloc((x))
#define calloc(x,y) _tgf_win_calloc((x),(y))
#define realloc(x,y) _tgf_win_realloc((x),(y))
#define free(x) _tgf_win_free((x))
#define doaccept() GfMemoryManagerDoAccept()
#define dofree() GfMemoryManagerDoFree()
#ifdef strdup
#undef strdup
#endif
#define strdup(x) _tgf_win_strdup((x))
#define _strdup(x) _tgf_win_strdup((x))
// ... Linux
#endif
#define strdup _tgf_win_strdup
#define _strdup _tgf_win_strdup
//============================================================================*
//============================================================================*
@ -268,7 +303,6 @@ ExternC TGF_API void* _tgf_win_malloc(size_t size);
ExternC TGF_API void* _tgf_win_calloc(size_t num, size_t size);
ExternC TGF_API void* _tgf_win_realloc(void * memblock, size_t size);
ExternC TGF_API void _tgf_win_free(void * memblock);
ExternC TGF_API void _tgf_win_accept(void * memblock);
ExternC TGF_API char* _tgf_win_strdup(const char * str);
ExternC TGF_API void GfMemoryManagerDoAccept();
ExternC TGF_API void GfMemoryManagerDoFree();

View file

@ -3,7 +3,7 @@
file : genetic.cpp
created : Sun Nov 06 09:15:00 CET 2011
copyright : (C) 2011-2013 by Wolf-Dieter Beelitz
email : wdb@wdbee.de
email : wdbee@users.sourceforge.net
version : $Id: genetic.cpp 3657 2011-11-06 09:15:00Z wdbee $
***************************************************************************/
@ -18,7 +18,7 @@
/** @file
Helper for parameter handling while optimizations
@author <a href=mailto:wdb@wdbee.de>WDBee</a>
@author <a href=mailto:wdbee@users.sourceforge.net>WDBee</a>
@version $Id: genetic.cpp 3657 2011-11-06 09:15:00Z wdbee $
*/

View file

@ -3,7 +3,7 @@
file : genetic.h
created : Tue Nov 04 17:45:00 CET 2010
copyright : (C) 2010-2013 by Wolf-Dieter Beelitz
email : wdb@wdbee.de
email : wdbee@users.sourceforge.net
***************************************************************************/

View file

@ -116,6 +116,10 @@ ReHumanInGroup()
int ReConfigure()
{
// Set track 1 as starting track
void *params = ReInfo->params;
GfParmSetNum(params, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, (tdble)1);
ReUI().onRaceConfiguring();
return RM_ASYNC | RM_NEXT_STEP;