chrono::vehicle::ChSteeringController Class Referenceabstract

Description

Base class for all steering path-following PID controllers.

The base class implements the basic functionality to control the error between the location of a sentinel point (a point at a look-ahead distance in front of the vehicle) and the current target point.

The parameters of a steering controller can also be specified through a JSON file; a sample JSON input file is as follows:

 {
     "Gains":
     {
         "Kp":   0.5,
             "Ki" : 0.0,
             "Kd" : 0.0
     },

     "Lookahead Distance": 20.0
 }

Data collection from the steering controller can be started (restarted) and suspended (stopped) as many times as desired. Data collected so far can be written to a file. The tab-separated output ASCII file contains on each line the time, location of the target point, and location of the sentinel point.

#include <ChSteeringController.h>

Inheritance diagram for chrono::vehicle::ChSteeringController:
Collaboration diagram for chrono::vehicle::ChSteeringController:

Public Member Functions

 ChSteeringController ()
 Construct a steering controller with default parameters. More...
 
 ChSteeringController (const std::string &filename)
 Construct a steering controller with parameters read from a JSON file.
 
virtual ~ChSteeringController ()
 Destructor.
 
void SetLookAheadDistance (double dist)
 Specify the look-ahead distance. More...
 
void SetGains (double Kp, double Ki, double Kd)
 Set the gains for the PID controller.
 
const ChVectorGetSentinelLocation () const
 Return the current location of the sentinel point. More...
 
const ChVectorGetTargetLocation () const
 Return the current value of the target point. More...
 
virtual void Reset (const ChVehicle &vehicle)
 Reset the PID controller. More...
 
double Advance (const ChVehicle &vehicle, double step)
 Advance the state of the PID controller. More...
 
void StartDataCollection ()
 Start/restart data collection.
 
void StopDataCollection ()
 Suspend/stop data collection.
 
bool IsDataCollectionEnabled () const
 Return true if data is being collected.
 
bool IsDataAvailable () const
 Return true if data is available for output.
 
void WriteOutputFile (const std::string &filename)
 Output data collected so far to the specified file.
 

Protected Member Functions

virtual void CalcTargetLocation ()=0
 Calculate the current target point location. More...
 

Protected Attributes

double m_dist
 look-ahead distance
 
ChVector m_sentinel
 position of sentinel point in global frame
 
ChVector m_target
 position of target point in global frame
 
double m_Kp
 
double m_Ki
 PID controller gains.
 
double m_Kd
 
double m_err
 current error (signed distance to target point)
 
double m_errd
 error derivative
 
double m_erri
 integral of error
 
utils::CSV_writer * m_csv
 CSV_writer object for data collection.
 
bool m_collect
 flag indicating whether or not data is being collected
 

Constructor & Destructor Documentation

chrono::vehicle::ChSteeringController::ChSteeringController ( )

Construct a steering controller with default parameters.

Default values are all gains set to zero (no controller). The user is responsible for calling SetGains and SetLookAheadDistance.

Member Function Documentation

double chrono::vehicle::ChSteeringController::Advance ( const ChVehicle vehicle,
double  step 
)

Advance the state of the PID controller.

This function performs the required integration for the integral component of the PID controller and returns the calculated steering value.

virtual void chrono::vehicle::ChSteeringController::CalcTargetLocation ( )
protectedpure virtual

Calculate the current target point location.

All derived classes must implement this function to calculate the current location of the target point, expressed in the global frame. The location of the sentinel point at the current time is calculated and available in m_sentinel.

Implemented in chrono::vehicle::ChPathSteeringController.

const ChVector& chrono::vehicle::ChSteeringController::GetSentinelLocation ( ) const

Return the current location of the sentinel point.

The return vector is expressed in the global reference frame.

const ChVector& chrono::vehicle::ChSteeringController::GetTargetLocation ( ) const

Return the current value of the target point.

The return vector is expressed in the global reference frame.

void chrono::vehicle::ChSteeringController::Reset ( const ChVehicle vehicle)
virtual

Reset the PID controller.

This function must be called at a configuration where a valid location for the sentinel point can be calculated. The default implementation in the base class simply calculates the new sentinel point location and sets all errors to 0.

Reimplemented in chrono::vehicle::ChPathSteeringController.

void chrono::vehicle::ChSteeringController::SetLookAheadDistance ( double  dist)

Specify the look-ahead distance.

This defines the location of the "sentinel" point (in front of the vehicle, at the given distance from the chassis reference frame).