Example #1
0
void ClothoidPath::MakeSmoothPath( MyTrack*	pTrack,	const CarModel&	cm,	const Options& opts )
{
//	m_factor = factor;

	LinePath::Initialise( pTrack, opts.maxL, opts.maxR );

	const int	NSEG = pTrack->GetSize();

	CalcCurvaturesZ();
	int	fwdRange = 110;
	CalcFwdAbsK( fwdRange );

	const int delta = 25;
	const int n = (150 + delta - 1) / delta;

	int		step = 1;
	while( step * 4 < NSEG )
		step *= 2;

	do
	{
		step = (step + 1) / 2;
//		int n = 100 * int(sqrt(step));
		for( int i = 0; i < n; i++ )
		{
			OptimisePath( cm, step, delta, 0 );
		}
	}
	while( step > 1 );

	if( opts.bumpMod )
	{
		CalcCurvaturesZ();
		CalcFwdAbsK( fwdRange );
		AnalyseBumps( cm, false );

		step = 8;

		do
		{
			step = (step + 1) / 2;

			for( int i = 0; i < n; i++ )
			{
				OptimisePath( cm, step, delta, opts.bumpMod );
				CalcFwdAbsK( fwdRange );
				CalcMaxSpeeds( cm, step );
				PropagateBreaking( cm, step );
				PropagateAcceleration( cm, step );
			}
		}
		while( step > 1 );
	}

	CalcCurvaturesZ();
}
Example #2
0
void LinePath::Initialise( MyTrack* pTrack, double maxL, double maxR )
{
  const int NSEG = pTrack->GetSize();

  m_pTrack = pTrack;
  delete [] m_pPath;
  m_pPath = new PathPt[NSEG];

  m_maxL = maxL;
  m_maxR = maxR;

  for( int i = 0; i < NSEG; i++ )
  {
    m_pPath[i].pSeg = &(*pTrack)[i];
    m_pPath[i].k = 0;
    m_pPath[i].kz = 0;
    m_pPath[i].offs = m_pPath[i].pSeg->midOffs;
    m_pPath[i].pt = m_pPath[i].CalcPt();
    m_pPath[i].maxSpd = 10;
    m_pPath[i].spd = 10;
    m_pPath[i].accSpd = 10;
    m_pPath[i].h = 0;
    m_pPath[i].lBuf = 0;
    m_pPath[i].rBuf = 0;
  }

  CalcCurvaturesXY();
  CalcCurvaturesZ();
}
Example #3
0
//==========================================================================*
// Create a smooth lane
//--------------------------------------------------------------------------*
void TClothoidLane::MakeSmoothPath(
  TTrackDescription* Track,
  TParam& Param,
  const TOptions& Opts)
{
  TCarParam* CarParam = &Param.oCarParam;
  if (Opts.Side)
    CarParam = &Param.oCarParam2;

  TLane::Initialise(Track, Param.Fix, *CarParam, Opts.MaxL, Opts.MaxR);
  oCount = Track->Count();
  //const int Count = Track->Count();

  int FwdRange = 110;
  CalcFwdAbsCrv(FwdRange);

  const int Delta = 25;
  const int L = 8;

  int Step = 1;                                  // Initialize step width
  while (Step * 16 < oCount)                     // Find largest step width
    Step *= 2;

  while (Step > 0)
  {
 	for (int I = 0; I < L; I++)
	  OptimisePath(Step, Delta, 0);
    Step >>= 1;
  }
  
  if (Opts.BumpMod)
  {
	AnalyseBumps(false);

	Step = 1;
	Step <<= ANALYSE_STEPS;
	while (Step > 0)
	{
  	  for (int I = 0; I < L; I++)
	  {
		OptimisePath(Step, Delta, Opts.BumpMod);
	    CalcCurvaturesZ();
		CalcFwdAbsCrv(FwdRange);
		CalcMaxSpeeds(Step);
		PropagateBreaking(Step);
		PropagateAcceleration(Step);
	  }
      Step >>= 1;
	}
  }
Example #4
0
//==========================================================================*
// Create a smooth lane
//--------------------------------------------------------------------------*
void TClothoidLane::MakeSmoothPath(
  TTrackDescription* Track,
  TParam& Param,
  const TOptions& Opts)
{
  TCarParam& CarParam = Param.oCarParam;
  oBase = Opts.Base;
  oBaseFactor = Opts.BaseFactor;

  if (Opts.MaxR < FLT_MAX)
    LaneType = ltLeft;
  else if (Opts.MaxL < FLT_MAX)
    LaneType = ltRight;
  else
    LaneType = ltFree;

  if (Opts.Side)
  {
    LogSimplix.debug("Switch to CarParam2\n");
    CarParam = Param.oCarParam2;
  }
  TLane::Initialise(Track, Param.Fix, CarParam, Opts.MaxL, Opts.MaxR);
  const int Count = Track->Count();

  int FwdRange = 110;
  CalcFwdAbsCrv(FwdRange);

  const int Delta = 25;
  int L = 8;

  int Step = 1;                                  // Initialize step width
  while (Step * 16 < Count)                      // Find largest step width
    Step *= 2;

  LogSimplix.debug("OptimisePath:\n");
  while (Step > 0)
  {
	LogSimplix.debug("Step: %d\n",Step);
 	for (int I = 0; I < L; I++)
	{
		OptimisePath(Step, Delta, 0, Param.oCarParam.oUglyCrvZ);
	}
    Step >>= 1;
  }

  if (Opts.BumpMod)
  {
    LogSimplix.debug("AnalyseBumps:\n");
	AnalyseBumps(false);
	//AnalyseBumps(true);

	Step = 1;
	Step <<= ANALYSE_STEPS;

	while (Step > 0)
	{
	  LogSimplix.debug("Step: %d\n",Step);
  	  for (int I = 0; I < L; I++)
	  {
		OptimisePath(Step, Delta, Opts.BumpMod, Param.oCarParam.oUglyCrvZ);
		CalcCurvaturesZ();
		CalcFwdAbsCrv(FwdRange);
		CalcMaxSpeeds(Step);
		PropagateBreaking(Step);
		PropagateAcceleration(Step);
	  }
      Step >>= 1;
	}
  }
Example #5
0
void LinePath::CalcCurvaturesZ( int step )
{
  const int NSEG = m_pTrack->GetSize();
  CalcCurvaturesZ( 0, NSEG, step );
}
Example #6
0
//==========================================================================*
// Calculate curvature in Z
//--------------------------------------------------------------------------*
void TLane::CalcCurvaturesZ(int Step)
{
  CalcCurvaturesZ( 0, Step);
}
Example #7
0
//==========================================================================*
// Initialize lane from track limiting width to left and right
//--------------------------------------------------------------------------*
void TLane::Initialise
  (TTrackDescription* Track,
  const TFixCarParam& FixCarParam,
  const TCarParam& CarParam,
  double MaxLeft, double MaxRight)
{
  delete [] oPathPoints;
  oTrack = Track;
  oPathPoints = new TPathPt[Track->Count()];
  oCarParam = CarParam;                          // Copy car params
  oFixCarParam = FixCarParam;                    // Copy car params

  // To avoid uninitialized alignment bytes within the allocated memory for 
  // linux compilers not doing this initialization without our explizit 
  // request we should fill it with zeros. Otherwise we would get valgrind
  // warnings writing the data to file using only one memory block per
  // path point.
  memset(oPathPoints, 0, Track->Count() * sizeof(*oPathPoints));

  if (MaxLeft < 999.0)
  {
    for (int I = 0; I < Track->Count(); I++)
    {
	  const TSection& Sec = (*oTrack)[I];
	  oPathPoints[I].Sec = &Sec;
	  oPathPoints[I].Center = Sec.Center;
	  oPathPoints[I].Crv = 0;
	  oPathPoints[I].CrvZ	= 0;
	  oPathPoints[I].Offset = 0.0;
	  oPathPoints[I].Point = oPathPoints[I].CalcPt();
	  oPathPoints[I].MaxSpeed	= 10;
	  oPathPoints[I].Speed = 10;
	  oPathPoints[I].AccSpd = 10;
	  oPathPoints[I].FlyHeight = 0;
//	  oPathPoints[I].BufL	= 0;
//	  oPathPoints[I].BufR	= 0;
	  oPathPoints[I].NextCrv = 0.0;
	  oPathPoints[I].WToL = (float) MaxLeft;
  	  oPathPoints[I].WToR = (float) Sec.WidthToRight;
	  oPathPoints[I].WPitToL = (float) Sec.PitWidthToLeft;
      oPathPoints[I].WPitToR = (float) Sec.PitWidthToRight;
	  oPathPoints[I].Fix = false;
    }
    oPathPoints[0].WToL = oPathPoints[1].WToL;
	oPathPoints[0].WToR = oPathPoints[1].WToR;
  }
  else if (MaxRight < 999.0)
  {
    for (int I = 0; I < Track->Count(); I++)
    {
	  const TSection& Sec = (*oTrack)[I];
	  oPathPoints[I].Sec = &Sec;
	  oPathPoints[I].Center	= Sec.Center;
	  oPathPoints[I].Crv = 0;
	  oPathPoints[I].CrvZ = 0;
	  oPathPoints[I].Offset = 0.0;
	  oPathPoints[I].Point = oPathPoints[I].CalcPt();
	  oPathPoints[I].MaxSpeed = 10;
	  oPathPoints[I].Speed = 10;
	  oPathPoints[I].AccSpd	= 10;
	  oPathPoints[I].FlyHeight = 0;
//	  oPathPoints[I].BufL = 0;
//	  oPathPoints[I].BufR = 0;
	  oPathPoints[I].NextCrv = 0.0;
	  oPathPoints[I].WToL = (float) Sec.WidthToLeft;
	  oPathPoints[I].WToR = (float) MaxRight;
      oPathPoints[I].WPitToL = (float) Sec.PitWidthToLeft;
      oPathPoints[I].WPitToR = (float) Sec.PitWidthToRight;
	  oPathPoints[I].Fix = false;
    }
    oPathPoints[0].WToL = oPathPoints[1].WToL;
	oPathPoints[0].WToR = oPathPoints[1].WToR;
  }
  else
  {
    for (int I = 0; I < Track->Count(); I++)
    {
	  const TSection& Sec = (*oTrack)[I];
	  oPathPoints[I].Sec = &Sec;
	  oPathPoints[I].Center = Sec.Center;
	  oPathPoints[I].Crv = 0;
	  oPathPoints[I].CrvZ	= 0;
	  oPathPoints[I].Offset = 0.0;
	  oPathPoints[I].Point = oPathPoints[I].CalcPt();
	  oPathPoints[I].MaxSpeed	= 10;
	  oPathPoints[I].Speed = 10;
	  oPathPoints[I].AccSpd = 10;
	  oPathPoints[I].FlyHeight = 0;
//	  oPathPoints[I].BufL	= 0;
//	  oPathPoints[I].BufR	= 0;
	  oPathPoints[I].NextCrv = 0.0;
      oPathPoints[I].WToL = (float) Sec.WidthToLeft;
	  oPathPoints[I].WToR = (float) Sec.WidthToRight;
      oPathPoints[I].WPitToL = (float) Sec.PitWidthToLeft;
      oPathPoints[I].WPitToR = (float) Sec.PitWidthToRight;
	  oPathPoints[I].Fix = false;
    }
    oPathPoints[0].WToL = oPathPoints[1].WToL;
	oPathPoints[0].WToR = oPathPoints[1].WToR;

  }
  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);         
}