- Update Shadow's driver

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

Former-commit-id: f1a8b9ada7e601897c021607b9df413787172fa0
Former-commit-id: 812bf7a8fcecb783744b533a0697700e8f17841d
This commit is contained in:
torcs-ng 2015-04-10 00:12:00 +00:00
parent a325ba2c6d
commit 7b3a208980
12 changed files with 12 additions and 389 deletions

View file

@ -21,12 +21,8 @@ SET(ROBOT_SOURCES src/Array.h
src/CubicSpline.h
src/GenericAvoidance.cpp
src/GenericAvoidance.h
src/Hysteresis.cpp
src/Hysteresis.h
src/LearnedGraph.cpp
src/LearnedGraph.h
src/LinearAttractor.cpp
src/LinearAttractor.h
src/LinearRegression.cpp
src/LinearRegression.h
src/LinePath.cpp
@ -45,8 +41,6 @@ SET(ROBOT_SOURCES src/Array.h
src/Path.h
src/PathRecord.cpp
src/PathRecord.h
src/Pattern.cpp
src/Pattern.h
src/PidController.cpp
src/PidController.h
src/PitControl.cpp

View file

@ -397,7 +397,7 @@ void CarModel::CalcSimuSpeeds( double spd0, double dy, double dist, double kFric
// max_a = M * G * MU;
// max_spd = sqrt(max_a r) = sqrt(M * G * MU / k)
double M = MASS + FUEL;
//double M = MASS + FUEL;
double MU = kFriction * TYRE_MU;
double max_acc = GRAVITY * MU;
@ -443,7 +443,7 @@ void CarModel::CalcSimuSpeedRanges( double spd0, double dist, double kFriction,
// max_a = M * G * MU;
// max_spd = sqrt(max_a r) = sqrt(M * G * MU / k)
double M = MASS + FUEL;
//double M = MASS + FUEL;
double MU = kFriction * TYRE_MU;
double max_acc = GRAVITY * MU;

View file

@ -129,14 +129,14 @@ void ClothoidPath::AnalyseBumps( const CarModel& cm, bool dumpInfo )
double sz = m_pPath[0].pt.z;
double vz = 0;
double pz = sz;
double dt = 0.1;
//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 oldSz = sz;
double oldPz = pz;
double v = (m_pPath[i].accSpd + m_pPath[pi].accSpd) * 0.5;
@ -419,7 +419,7 @@ void ClothoidPath::Optimise( const CarModel& cm, double factor, int idx, PathPt*
}
double t = l3->offs;
double oldT = t;
//double oldT = t;
Utils::LineCrossesLineXY( l3->Pt(), l3->Norm(), p2, p4 - p2, t );
// if( l3->h < 0.1 )
{

View file

@ -37,7 +37,6 @@
#include "LearnedGraph.h"
#include "AveragedData.h"
#include "LinearRegression.h"
#include "LinearAttractor.h"
#include "PtInfo.h"
#include "Strategy.h"
@ -397,8 +396,8 @@ private:
double m_FuelNeeded;
double m_RepairNeeded;
LinearAttractor m_avoidX;
LinearAttractor m_avoidY;
//LinearAttractor m_avoidX;
//LinearAttractor m_avoidY;
Vec2d m_lastPts[HIST];
double m_lastSpd;

View file

@ -1,35 +0,0 @@
// Hysteresis.cpp: implementation of the Hysteresis class.
//
//////////////////////////////////////////////////////////////////////
#include "Hysteresis.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Hysteresis::Hysteresis( double hist )
: m_hist(hist),
m_oldTest(TEST_UNKNOWN)
{
}
Hysteresis::~Hysteresis()
{
}
bool Hysteresis::IsLess( double value, double limit ) const
{
bool less = value < limit || m_oldTest == TEST_LESS && value < limit + m_hist;
m_oldTest = less ? TEST_LESS : TEST_MORE;
return less;
}
bool Hysteresis::IsMore( double value, double limit ) const
{
bool more = value > limit || m_oldTest == TEST_MORE && value > limit - m_hist;
m_oldTest = more ? TEST_MORE : TEST_LESS;
return more;
}

View file

@ -1,26 +0,0 @@
#ifndef _HYSTERESIS_H_
#define _HYSTERESIS_H_
class Hysteresis
{
public:
Hysteresis( double hist );
~Hysteresis();
bool IsLess( double value, double limit ) const;
bool IsMore( double value, double limit ) const;
private:
enum
{
TEST_LESS = -1,
TEST_UNKNOWN = 0,
TEST_MORE = 1,
};
private:
double m_hist;
mutable int m_oldTest;
};
#endif

View file

@ -1,116 +0,0 @@
// LinearAttractor.cpp: implementation of the LinearAttractor class.
//
//////////////////////////////////////////////////////////////////////
#include "LinearAttractor.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LinearAttractor::LinearAttractor()
: m_value(0),
m_velocity(0),
// m_accel(0),
m_maxVelocity(0.01),
m_maxAccel(0.01)
// m_min(-1),
// m_max(1)
{
}
LinearAttractor::~LinearAttractor()
{
}
double LinearAttractor::GetValue() const
{
return m_value;
}
void LinearAttractor::SetValue( double value )
{
m_value = value;
}
double LinearAttractor::GetVelocity() const
{
return m_velocity;
}
void LinearAttractor::SetVelocity( double velocity )
{
m_velocity = velocity;
}
/*
double LinearAttractor::GetAccel() const
{
return m_accel;
}
void LinearAttractor::SetAccel( double accel )
{
m_accel = accel;
}
*/
double LinearAttractor::GetMaxVelocity() const
{
return m_maxVelocity;
}
void LinearAttractor::SetMaxVelocity( double velocity )
{
m_maxVelocity = velocity;
}
double LinearAttractor::GetMaxAccel() const
{
return m_maxAccel;
}
void LinearAttractor::SetMaxAccel( double accel )
{
m_maxAccel = accel;
}
/*
double LinearAttractor::GetMin() const
{
return m_min;
}
void LinearAttractor::SetMin( double min )
{
m_min = min;
}
double LinearAttractor::GetMax() const
{
return m_max;
}
void LinearAttractor::SetMax( double max )
{
m_max = max;
}
*/
void LinearAttractor::Update( double target )
{
double delta = target - m_value;
double targetVelocity = delta * 0.05;
if( targetVelocity > m_maxVelocity )
targetVelocity = m_maxVelocity;
else if( targetVelocity < -m_maxVelocity )
targetVelocity = -m_maxVelocity;
double velocityDelta = targetVelocity - m_velocity;
double targetAccel = velocityDelta * 0.5;
if( targetAccel > m_maxAccel )
targetAccel = m_maxAccel;
else if( targetAccel < -m_maxAccel )
targetAccel = -m_maxAccel;
m_velocity += targetAccel;
m_value += m_velocity;
}

View file

@ -1,31 +0,0 @@
#ifndef _LINEARATTRACTOR_H_
#define _LINEARATTRACTOR_H_
class LinearAttractor
{
public:
LinearAttractor();
~LinearAttractor();
double GetValue() const;
void SetValue( double value );
double GetVelocity() const;
void SetVelocity( double vel );
double GetMaxVelocity() const;
void SetMaxVelocity( double velocity );
double GetMaxAccel() const;
void SetMaxAccel( double accel );
void Update( double target );
private:
double m_value;
double m_velocity;
double m_maxVelocity;
double m_maxAccel;
};
#endif

View file

@ -47,7 +47,7 @@ void OptimisedPath::Initialise()
void OptimisedPath::SetupStartSlice()
{
// need to add nodes to this slice, that are around the start pt info.
if( m_curSlice == 0 );
if( m_curSlice == 0 )
m_curSlice = new Slice();
SetupSlice( 0, m_curSlice );
@ -149,8 +149,8 @@ void OptimisedPath::NextSlice()
double ang = node2.m_ang - node1.m_ang;
NORM_PI_PI(ang);
double k1 = ang / dist;
double k2 = Utils::CalcCurvatureTan(p1, node1.m_vel, p2);
double K = GetAt(m_curSlice->m_seg).k;
//double k2 = Utils::CalcCurvatureTan(p1, node1.m_vel, p2);
//double K = GetAt(m_curSlice->m_seg).k;
double minSpd, maxSpd;
m_cm.CalcSimuSpeeds(spd1, k1, dist, 1.0, minSpd, maxSpd);

View file

@ -1,131 +0,0 @@
// Pattern.cpp: implementation of the Pattern class.
//
//////////////////////////////////////////////////////////////////////
#include "Pattern.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Pattern::Pattern()
{
}
Pattern::Pattern( const Pattern& pattern )
{
m_spans = pattern.m_spans;
}
Pattern::Pattern( const Span& span )
{
m_spans.Add( span );
}
Pattern::Pattern( double a, double b )
{
m_spans.Add( Span(a, b) );
}
Pattern::~Pattern()
{
}
bool Pattern::Overlaps( const Span& span ) const
{
if( span.IsNull() )
return false;
for( int i = 0; i < m_spans.GetSize(); i++ )
{
if( m_spans[i].Overlaps(span) )
return true;
}
return false;
}
void Pattern::InsertAt( int index, const Span& span )
{
m_spans.InsertAt( index, span );
}
void Pattern::RemoveAt( int index )
{
m_spans.RemoveAt( index );
}
void Pattern::Remove( const Span& span )
{
if( span.IsNull() )
return;
for( int i = m_spans.GetSize() - 1; i >= 0; i-- )
{
if( m_spans[i].a >= span.b )
continue;
if( m_spans[i].Overlaps(span) )
{
if( m_spans[i].Contains(span) )
{
InsertAt( i + 1, Span(span.b, m_spans[i].b) );
m_spans[i].b = span.a;
break;
}
else if( span.Contains(m_spans[i]) )
{
RemoveAt( i );
}
else
{
if( m_spans[i].a < span.a )
m_spans[i].b = span.a;
else
m_spans[i].a = span.b;
}
}
else if( m_spans[i].b <= span.a )
{
break;
}
}
// ASSERT( !Overlaps(span) );
}
void Pattern::Add( const Span& span )
{
if( span.IsNull() )
return;
if( m_spans.IsEmpty() )
{
m_spans.Add( span );
return;
}
if( span.b < m_spans[0].a )
{
m_spans.InsertAt( 0, span );
return;
}
if( span.a > m_spans[m_spans.GetSize() - 1].b )
{
m_spans.Add( span );
return;
}
for( int i = m_spans.GetSize() - 1; i >= 0; i-- )
{
if( m_spans[i].Overlaps(span) )
{
if( m_spans[i].Contains(span) )
return;
// if( m_spans[i].a < span.a )
// else
}
}
}

View file

@ -1,31 +0,0 @@
#ifndef _PATTERN_H_
#define _PATTERN_H_
#include "Array.h"
#include "Span.h"
class Pattern
{
public:
Pattern();
Pattern( const Pattern& pattern );
Pattern( const Span& span );
Pattern( double a, double b );
~Pattern();
bool Overlaps( const Span& span ) const;
void InsertAt( int index, const Span& span );
void RemoveAt( int index );
void Remove( const Span& span ); // pattern &= ~span
void Add( const Span& span ); // pattern |= span;
// void Remove( const Pattern& p ); // pattern &= ~p;
// void Add( const Pattern& p ); // pattern |= p;
private:
Array<Span> m_spans;
};
#endif

View file

@ -98,7 +98,7 @@ void PitControl::Process( CarElt* pCar )
double repairLimit = delayRepair ? 7000 : 5000;
double fuelPerLap = fuelPerM * trackLen;
double damagePerLap = damagePerM * trackLen;
//double damagePerLap = damagePerM * trackLen;
// bool likeToPit = pCar->_dammage >= 500 || pCar->_fuel < 90;
// bool likeToPit = pCar->_dammage + damagePerLap >= repairLimit ||