## Description

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 <ChAdaptiveSpeedController.h>

## Public Member Functions

Construct a speed controller with default parameters. More...

Construct a steering controller with parameters read from a JSON file.

Destructor.

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 target_following_time, double target_min_distance, double current_distance, 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