diff --git a/src/drivers/simplix/simplix_36GP/36gp-ettore-t59/default.xml b/src/drivers/simplix/simplix_36GP/36gp-ettore-t59/default.xml index d43d399e1..db80df024 100644 --- a/src/drivers/simplix/simplix_36GP/36gp-ettore-t59/default.xml +++ b/src/drivers/simplix/simplix_36GP/36gp-ettore-t59/default.xml @@ -26,7 +26,7 @@ - + diff --git a/src/drivers/simplix/simplix_36GP/36gp-milano-12c36/default.xml b/src/drivers/simplix/simplix_36GP/36gp-milano-12c36/default.xml index bd1f657dc..23addbc27 100644 --- a/src/drivers/simplix/simplix_36GP/36gp-milano-12c36/default.xml +++ b/src/drivers/simplix/simplix_36GP/36gp-milano-12c36/default.xml @@ -26,7 +26,7 @@ - + diff --git a/src/drivers/simplix/simplix_36GP/36gp-silber-w25b/default.xml b/src/drivers/simplix/simplix_36GP/36gp-silber-w25b/default.xml index 623b8c902..24852af8d 100644 --- a/src/drivers/simplix/simplix_36GP/36gp-silber-w25b/default.xml +++ b/src/drivers/simplix/simplix_36GP/36gp-silber-w25b/default.xml @@ -26,8 +26,8 @@ - - + + diff --git a/src/drivers/simplix/simplix_36GP/36gp-tridenti-6c34/default.xml b/src/drivers/simplix/simplix_36GP/36gp-tridenti-6c34/default.xml index 24c61aff9..46f8d80c0 100644 --- a/src/drivers/simplix/simplix_36GP/36gp-tridenti-6c34/default.xml +++ b/src/drivers/simplix/simplix_36GP/36gp-tridenti-6c34/default.xml @@ -26,7 +26,7 @@ - + diff --git a/src/drivers/simplix/simplix_36GP/36gp-tridenti-v8ri/default.xml b/src/drivers/simplix/simplix_36GP/36gp-tridenti-v8ri/default.xml index 7e8773df5..a59f61378 100644 --- a/src/drivers/simplix/simplix_36GP/36gp-tridenti-v8ri/default.xml +++ b/src/drivers/simplix/simplix_36GP/36gp-tridenti-v8ri/default.xml @@ -26,7 +26,7 @@ - + diff --git a/src/drivers/simplix/simplix_36GP/tracks/a-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/a-speedway.xml deleted file mode 100644 index fb4078b47..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/a-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/aalborg.xml b/src/drivers/simplix/simplix_36GP/tracks/aalborg.xml deleted file mode 100644 index edb722d18..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/aalborg.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/allondaz.xml b/src/drivers/simplix/simplix_36GP/tracks/allondaz.xml deleted file mode 100644 index ea436f71c..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/allondaz.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/alpine-1.xml b/src/drivers/simplix/simplix_36GP/tracks/alpine-1.xml deleted file mode 100644 index ea436f71c..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/alpine-1.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/alpine-2.xml b/src/drivers/simplix/simplix_36GP/tracks/alpine-2.xml deleted file mode 100644 index 9c5a247d6..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/alpine-2.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/b-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/b-speedway.xml deleted file mode 100644 index 18f1e7674..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/b-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/brondehach.xml b/src/drivers/simplix/simplix_36GP/tracks/brondehach.xml deleted file mode 100644 index 0f03398e7..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/brondehach.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/c-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/c-speedway.xml deleted file mode 100644 index a3977c770..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/c-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/charmey.xml b/src/drivers/simplix/simplix_36GP/tracks/charmey.xml deleted file mode 100644 index 475818dae..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/charmey.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/corkscrew.xml b/src/drivers/simplix/simplix_36GP/tracks/corkscrew.xml deleted file mode 100644 index 1d502c8dd..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/corkscrew.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/d-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/d-speedway.xml deleted file mode 100644 index 99f4debd0..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/d-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/e-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/e-speedway.xml deleted file mode 100644 index b5ec8d03f..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/e-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/e-track-1.xml b/src/drivers/simplix/simplix_36GP/tracks/e-track-1.xml deleted file mode 100644 index 37054e0b0..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/e-track-1.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/e-track-2.xml b/src/drivers/simplix/simplix_36GP/tracks/e-track-2.xml deleted file mode 100644 index ffd4bdc75..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/e-track-2.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/e-track-3.xml b/src/drivers/simplix/simplix_36GP/tracks/e-track-3.xml deleted file mode 100644 index 63c71d534..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/e-track-3.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/e-track-4.xml b/src/drivers/simplix/simplix_36GP/tracks/e-track-4.xml deleted file mode 100644 index 112f671c9..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/e-track-4.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/espie.xml b/src/drivers/simplix/simplix_36GP/tracks/espie.xml deleted file mode 100644 index 0f8c18326..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/espie.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/f-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/f-speedway.xml deleted file mode 100644 index de23c68f8..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/f-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/forza.xml b/src/drivers/simplix/simplix_36GP/tracks/forza.xml deleted file mode 100644 index 98268c588..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/forza.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/g-speedway.xml b/src/drivers/simplix/simplix_36GP/tracks/g-speedway.xml deleted file mode 100644 index edae35286..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/g-speedway.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/g-track-1.xml b/src/drivers/simplix/simplix_36GP/tracks/g-track-1.xml deleted file mode 100644 index 55c99035e..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/g-track-1.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/g-track-2.xml b/src/drivers/simplix/simplix_36GP/tracks/g-track-2.xml deleted file mode 100644 index 936411981..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/g-track-2.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/g-track-3.xml b/src/drivers/simplix/simplix_36GP/tracks/g-track-3.xml deleted file mode 100644 index 475818dae..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/g-track-3.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/manton.xml b/src/drivers/simplix/simplix_36GP/tracks/manton.xml deleted file mode 100644 index e448af80e..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/manton.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/michigan.xml b/src/drivers/simplix/simplix_36GP/tracks/michigan.xml deleted file mode 100644 index e448af80e..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/michigan.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/migrants.xml b/src/drivers/simplix/simplix_36GP/tracks/migrants.xml deleted file mode 100644 index a30795150..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/migrants.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/ole-road-1.xml b/src/drivers/simplix/simplix_36GP/tracks/ole-road-1.xml deleted file mode 100644 index 720a9727d..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/ole-road-1.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/prenzlau.xml b/src/drivers/simplix/simplix_36GP/tracks/prenzlau.xml deleted file mode 100644 index c75c4e1f9..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/prenzlau.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/ruudskogen.xml b/src/drivers/simplix/simplix_36GP/tracks/ruudskogen.xml deleted file mode 100644 index 8f0c8bc62..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/ruudskogen.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/spring.xml b/src/drivers/simplix/simplix_36GP/tracks/spring.xml deleted file mode 100644 index 6598766db..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/spring.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/street-1.xml b/src/drivers/simplix/simplix_36GP/tracks/street-1.xml deleted file mode 100644 index 5a9bcff53..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/street-1.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/wheel-1.xml b/src/drivers/simplix/simplix_36GP/tracks/wheel-1.xml deleted file mode 100644 index f921885f7..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/wheel-1.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/simplix_36GP/tracks/wheel-2.xml b/src/drivers/simplix/simplix_36GP/tracks/wheel-2.xml deleted file mode 100644 index 890a1d598..000000000 --- a/src/drivers/simplix/simplix_36GP/tracks/wheel-2.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/drivers/simplix/src/unitclothoid.cpp b/src/drivers/simplix/src/unitclothoid.cpp index 795659152..0f7c44022 100644 --- a/src/drivers/simplix/src/unitclothoid.cpp +++ b/src/drivers/simplix/src/unitclothoid.cpp @@ -9,10 +9,10 @@ // // File : unitclothoid.cpp // Created : 2007.11.25 -// Last changed : 2010.11.21 -// Copyright : © 2007-2010 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 3.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Teile diese Unit basieren auf diversen Header-Dateien von TORCS // diff --git a/src/drivers/simplix/src/unitcubicspline.cpp b/src/drivers/simplix/src/unitcubicspline.cpp index c3fc8a73d..eda43def5 100644 --- a/src/drivers/simplix/src/unitcubicspline.cpp +++ b/src/drivers/simplix/src/unitcubicspline.cpp @@ -45,6 +45,17 @@ #include "unitcubicspline.h" +//==========================================================================* +// Default constructor +//--------------------------------------------------------------------------* +TCubicSpline::TCubicSpline() +{ + oCount = 0; + oSegs = NULL; + oCubics = NULL; +} +//==========================================================================* + //==========================================================================* // Constructor //--------------------------------------------------------------------------* @@ -64,6 +75,28 @@ TCubicSpline::TCubicSpline } //==========================================================================* +//==========================================================================* +// Initialization +//--------------------------------------------------------------------------* +void TCubicSpline::Init + (int Count, const double* X, const double* Y, const double* S) +{ + delete [] oSegs; + delete [] oCubics; + + oCount = Count; + oSegs = new double[oCount]; + oCubics = new TCubic[oCount - 1]; + + for (int I = 0; I < oCount; I++) + { + oSegs[I] = X[I]; + if (I + 1 < oCount) + oCubics[I].Set( X[I], Y[I], S[I], X[I+1], Y[I+1], S[I+1]); + } +} +//==========================================================================* + //==========================================================================* // Destructor //--------------------------------------------------------------------------* diff --git a/src/drivers/simplix/src/unitcubicspline.h b/src/drivers/simplix/src/unitcubicspline.h index 850e2e15e..a51a7e18c 100644 --- a/src/drivers/simplix/src/unitcubicspline.h +++ b/src/drivers/simplix/src/unitcubicspline.h @@ -2,15 +2,17 @@ // unitcubicspline.h //--------------------------------------------------------------------------* // TORCS: "The Open Racing Car Simulator" -// Roboter für TORCS-Version 1.3.0 -// Zentrale Klasse für das Fahren bzw. den Fahrer/Roboter +// A robot for Speed Dreams-Version 1.4.0/2.X +//--------------------------------------------------------------------------* +// Cubic spline +// Kubischer Spline // -// Datei : unitcubicspline.h -// Erstellt : 25.11.2007 -// Stand : 24.11.2008 -// Copyright: © 2007-2008 Wolf-Dieter Beelitz -// eMail : wdb@wdbee.de -// Version : 1.01.000 +// File : unitcubicspline.h +// Created : 2007.11.25 +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz +// eMail : wdb@wdbee.de +// Version : 3.00.002 //--------------------------------------------------------------------------* // Ein erweiterter TORCS-Roboters //--------------------------------------------------------------------------* @@ -46,10 +48,15 @@ class TCubicSpline { public: + TCubicSpline(); // Default constructor TCubicSpline // Constructor - (int Count, const double* X, const double* Y, const double* S); + (int Count, const double* X, + const double* Y, const double* S); ~TCubicSpline(); + void Init(int Count, const double* X, + const double* Y, const double* S); + double CalcOffset(double X) const; // Get offset double CalcGradient(double X) const; // Get gradient diff --git a/src/drivers/simplix/src/unitdriver.cpp b/src/drivers/simplix/src/unitdriver.cpp index 269e2bfdd..58f572ddf 100644 --- a/src/drivers/simplix/src/unitdriver.cpp +++ b/src/drivers/simplix/src/unitdriver.cpp @@ -12,7 +12,7 @@ // Last changed : 2011.05.26 // Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 3.00.001 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Teile dieser Unit basieren auf diversen Header-Dateien von TORCS // @@ -806,7 +806,7 @@ void TDriver::AdjustPitting(PCarHandle Handle) oTestPitStop = (int) GfParmGetNum(Handle,TDriver::SECT_PRIV,PRV_PIT_TEST_STOP,0,0); - //GfOut("#TestPitStop %d\n",oTestPitStop); + GfOut("#TestPitStop %d\n",oTestPitStop); // ... Adjust pitting }; //==========================================================================* @@ -1387,6 +1387,13 @@ void TDriver::Drive() //else // GfOut("t:%.2f s v:(%.1f)%.1f km/h A:%.3f C:%.3f G:%d R:%.1f F:%.3f\n",CurrSimTime,oTargetSpeed*3.6,oCurrSpeed*3.6,oAccel,oClutch,oGear,1/oLanePoint.Crv,CalcCrv_simplix_36GP(fabs(oLanePoint.Crv))); //GfOut("v:(%.1f)%.1f km/h R:%.3f m c:%.3f 1/m\n",oTargetSpeed*3.6,oCurrSpeed*3.6,1/oLanePoint.Crv,oLanePoint.Crv); +/* + const int N = oTrackDesc.Count(); + int Idx = oTrackDesc.IndexFromPos(Pos); + double TrackTurnangle1 = oRacingLine[0].CalcTrackTurnangle((Idx + N - 30) % N, Idx); + double TrackTurnangle2 = oRacingLine[0].CalcTrackTurnangle(Idx, (Idx + 30) % N); + GfOut("v:(%.1f)%.1f km/h A1:%.3f A2:%.3f\n",oTargetSpeed*3.6,oCurrSpeed*3.6,TrackTurnangle1,TrackTurnangle2); +*/ } //==========================================================================* @@ -1620,7 +1627,7 @@ void TDriver::FindRacinglines() { // using car parameters //GfOut("# ... adjust pit path %d ...\n",I); oStrategy->oPit->oPitLane[I].MakePath - (oPitLoad[I],&oRacingLine[I], Param, I); + (oPitLoad[I],oStrategy,&oRacingLine[I], Param, I); if (MaxPitDist < oStrategy->oPit->oPitLane[I].PitDist()) MaxPitDist = oStrategy->oPit->oPitLane[I].PitDist(); @@ -1628,7 +1635,7 @@ void TDriver::FindRacinglines() //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->oDistToSwitch = MaxPitDist + 100; // Distance to pit entry + oStrategy->oDistToSwitch = MaxPitDist + 125; // Distance to pit entry } } @@ -1685,7 +1692,8 @@ void TDriver::InitCarModells() Param.Fix.oWidth = CarWidth; // width of car Param.oCarParam2 = Param.oCarParam; // Copy to avoid set Param.oCarParam2.oScaleMu = // Adjust mu scale to - MIN(0.95, 0.9 * Param.oCarParam.oScaleMu); // be able to avoid +// MIN(0.95, 0.9 * Param.oCarParam.oScaleMu); // be able to avoid + MIN(0.5, 0.9 * Param.oCarParam.oScaleMu); // be able to avoid Param.oCarParam3 = Param.oCarParam; // Copy to pit set } //==========================================================================* @@ -2383,13 +2391,21 @@ void TDriver::GearTronic() //--------------------------------------------------------------------------* void TDriver::GetLanePoint(int Path, double Pos, TLanePoint& LanePoint) { +/* + if (oStrategy->GoToPit()) + GfOut("*"); + else if (oStrategy->oPit->oPitLane[Path].ContainsPos(Pos)) + GfOut("#"); + else + GfOut("O"); +*/ if (oStrategy->oPit != NULL && oStrategy->oPit->HasPits() && !oStrategy->oWasInPit && oStrategy->GoToPit() && oStrategy->oPit->oPitLane[Path].ContainsPos(Pos)) { - //GfOut("#+"); + //GfOut("+"); oStrategy->oPit->oPitLane[Path].GetLanePoint(Pos, LanePoint); oLookScale = 0.05; oOmegaScale = 0.2; @@ -2402,7 +2418,7 @@ void TDriver::GetLanePoint(int Path, double Pos, TLanePoint& LanePoint) && oStrategy->oWasInPit && oStrategy->oPit->oPitLane[Path].ContainsPos(Pos)) { - //GfOut("#-"); + //GfOut("-"); oStrategy->oPit->oPitLane[Path].GetLanePoint(Pos, LanePoint); oLookScale = 0.02; oOmegaScale = 0.2; @@ -2412,7 +2428,7 @@ void TDriver::GetLanePoint(int Path, double Pos, TLanePoint& LanePoint) } else { - //GfOut("#*"); + //GfOut("="); oRacingLine[Path].GetLanePoint(Pos, LanePoint); oLookScale = oLookAheadFactor; oOmegaScale = oOmegaAheadFactor; @@ -3183,6 +3199,10 @@ void TDriver::AvoidOtherCars(double K, bool& IsClose, bool& IsLapper) Target = RunAround.AvoidTo // Which way we should take (Coll,oCar,*this,oDoAvoid); // depending on opponents + float ExitOffset = float + (oStrategy->oPit->oDistToPitEnd + + Param.Pit.oExitLength); + if (oStrategy->StartPitEntry(Ratio)) // If entrering pit { if (!oDoAvoid) // If no avoiding needed @@ -3191,7 +3211,7 @@ void TDriver::AvoidOtherCars(double K, bool& IsClose, bool& IsLapper) oDoAvoid = true; // side to make pit stop } } - else if (oStrategy->StopPitEntry(Param.Pit.oExitLength)) // back to track + else if (oStrategy->StopPitEntry(ExitOffset)) // back to track { if (!oDoAvoid) // If no avoiding needed { @@ -3244,8 +3264,8 @@ double TDriver::FilterStart(double Speed) } // For unknown tracks do not limit speed to much - if(!oStrategy->GoToPit() && (Speed < 12.0)) - Speed = 12.0; + if(!oStrategy->GoToPit() && (Speed < 10.0)) + Speed = 10.0; return Speed; } @@ -3730,7 +3750,7 @@ double TDriver::CalcCrv_simplix_SC(double Crv) return 1.0; } //==========================================================================* - +/* //==========================================================================* // simplix_36GP //--------------------------------------------------------------------------* @@ -3744,13 +3764,25 @@ double TDriver::CalcCrv_simplix_36GP(double Crv) return 1.0; else return ((1+Crv) * (400 + Offset)/(1/Crv + Offset)); -/* - { - double Value = ((1+Crv) * (400 + Offset)/(1/Crv + Offset)); - GfOut("%.5f\n",Value); - return MIN(1.25,Value); - } + } + else + return 1.0; +} +//==========================================================================* */ +//==========================================================================* +// simplix_36GP +//--------------------------------------------------------------------------* +double TDriver::CalcCrv_simplix_36GP(double Crv) +{ + double Offset = 1300; + + if (oCrvComp) + { + if (Crv < 0.0085) + return 1.0; + else + return MIN(1.5,MAX(1.0,((1+Crv) * (400 + Offset)/(1/Crv + Offset)))); } else return 1.0; diff --git a/src/drivers/simplix/src/unitdriver.h b/src/drivers/simplix/src/unitdriver.h index 4cf9167c6..e69b04607 100644 --- a/src/drivers/simplix/src/unitdriver.h +++ b/src/drivers/simplix/src/unitdriver.h @@ -9,10 +9,10 @@ // // File : unitdriver.h // Created : 2007.11.25 -// Last changed : 2011.03.06 -// Copyright : © 2007-2010 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 3.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Teile dieser Unit basieren auf diversen Header-Dateien von TORCS // diff --git a/src/drivers/simplix/src/unitfixcarparam.cpp b/src/drivers/simplix/src/unitfixcarparam.cpp index 200b9baa4..a3b187747 100644 --- a/src/drivers/simplix/src/unitfixcarparam.cpp +++ b/src/drivers/simplix/src/unitfixcarparam.cpp @@ -9,10 +9,10 @@ // // File : unitfixcarparam.cpp // Created : 2007.11.25 -// Last changed : 2011.02.12 -// Copyright : © 2007-2010 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 3.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Ein erweiterter TORCS-Roboters //--------------------------------------------------------------------------* @@ -252,7 +252,7 @@ double TFixCarParam::CalcBraking //==========================================================================* //==========================================================================* -// Calculate decceleration in pitlane +// Calculate deceleration in pitlane //--------------------------------------------------------------------------* double TFixCarParam::CalcBrakingPit (TCarParam& CarParam, // Lane specific parameters @@ -289,6 +289,9 @@ double TFixCarParam::CalcBrakingPit Crv *= oDriver->CalcCrv(fabs(Crv)); + if (Crvz > 0) + Crvz = 0; + double Gdown = G * cos(TrackRollAngle); double Glat = G * sin(TrackRollAngle); double Gtan = 0; @@ -320,8 +323,8 @@ double TFixCarParam::CalcBrakingPit double Acc = CarParam.oScaleBrakePit * Ftanroad / oTmpCarParam->oMass; - if (TDriver::UseGPBrakeLimit) - Acc = MAX(Acc,TDriver::BrakeLimit/2); +// if (TDriver::UseGPBrakeLimit) +// Acc = MAX(Acc,TDriver::BrakeLimit/2); double Inner = MAX(0, V * V - 2 * Acc * Dist); double OldU = U; @@ -397,9 +400,6 @@ double TFixCarParam::CalcMaxSpeed double Speed = factor * sqrt((Cos * G * Mu + Sin * G * SGN(Crv0)) / Den); -// if (fabs(AbsCrv) > 1/45.0) -// Speed *= 0.89; // Filter hairpins - if (fabs(AbsCrv) > 1/40.0) Speed *= 0.70; // Filter hairpins else if (fabs(AbsCrv) > 1/45.0) @@ -407,8 +407,19 @@ double TFixCarParam::CalcMaxSpeed else if (Speed > 112) // (111,11 m/s = 400 km/h) Speed = 112; - if (Speed < 11.0) - Speed = 11.0; + if (AbsCrv0 < 1/10.0) + { + if (TDriver::UseGPBrakeLimit) + { + if (Speed < 10.0) + Speed = 10.0; + } + else + { + if (Speed < 12.0) + Speed = 12.0; + } + } return Speed; } diff --git a/src/drivers/simplix/src/unitlane.cpp b/src/drivers/simplix/src/unitlane.cpp index 4e78cbd18..d1fce822a 100644 --- a/src/drivers/simplix/src/unitlane.cpp +++ b/src/drivers/simplix/src/unitlane.cpp @@ -9,10 +9,10 @@ // // File : unitlane.cpp // Created : 2007.11.25 -// Last changed : 2010.09.25 -// Copyright : © 2007-2009 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 2.00.001 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Ein erweiterter TORCS-Roboters //--------------------------------------------------------------------------* @@ -65,6 +65,7 @@ #include "unitglobal.h" #include "unitcommon.h" +#include "unitcubicspline.h" #include "unitdriver.h" #include "unitlane.h" #include "unitlinalg.h" @@ -114,6 +115,14 @@ void TLane::SetLane(const TLane& Lane) oPathPoints = new TPathPt[Count]; memcpy(oPathPoints, Lane.oPathPoints, Count * sizeof(*oPathPoints)); + + for (int I = 0; I < TA_N; I++) + { + TA_X[I] = Lane.TA_X[I]; + TA_Y[I] = Lane.TA_Y[I]; + TA_S[I] = Lane.TA_S[I]; + } + oTurnScale.Init(TA_N,TA_X,TA_Y,TA_S); } //==========================================================================* @@ -293,6 +302,44 @@ void TLane::Initialise } CalcCurvaturesXY(); CalcCurvaturesZ(); + + TA_X[0] = 0.0; + TA_X[1] = 0.4; + TA_X[2] = 0.5; + TA_X[3] = 0.6; + TA_X[4] = 0.7; + TA_X[5] = 0.8; + TA_X[6] = 0.9; + TA_X[7] = 1.0; + TA_X[8] = 1.1; + TA_X[9] = 10.0; +/* + TA_Y[0] = 1.0; + TA_Y[1] = 1.0; + TA_Y[2] = 0.995; + TA_Y[3] = 0.97; + TA_Y[4] = 0.9; + TA_Y[5] = 0.7; + TA_Y[6] = 0.5; + TA_Y[7] = 0.35; + TA_Y[8] = 0.305; + TA_Y[9] = 0.30; +*/ + TA_Y[0] = 1.0; + TA_Y[1] = 1.0; + TA_Y[2] = 1.0; + TA_Y[3] = 0.995; + TA_Y[4] = 0.97; + TA_Y[5] = 0.9; + TA_Y[6] = 0.7; + TA_Y[7] = 0.55; + TA_Y[8] = 0.505; + TA_Y[9] = 0.50; + + TA_S[0] = 0.0; + TA_S[9] = 0.0; + + oTurnScale.Init(TA_N,TA_X,TA_Y,TA_S); } //==========================================================================* @@ -390,9 +437,20 @@ void TLane::CalcMaxSpeeds oTrack->Friction(P)*Factor, TrackRollAngle); - double TrackTurnangle = CalcTrackTurnangle(P, (P + 50) % N); - if (TrackTurnangle > 0.7) - Speed *= 0.75; + if (TDriver::UseGPBrakeLimit) + { + + //double TrackTurnangle1 = CalcTrackTurnangle(P, (P + 30) % N); + //double TrackTurnangle2 = 0.7 * CalcTrackTurnangle((P + N - 30) % N, P); + //double TrackTurnangle = MAX(fabs(TrackTurnangle1),fabs(TrackTurnangle2)); + //Speed *= oTurnScale.CalcOffset(TrackTurnangle); + } + else + { + double TrackTurnangle = CalcTrackTurnangle(P, (P + 50) % N); + if (TrackTurnangle > 0.7) + Speed *= 0.75; + } if (Speed < 5) Speed = 5.0; @@ -481,8 +539,9 @@ void TLane::PropagatePitBreaking double TrackRollAngle = atan2(oPathPoints[P].Norm().z, 1); double TrackTiltAngle = 1.1 * atan2(Delta.z, Dist); - double Factor = 1.0 - MIN(1.0,fabs(oPathPoints[Q].Dist() - PitStopPos) / oFixCarParam.oPitBrakeDist); - double Friction = oTrack->Friction(P) * (Factor * ScaleMu + (1 - Factor) * oCarParam.oScaleBrakePit); +// double Factor = 1.0 - MIN(1.0,fabs(oPathPoints[Q].Dist() - PitStopPos) / oFixCarParam.oPitBrakeDist); +// double Friction = oTrack->Friction(P) * (Factor * ScaleMu + (1 - Factor) * oCarParam.oScaleBrakePit); + double Friction = oTrack->Friction(P); double U = oFixCarParam.CalcBraking( oCarParam, @@ -502,7 +561,7 @@ void TLane::PropagatePitBreaking //GfOut("I:%d P:%d Q:%d F:%g U:%g S:%g\n",I,P,Q,Factor,U,oPathPoints[P].Speed); if (oPathPoints[P].FlyHeight > 0.1) - oPathPoints[P].Speed = oPathPoints[Q].Speed; + oPathPoints[P].Speed = oPathPoints[Q].Speed; } } } diff --git a/src/drivers/simplix/src/unitlane.h b/src/drivers/simplix/src/unitlane.h index f57df2d74..92fa3860a 100644 --- a/src/drivers/simplix/src/unitlane.h +++ b/src/drivers/simplix/src/unitlane.h @@ -61,6 +61,7 @@ #include "unittrack.h" #include "unitcarparam.h" #include "unitfixcarparam.h" +#include "unitcubicspline.h" //==========================================================================* // Class TLane @@ -99,7 +100,12 @@ class TLane }; public: - TLane(); + static const int TA_N = 10; // Nbr of points + double TA_X[TA_N]; // X-coordinates + double TA_Y[TA_N]; // Y-coordinates + double TA_S[TA_N]; // Directions + + TLane(); virtual ~TLane(); virtual TLane& operator= (const TLane& Lane); @@ -153,11 +159,13 @@ class TLane double CalcTrackRollangle(double TrackPos); double CalcTrackTurnangle(int P, int Q); + protected: TTrackDescription* oTrack; // TORCS track data TPathPt* oPathPoints; // Points in this lane TFixCarParam oFixCarParam; // Copy of car params TCarParam oCarParam; // Copy of car params + TCubicSpline oTurnScale; // Scale of turns int Dummy; }; //==========================================================================* diff --git a/src/drivers/simplix/src/unitparam.h b/src/drivers/simplix/src/unitparam.h index e252c201e..02949d365 100644 --- a/src/drivers/simplix/src/unitparam.h +++ b/src/drivers/simplix/src/unitparam.h @@ -9,10 +9,10 @@ // // File : unitparam.h // Created : 2007.04.11 -// Last changed : 2009.07.12 -// Copyright : © 2007-2008 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 2.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // This program was developed and tested on windows XP // There are no known Bugs, but: diff --git a/src/drivers/simplix/src/unitpit.cpp b/src/drivers/simplix/src/unitpit.cpp index b0fc69ccc..a081f0a25 100644 --- a/src/drivers/simplix/src/unitpit.cpp +++ b/src/drivers/simplix/src/unitpit.cpp @@ -9,10 +9,10 @@ // // File : unitpit.cpp // Created : 2007.02.20 -// Last changed : 2010.10.16 -// Copyright : © 2007-2010 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 3.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Diese Unit basiert auf dem erweiterten Robot-Tutorial bt // @@ -236,11 +236,10 @@ void TPitLane::Init(PtCarElt Car) // Smooth Path with pitlane //--------------------------------------------------------------------------* void TPitLane::SmoothPitPath - (/*const TParam& Param*/) + (const TParam& Param) { int I; // Loop counter - //GfOut("\n\n\nMagic smoother is working!\n\n\n"); int NSEG = oTrack->Count(); // Number of sections in the path int Idx0 = oTrack->IndexFromPos(oPitEntryPos); // First index and int Idx1 = oTrack->IndexFromPos(oPitExitPos); // last index to modify @@ -253,10 +252,8 @@ void TPitLane::SmoothPitPath } // Smooth pit path - //GfOut("SmoothPath ...\n"); - SmoothPath(/*oTrack, Param,*/ TClothoidLane::TOptions(0.43f)); - //GfOut("... SmoothPath\n"); - + float BumpMode = (float) Param.oCarParam.oScaleBump; + SmoothPath(TClothoidLane::TOptions(BumpMode)); } //==========================================================================* @@ -264,9 +261,12 @@ void TPitLane::SmoothPitPath // Make Path with pitlane //--------------------------------------------------------------------------* void TPitLane::MakePath - (char* Filename, TClothoidLane* BasePath, + (char* Filename, + TAbstractStrategy* Strategy, + TClothoidLane* BasePath, const TParam& Param, int Index) { + // 1. Check whether we got a place to build our pit const tTrackOwnPit* Pit = CarPit; // Get my pit if (Pit == NULL) // If pit is NULL { // nothing to do @@ -274,44 +274,51 @@ void TPitLane::MakePath return; } - // We have a pit, let us build all we need to use it ... + // 2. We have a place, let us build all we need to use it ... + const int NPOINTS = 7; // Nbr of points defined for pitlane + double X[NPOINTS]; // X-coordinates + double Y[NPOINTS]; // Y-coordinates + double S[NPOINTS]; // Directions + + bool FirstPit = false; // Reset flag int I; // Loop counter TCarParam CarParam = Param.oCarParam3; // Copy parameters TLane::SetLane(*BasePath); // Copy Pathpoints const tTrackPitInfo* PitInfo = // Get pit infos &oTrack->Track()->pits; - bool FirstPit = false; // Reset flag - const int NPOINTS = 7; // Nbr of points defined for pitlane - double X[NPOINTS]; // X-coordinates - double Y[NPOINTS]; // Y-coordinates - double S[NPOINTS]; // Directions - + // At which side of the track is the place to build the pit? int Sign = // Get the side of pits (PitInfo->side == TR_LFT) ? -1 : 1; + // To be able to avoid in the pitlane we need he offsets float F[3] = {0.5, 1.0, 0.0}; // Avoid offsets if (Sign < 0) // If pits are on the { // left side F[1] = 0.0; // swap F[2] = 1.0; } + + // Different cars need different distances oStoppingDist = Param.Pit.oStoppingDist; // Distance to brake oPitStopOffset = Param.Pit.oLongOffset; // Offset for fine tuning + oCarParam.oScaleBrake = // Limit brake to be used + MIN(0.10f,CarParam.oScaleBrake); // in pitlane + oCarParam.oScaleMu = // Scale friction estimation + MIN(0.10f,CarParam.oScaleMu); // of pitlane + + // Get the distance of pit to middle of the track double PitLaneOffset = // Offset of the pitlane fabs(PitInfo->driversPits->pos.toMiddle) // from the middle of the - PitInfo->width; // track - oCarParam.oScaleBrake = // Limit brake to be used - MIN(0.60f,CarParam.oScaleBrake); // in pitlane - oCarParam.oScaleMu = // Scale friction estimation - MIN(1.00f,CarParam.oScaleMu); // of pitlane - + // To get same steering angles the distance to start to steer to the pit + // depends on the side of the driven lane in the pitlane (from avoiding) float Ratio = (float) (0.5 * PitInfo->len / (fabs(PitInfo->driversPits->pos.toMiddle) - PitLaneOffset)); - // Compute pit spline points along the track defined by TORCS - X[0] = PitInfo->pitEntry->lgfromstart // Start of Pitlane defined by TORCS + // Compute pit spline points along the track defined by TORCS/SD + X[0] = PitInfo->pitEntry->lgfromstart // Start of Pitlane defined + Param.Pit.oEntryLong; // our own offset along the track X[1] = PitInfo->pitStart->lgfromstart; // Start of speedlimit X[3] = Pit->pos.seg->lgfromstart // Center of our own pit @@ -321,42 +328,60 @@ void TPitLane::MakePath X[4] = X[3] + PitInfo->len // Leave own pit here + F[Index] * Ratio * Param.Pit.oLaneExitOffset; X[5] = X[1] + PitInfo->nPitSeg * PitInfo->len; // End of speed limit - X[6] = PitInfo->pitExit->lgfromstart // End of pitlane defind by TORCS - + PitInfo->pitExit->length // and own offset alog track + X[6] = PitInfo->pitExit->lgfromstart // End of pitlane defind + + PitInfo->pitExit->length // and own offset along track + Param.Pit.oExitLong; - oPitEntryPos = X[0]; // Save this values for later - oPitStartPos = X[1]; // use - oPitEndPos = X[5]; - oPitExitPos = X[6]; - //GfOut("oPitEntryPos: %g\n",oPitEntryPos); - //GfOut("oPitStartPos: %g\n",oPitStartPos); - //GfOut("oPitEndPos: %g\n",oPitEndPos); - //GfOut("oPitExitPos: %g\n",oPitExitPos); + oPitEntryPos = X[0]; // Save this value as start of spline - // Normalizing spline segments to >= 0.0 - for (I = 0; I < NPOINTS; I++) + // Normalizing spline segments to X[I+1] >= X[I] if startline is crossed + for (I = 1; I < NPOINTS; I++) { X[I] = ToSplinePos(X[I]); S[I] = 0.0; } - // Now the dark side of TORCS ... + // Now the dark side of TORCS and SD ... - // Fix point for first pit if necessary. + // Fix start of pitlane point for first pit if necessary. if (X[2] < X[1]) { FirstPit = true; // Hey we use the first pit! - X[1] = X[2]; + X[1] = X[2] - 1.0; // Congratulation } + // Fix end of pitlane point for last pit if necessary. + if (X[5] < X[4]) // May be this is not your race + X[5] = X[4] + 1.0; + // Fix broken pit exit. if (X[6] < X[5]) X[6] = X[5] + 50.0; - // Fix point for last pit if necessary. - if (X[5] < X[4]) - X[5] = X[4]; + // Recalculate spline segments to X[I+1] >= X[I] if startline is crossed + for (I = 1; I < NPOINTS; I++) + { + X[I] = ToSplinePos(X[I]); + S[I] = 0.0; + } + + oPitEntryPos = X[0]; // Save this values for later + oPitStartPos = X[1]; // use + oPitEndPos = X[5]; + oPitExitPos = X[6]; + + // For tuning the exit we need to know the distance + // from pit to end of pitlane + Strategy->oPit->oDistToPitEnd = + oPitEndPos - X[3]; + + // Get track positions from the spline station + if (oPitStartPos > oTrack->Length()) // Use normalized position + oPitStartPos -= oTrack->Length(); + if (oPitEndPos > oTrack->Length()) // Use normalized position + oPitEndPos -= oTrack->Length(); + if (oPitExitPos > oTrack->Length()) // Use normalized position + oPitExitPos -= oTrack->Length(); // Splice entry/exit of pit path into the base path provided. TLanePoint Point; // Data of the point @@ -365,11 +390,7 @@ void TPitLane::MakePath S[0] = -tan(Point.Angle // Direction of our - oTrack->ForwardAngle(oPitEntryPos)); // basic racingline - if (oPitExitPos < oTrack->Length()) // Use normalized position - BasePath->GetLanePoint(oPitExitPos, Point); // to get the data - else - BasePath->GetLanePoint(oPitExitPos-oTrack->Length(), Point); - + BasePath->GetLanePoint(oPitExitPos, Point); // As defined by TORCS Y[6] = Point.Offset; // Lateral distance and S[6] = -tan(Point.Angle // and direction at the - oTrack->ForwardAngle(oPitExitPos)); // TORCS end of pitlane @@ -378,132 +399,106 @@ void TPitLane::MakePath if (Param.Pit.oUseFirstPit && FirstPit) // If allowed and possible { // we will use a special path to Y[3] = Y[2] = Y[1] = Sign * // the first pit with - (fabs(PitInfo->driversPits->pos.toMiddle) // TORCS defined offset - + Param.Pit.oLatOffset); // and our own lateral offset + (fabs(PitInfo->driversPits->pos.toMiddle // TORCS defined offset + - 0.5 + Param.Pit.oLatOffset)); // and our own lateral offset } else // All other pits { // have to be reached over - Y[3] = Y[2] = Y[1] = Sign * // a path defined here +// Y[3] = Y[2] = Y[1] = Sign * // a path defined here + Y[2] = Y[1] = Sign * // a path defined here (PitLaneOffset - // Sign gives the side of the pits Param.Pit.oLaneEntryOffset * F[Index]); // and we correct the TORCS offset + + Y[3] = Sign * // we have to set the pit + (fabs(PitInfo->driversPits->pos.toMiddle) // offset + + Param.Pit.oLatOffset); // } Y[5] = Y[4] = Sign * // Leaving the own pit, we will (PitLaneOffset // go to the pitlane and use - Param.Pit.oLaneExitOffset * F[Index]); // an additional offset - TCubicSpline PreSpline(NPOINTS, X, Y, S); // Calculate the splines + // Calculate the splines for entry and exit of pitlane + TCubicSpline PreSpline(NPOINTS, X, Y, S); // Modify points in line path for pits ... int NSEG = oTrack->Count(); // Number of sections in the path // Start at section with speedlimit int Idx0 = oTrack->IndexFromPos(oPitStartPos); // Index to first point - // Section with offset of 5 m, keep it's position - Idx0 = (Idx0 + 5) % NSEG; // Index to first point + 5 m int Idx1 = oTrack->IndexFromPos(oPitEndPos); // Index to last point for (I = Idx0; I != Idx1; I = (I + 1) % NSEG) // Set Flag, to keep the points - oPathPoints[I].Fix = true; + oPathPoints[I].Fix = true; // while smooting - // Pit entry and pit exit as defined by TORCS + // Pit entry and pit exit as defined by TORCS/SD Idx0 = (1 + oTrack->IndexFromPos(oPitEntryPos)) % NSEG; - Idx1 = oTrack->IndexFromPos(oPitExitPos) % NSEG; + Idx1 = oTrack->IndexFromPos(oPitExitPos); - // Change offsets to go to the pitlane + // Change offsets to go to the pitlane based on the splines for (I = Idx0; I != Idx1; I = (I + 1) % NSEG) { - double Station = // Station in spline coordinates + double SplineY; // Offset lateral to track + double SplineX = // Station in spline coordinates ToSplinePos(oTrack->Section(I).DistFromStart); - oPathPoints[I].Offset = // Offset lateral to track - PreSpline.CalcOffset(Station); + + // Restrict to length of spline + if (SplineX > X[6]) + SplineX = X[6]; + + // Calculate offset to side depending on pit side + if (Sign < 0) + SplineY = MAX(PreSpline.CalcOffset(SplineX),-(oPathPoints[I].WPitToL - 1.3)); + else + SplineY = MIN(PreSpline.CalcOffset(SplineX),oPathPoints[I].WPitToR - 1.3); + + oPathPoints[I].Offset = SplineY; // Offset lateral to track oPathPoints[I].Point = // Recalculate point coordinates oPathPoints[I].CalcPt(); // from offset + //GfOut("Spline: %g/%g\n",SplineX,oPathPoints[I].Offset); } - int IdxStart; - int IdxEnd; - - if (Param.Pit.oUseSmoothPit > 0) // Smooth path at pit entry - { - if (FirstPit) - { - int Len = strlen(Filename); - Filename[Len - 2] = '1'; - } - else - { - int Len = strlen(Filename); - Filename[Len - 2] = 'p'; - } - if (!LoadPointsFromFile(Filename)) - { - GfOut("SmoothPitPath ...\n"); - SmoothPitPath(/*Param*/); // and pit exit - SavePointsToFile(Filename); - GfOut("... SmoothPitPath\n"); - } - - // Find section with nearly same path at start (offset differences small) - Idx0 = oTrack->IndexFromPos(oPitEntryPos); - double Delta; - int count = 4; - do - { - Idx0 = (Idx0 + NSEG - 1) % NSEG; - Delta = Dist(oPathPoints[Idx0].Point,BasePath->PathPoints(Idx0).Point); - if (Delta < 0.01) - count--; - } - while ((Delta > 0.01) || (count > 0)); - IdxStart = Idx0; - - // Find section with nearly same path at end (offset differences small) - Idx1 = oTrack->IndexFromPos(oPitExitPos); - count = 4; - do - { - Idx1 = (Idx1 + 1) % NSEG; - Delta = Dist(oPathPoints[Idx1].Point,BasePath->PathPoints(Idx1).Point); - if (Delta < 0.01) - count--; - } - while ((Delta > 0.01) || (count > 0)); - IdxEnd = Idx0; - } - - // Save the positions of the new pit entry and pit exit - oPitEntryPos = oPathPoints[Idx0].Dist(); - oPitExitPos = oPathPoints[Idx1].Dist(); - for (I = 0; I < NPOINTS; I++) - X[I] = ToSplinePos(X[I]); +/* + // What we have now is the path for a pass through penalty! + // TODO: Save it for use in pro mode // Now we use the complete pitlane with the pit itself - if (!Param.Pit.oUseFirstPit || !FirstPit) // If needed - { // have to be reached over - Y[3] = Sign * // To compensate steering we use - (fabs(PitInfo->driversPits->pos.toMiddle) // as target a point beeing a little - + Param.Pit.oLatOffset + 0.5); // in the pit + if (!Param.Pit.oUseFirstPit || !FirstPit) // If needed, means if we + { // do not use the first pit + Y[3] = Sign * // we have to set the pit + (fabs(PitInfo->driversPits->pos.toMiddle) // offset + + Param.Pit.oLatOffset); // + + GfOut("\n"); + GfOut("Spline points :\n"); + GfOut("oPitEntryPos : %g/%g\n",X[0],Y[0]); + GfOut("oPitStartPos : %g/%g\n",X[1],Y[1]); + GfOut("oPitStartSteer: %g/%g\n",X[2],Y[2]); + GfOut("oPitPos : %g/%g\n",X[3],Y[3]); + GfOut("oPitStopSteer : %g/%g\n",X[4],Y[4]); + GfOut("oPitEndPos : %g/%g\n",X[5],Y[5]); + GfOut("oPitExitPos : %g/%g\n",X[6],Y[6]); + + // Calculate the splines to the pit and out of it + TCubicSpline Spline(NPOINTS, X, Y, S); + + // Section with speedlimit, keep it + Idx0 = oTrack->IndexFromPos(oPitStartPos); // Index to first point + Idx1 = oTrack->IndexFromPos(oPitEndPos); // Index to last point + + // Change offsets to go to the pit + for (I = Idx0; I != Idx1; I = (I + 1) % NSEG) + { + double SplineX = // Station in spline coordinates + ToSplinePos(oTrack->Section(I).DistFromStart); + oPathPoints[I].Offset = // Offset lateral to track + Spline.CalcOffset(SplineX); + oPathPoints[I].Point = // Recalculate point coordinates + oPathPoints[I].CalcPt(); // from offset + oPathPoints[I].Fix = true; + //GfOut("Spline: %g/%g\n",SplineX,oPathPoints[I].Offset); + } } - - TCubicSpline Spline(NPOINTS, X, Y, S); // Calculate the splines - - // Section with speedlimit, keep it - Idx0 = oTrack->IndexFromPos(oPitStartPos); // Index to first point - Idx0 = (Idx0 + 5) % NSEG; // Index to first point + 5 m - Idx1 = oTrack->IndexFromPos(oPitEndPos); // Index to last point - - // Change offsets to go to the pitlane - for (I = Idx0; I != Idx1; I = (I + 1) % NSEG) - { - double Station = // Station in spline coordinates - ToSplinePos(oTrack->Section(I).DistFromStart); - oPathPoints[I].Offset = // Offset lateral to track - Spline.CalcOffset(Station); - oPathPoints[I].Point = // Recalculate point coordinates - oPathPoints[I].CalcPt(); // from offset - oPathPoints[I].Fix = true; - } - +*/ // Prepare speed calculation with changed path int FwdRange = 110; CalcFwdAbsCrv(FwdRange); @@ -512,7 +507,6 @@ void TPitLane::MakePath CalcMaxSpeeds(1); // Overwrite speed calculations at section with speed limit - //Idx0 = (oTrack->IndexFromPos(oPitStartPos) + NSEG - 1) % NSEG; Idx0 = (oTrack->IndexFromPos(oPitStartPos) + NSEG - 5) % NSEG; Idx1 = (oTrack->IndexFromPos(oPitEndPos) + 1) % NSEG; @@ -524,112 +518,40 @@ void TPitLane::MakePath } // Save stop position - double StopPos = Pit->pos.seg->lgfromstart // As defined by TROCS - + Pit->pos.toStart + oPitStopOffset; // with own offset along track - if (StopPos >= oTrack->Length()) // Normalize it to be >= 0.0 + double StopPos = Pit->pos.seg->lgfromstart // As defined by TROCS/SD + + Pit->pos.toStart + oPitStopOffset; // with own offset along track# + + // Normalize it to be 0 >= StopPos > track length + if (StopPos >= oTrack->Length()) StopPos -= oTrack->Length(); else if (StopPos < 0) StopPos += oTrack->Length(); - // Sections at pit stop - Idx0 = oTrack->IndexFromPos(StopPos); - oStopIdx = Idx0; - oStopPos = StopPos; - oPitStopPos = oPathPoints[Idx0].Dist(); + // Section at pit stop + oStopIdx = Idx0 = oTrack->IndexFromPos(StopPos); - //Distance of pit entry to pit stop point + // Set speed to restart faster + for (I = 0; I < 15; I++) + { + Idx0 = (Idx0 + 1) % NSEG; + oPathPoints[Idx0].MaxSpeed = + oPathPoints[Idx0].Speed = + PitInfo->speedLimit - 0.5; + } + + oStopPos = StopPos; + oPitStopPos = oPathPoints[oStopIdx].Dist(); + + // Set target speed at stop position + oPathPoints[oStopIdx].MaxSpeed = oPathPoints[oStopIdx].Speed = 1.0; + + // Distance of pit entry to pit stop point oPitDist = oPitStopPos - oPitEntryPos; if (oPitDist < 0) oPitDist += oTrack->Length(); - float Factor = 1.00; -/* - // Set speed to allow to stop - float Speed = 4.0; - if (TDriver::UseGPBrakeLimit) - { - Factor = 3.00; - Speed = 11.0; - if (FirstPit) - { - Factor = 1.00; - Speed = 4.0; - } - } - - oPathPoints[Idx0].MaxSpeed = oPathPoints[Idx0].Speed = Speed; - Idx1 = (Idx0 + NSEG - 1) % NSEG; - - if (!TDriver::UseGPBrakeLimit) - { -// int N = 6; - int N = 15; - float Delta = 0.75; - - for (I = 0; I < N; I++) - { - Speed += Delta; - oPathPoints[Idx1].MaxSpeed = oPathPoints[Idx1].Speed = Speed; - Idx1 = (Idx1 + NSEG - 1) % NSEG; - } - } - - // Set speed to restart - for (I = 0; I < 15; I++) - { - Idx0 = (Idx0 + 1) % NSEG; - oPathPoints[Idx0].MaxSpeed = oPathPoints[Idx0].Speed = PitInfo->speedLimit - 0.5; - } -*/ // Calculate braking - PropagatePitBreaking((tdble) oPitStopPos,(tdble)(Factor * Param.oCarParam.oScaleMu)); -/* - if (Param.Pit.oUseSmoothPit > 0) - { - // Overwrite speed calculations before speed limit - if (FirstPit) - { -// Idx1 = (oTrack->IndexFromPos(oPitStartPos) - 20); - Idx1 = (oTrack->IndexFromPos(oPitStartPos) - 30); - if (Idx1 < 0) - Idx1 += NSEG; - Idx1 = Idx1 % NSEG; - } - else - { -// Idx1 = (oTrack->IndexFromPos(oPitStartPos) - 5); - Idx1 = (oTrack->IndexFromPos(oPitStartPos) - 10); - if (Idx1 < 0) - Idx1 += NSEG; - Idx1 = Idx1 % NSEG; - } - - // Set min speed before pit lane - for (I = IdxStart; I != Idx1; I = (I + 1) % NSEG) - { - double Speed = MAX(oPathPoints[I].Speed,Param.Fix.oPitMinEntrySpeed); - oPathPoints[I].MaxSpeed = oPathPoints[I].Speed = Speed; - } - - // Overwrite speed calculations in pitlane after pit - Idx0 = (oTrack->IndexFromPos(oPitEndPos) + 1) % NSEG; - for (I = oStopIdx + 5; I != Idx0; I = (I + 1) % NSEG) - { - double Speed = MIN(oPathPoints[I].Speed, PitInfo->speedLimit - 0.5); - //if (oPathPoints[I].Crv < 0.001) - oPathPoints[I].MaxSpeed = oPathPoints[I].Speed = Speed; - } - - // Overwrite speed calculations after speed limit - Idx0 = (oTrack->IndexFromPos(oPitEndPos) + 1) % NSEG; - // Set min speed after pit lane - for (I = Idx0; I != IdxEnd; I = (I + 1) % NSEG) - { - double Speed = MAX(Param.Fix.oPitMinExitSpeed,oPathPoints[I].Speed); - oPathPoints[I].MaxSpeed = oPathPoints[I].Speed = Speed; - } - } -*/ + PropagatePitBreaking((tdble) oPitStopPos,(tdble) Param.oCarParam.oScaleMu); } //==========================================================================* diff --git a/src/drivers/simplix/src/unitpit.h b/src/drivers/simplix/src/unitpit.h index 880a9ab39..2051f9b1a 100644 --- a/src/drivers/simplix/src/unitpit.h +++ b/src/drivers/simplix/src/unitpit.h @@ -9,10 +9,10 @@ // // File : unitpit.h // Created : 2007.02.20 -// Last changed : 2009.02.01 -// Copyright : © 2007-2009 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 2.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Diese Unit basiert auf dem erweiterten Robot-Tutorial bt // @@ -53,6 +53,7 @@ #include "unittrack.h" #include "unitclothoid.h" #include "unitparam.h" +#include "unitstrategy.h" //==========================================================================* // Klasse TPitLane @@ -81,11 +82,12 @@ class TPitLane : public TClothoidLane void Init(PtCarElt Car); // Initialize oCar void MakePath // Build pitlane (char* Filename, + TAbstractStrategy* Strategy, TClothoidLane* BasePath, const TParam& Param, int Index); void SmoothPitPath - (/*const TParam& Param*/); + (const TParam& Param); bool InPitSection(double TrackPos) const; bool CanStop(double TrackPos) const; @@ -114,6 +116,7 @@ class TPit bool oInPitLane; // We are still in the pitlane. float oPitEntry; // Distance to start line of the pit entry. float oPitExit; // Distance to the start line of the pit exit. + double oDistToPitEnd; // Remaining len of pitlane float oSpeedLimitSqr; // Pit speed limit squared. float oSpeedLimit; // Pit speed limit. diff --git a/src/drivers/simplix/src/unitstrategy.cpp b/src/drivers/simplix/src/unitstrategy.cpp index 0e89feba2..d99677e25 100644 --- a/src/drivers/simplix/src/unitstrategy.cpp +++ b/src/drivers/simplix/src/unitstrategy.cpp @@ -9,10 +9,10 @@ // // File : unitstrategy.cpp // Created : 2007.02.20 -// Last changed : 2010.11.06 -// Copyright : © 2007-2009 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 3.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Teile diese Unit basieren auf dem erweiterten Robot-Tutorial bt // @@ -400,7 +400,8 @@ double TSimpleStrategy::SetFuelAtRaceStart //--------------------------------------------------------------------------* bool TSimpleStrategy::GoToPit() { - return ((oState >= PIT_ENTER) && (oState <= PIT_GONE)); +//return ((oState >= PIT_ENTER) && (oState <= PIT_GONE)); + return ((oState >= PIT_PREPARE) && (oState <= PIT_GONE)); }; //==========================================================================* @@ -411,9 +412,10 @@ bool TSimpleStrategy::StartPitEntry(float& Ratio) { float DLong, DLat; // Dist to Pit RtDistToPit(oCar,oTrack,&DLong,&DLat); - if (GoToPit() && (DLong < oPit->oPitLane->PitDist())) +// if (GoToPit() && (DLong < oPit->oPitLane->PitDist())) + if (GoToPit() && (DLong < oDistToSwitch)) { - Ratio = (float) (1.0 - MAX(0.0,(DLong-100)/oPit->oPitLane->PitDist())); + Ratio = (float) (1.0 - MAX(0.0,(DLong-100)/oDistToSwitch)); return true; } else @@ -521,6 +523,15 @@ void TSimpleStrategy::CheckPitState(float PitScaleBrake) case PIT_BEFORE: // We are somewhere on the track and got the flag to go to pit + if (oFuelChecked && oGoToPit) + { // If we reache pit entry and flag is still set + // switch to the pitlane + oState = PIT_PREPARE; + } + break; + + case PIT_PREPARE: + // We are near the pit entry on the track and got the flag to go to pit if (oPit->oPitLane[0].InPitSection(TrackPos) && oGoToPit) { // If we reache pit entry and flag is still set // switch to the pitlane @@ -529,7 +540,7 @@ void TSimpleStrategy::CheckPitState(float PitScaleBrake) break; case PIT_ENTER: - // We are on the pitlane and drive to out pit + // We are on the pitlane and drive to our pit if (!oPit->oPitLane[0].CanStop(TrackPos)) { // We have to wait, till we reached the point to stop if (oDriver->CurrSpeed() < 3) diff --git a/src/drivers/simplix/src/unitstrategy.h b/src/drivers/simplix/src/unitstrategy.h index 34bb477d5..b1914af00 100644 --- a/src/drivers/simplix/src/unitstrategy.h +++ b/src/drivers/simplix/src/unitstrategy.h @@ -9,10 +9,10 @@ // // File : unitstrategy.h // Created : 2007.02.20 -// Last changed : 2009.07.25 -// Copyright : © 2007-2009 Wolf-Dieter Beelitz +// Last changed : 2011.05.26 +// Copyright : © 2007-2011 Wolf-Dieter Beelitz // eMail : wdb@wdbee.de -// Version : 2.00.000 +// Version : 3.00.002 //--------------------------------------------------------------------------* // Teile diese Unit basieren auf dem erweiterten Robot-Tutorial bt // @@ -85,6 +85,7 @@ class TAbstractStrategy { PIT_NONE, PIT_BEFORE, + PIT_PREPARE, PIT_ENTER, PIT_ASKED, PIT_SERVICE,