示例#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();
}
示例#2
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;
	}
  }
示例#3
0
void ClothoidPath::AnalyseBumps( const CarModel& cm, bool dumpInfo )
{
	// here we look at the bumps on the track, and increase the buffers
	//	from the edge after the bumps.

	// get an estimate of speeds.
	CalcMaxSpeeds( cm );
	PropagateBreaking( cm );
	PropagateAcceleration( cm );

	const int		NSEG = m_pTrack->GetSize();
	const double	g = -9.81;

	double	sz = m_pPath[0].pt.z;
	double	vz = 0;
	double	pz = sz;
    //double	dt = 0.1;
    for( int count = 0; count < 2; count++ )
	{
		int		pi = NSEG - 1;

		for( int i = 0; i < NSEG; i++ )
		{
            //double	oldSz = sz;
			double	oldPz = pz;

			double	v = (m_pPath[i].accSpd + m_pPath[pi].accSpd) * 0.5;
			double	s = Utils::VecLenXY(m_pPath[i].pt - m_pPath[pi].pt);
			double	dt = s / v;

			pz = m_pPath[i].pt.z;
			sz += vz * dt + 0.5 * g * dt * dt;
			vz += g * dt;

			if( sz <= pz )
			{
				double	newVz = (pz - oldPz) / dt;
				if( vz < newVz )
					vz = newVz;
				sz = pz;
			}

			double	h = sz - pz;
			m_pPath[i].h = h;

			if( count == 1 && dumpInfo )
			{
                /*GfOut( "###  %4d  spd %3.0f k %7.4f dt %.3f pz %5.2f sz %5.2f vz %5.2f -> h %5.2f\n",
						i, m_pPath[i].accSpd * 3.6, m_pPath[i].k, dt,
                        pz, sz, vz, m_pPath[i].h );*/
			}

			pi = i;
		}
    }

    for( int count = 0; count < 3; count++ )
	{
        for( int i = 0; i < NSEG; i++ )
		{
			int	j = (i + 1) % NSEG;
			if( m_pPath[i].h < m_pPath[j].h )
				m_pPath[i].h = m_pPath[j].h;
        }
    }
}
示例#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;
	}
  }
示例#5
0
//==========================================================================*
// Calculate max possible speed
//--------------------------------------------------------------------------*
void TLane::CalcMaxSpeeds(int Step)
{
  CalcMaxSpeeds(0, oTrack->Count(), Step);
}