chrono::vehicle::ChSpeedController Class Reference


Data collection from the speed 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, current desired speed, and current actual speed.

#include <ChSpeedController.h>

Public Member Functions

 ChSpeedController ()
 Construct a speed controller with default parameters. More...
 ChSpeedController (const std::string &filename)
 Construct a steering controller with parameters read from a JSON file.
virtual ~ChSpeedController ()
void SetGains (double Kp, double Ki, double Kd)
 Set the gains for the PID controller.
double GetCurrentSpeed () const
 Return the current speed.
virtual void Reset (const ChVehicle &vehicle)
 Reset the PID controller.
double Advance (const ChVehicle &vehicle, double target_speed, 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 Attributes

double m_speed
 current vehicle speed
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::ChSpeedController::ChSpeedController ( )

Construct a speed controller with default parameters.

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

Member Function Documentation

double chrono::vehicle::ChSpeedController::Advance ( const ChVehicle vehicle,
double  target_speed,
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 controller value.