![]() |
Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
|
Provides an implementation of a lightweight lateral StanleyController. This algorithm is used to precisely control a different drive robot to follow a given path. More...
#include <StanleyController.h>
Public Member Functions | |
StanleyController () | |
Default constructor for Stanley Controller. | |
StanleyController (const double dKp, const double dDistToFrontAxle, const double dYawTolerance) | |
Construct a new Stanley Contoller:: Stanley Contoller object. | |
StanleyController (const std::vector< geoops::UTMCoordinate > &vUTMPath, const double dKp, const double dDistToFrontAxle, const double dYawTolerance) | |
Construct a new Stanley Contoller:: Stanley Contoller object. | |
StanleyController (const std::vector< geoops::GPSCoordinate > &vGPSPath, const double dKp, const double dDistToFrontAxle, const double dYawTolerance) | |
Construct a new Stanley Contoller:: Stanley Contoller object. | |
~StanleyController () | |
Destroy the Stanley Contoller:: Stanley Contoller object. | |
double | Calculate (const geoops::UTMCoordinate &stUTMCurrPos, const double dVelocity, const double dBearing) |
Calculate the steering control adjustment for an agent using the Stanley method. | |
double | Calculate (const geoops::GPSCoordinate &stGPSCurrPos, const double dVelocity, const double dBearing) |
Calculate the steering control adjustment for an agent using the Stanley method. | |
void | ResetProgress () |
Resets the progress on the current path. | |
void | SetSteeringControlGain (const double dKpp) |
Setter for steering control gain. | |
void | SetDistanceToFrontAxle (const double dDistToFrontAxle) |
Setter for distance to front axle. | |
void | SetYawTolerance (const double dYawTolerance) |
Setter for yaw tolerance. | |
void | SetPath (std::vector< geoops::UTMCoordinate > &vUTMPath) |
Setter for path. | |
void | SetPath (std::vector< geoops::GPSCoordinate > &vGPSPath) |
Setter for path. | |
void | ClearPath () |
double | GetSteeringControlGain () const |
Getter for steering control gain. | |
double | GetDistanceToFrontAxle () const |
Getter for distance to the front axle. | |
double | GetYawTolerance () const |
Getter for yaw tolerance. | |
unsigned int | GetLastTargetIdx () const |
Getter for the index of the last target point on the path. | |
std::vector< geoops::UTMCoordinate > | GetPathUTM () const |
Getter for path. | |
std::vector< geoops::GPSCoordinate > | GetPathGPS () const |
Getter for path. | |
Private Member Functions | |
geoops::UTMCoordinate | CalculateFrontAxleCoordinate (const geoops::UTMCoordinate &stUTMCurrPos, const double dBearing) const |
Calculate the UTM coordinate of the center of the agent's front axle. | |
unsigned int | IdentifyTargetIdx (const geoops::UTMCoordinate &stUTMFrontAxlePos) const |
Identifies the closest point to the center of the agent's front axle on the path. | |
double | CalculateTargetBearing (const unsigned int unTargetIdx) const |
Calculate the required bearing to navigate from the current target point to the subsequent point on the path. | |
double | CalculateCrossTrackError (const geoops::UTMCoordinate &stUTMFrontAxlePos, const unsigned int unTargetIdx, const double dBearing) const |
Calculate the cross track error. This error expresses how far off the agent is from the path (lateral distance). | |
Private Attributes | |
double | m_dKp |
double | m_dDistToFrontAxle |
double | m_dYawTolerance |
unsigned int | m_unLastTargetIdx |
std::vector< geoops::UTMCoordinate > | m_vUTMPath |
std::vector< geoops::GPSCoordinate > | m_vGPSPath |
Provides an implementation of a lightweight lateral StanleyController. This algorithm is used to precisely control a different drive robot to follow a given path.
controllers::StanleyController::StanleyController | ( | ) |
Default constructor for Stanley Controller.
controllers::StanleyController::StanleyController | ( | const double | dKp, |
const double | dDistToFrontAxle, | ||
const double | dYawTolerance | ||
) |
Construct a new Stanley Contoller:: Stanley Contoller object.
dKp | - Steering control gain. |
dDistToFrontAxle | - Distance between the position sensor (GPS) and the front axle. |
dYawTolerance | - Minimum yaw change threshold for execution. |
controllers::StanleyController::StanleyController | ( | const std::vector< geoops::UTMCoordinate > & | vUTMPath, |
const double | dKp, | ||
const double | dDistToFrontAxle, | ||
const double | dYawTolerance | ||
) |
Construct a new Stanley Contoller:: Stanley Contoller object.
vUTMPath | - Vector of UTM coordinates describing path to follow. |
dKp | - Steering control gain. |
dDistToFrontAxle | - Distance between the position sensor (GPS) and the front axle. |
dYawTolerance | - Minimum yaw change threshold for execution. |
controllers::StanleyController::StanleyController | ( | const std::vector< geoops::GPSCoordinate > & | vGPSPath, |
const double | dKp, | ||
const double | dDistToFrontAxle, | ||
const double | dYawTolerance | ||
) |
Construct a new Stanley Contoller:: Stanley Contoller object.
vGPSPath | - Vector of GPS coordinates describing path to follow. |
dKp | - Steering control gain. |
dDistToFrontAxle | - Distance between the position sensor (GPS) and the front axle. |
dYawTolerance | - Minimum yaw change threshold for execution. |
controllers::StanleyController::~StanleyController | ( | ) |
Destroy the Stanley Contoller:: Stanley Contoller object.
double controllers::StanleyController::Calculate | ( | const geoops::UTMCoordinate & | stUTMCurrPos, |
const double | dVelocity, | ||
const double | dBearing | ||
) |
Calculate the steering control adjustment for an agent using the Stanley method.
This function computes the necessary change in yaw (steering angle) to align the agent with the predetermined path. The steering angle is limited by the proportional gain constant to prevent excessively sharp turns.
stUTMCurrPos | - The agent's current position in the UTM coordinate space. |
dVelocity | - The agent's current magnitude of velocity. |
dBearing | - The agent's current yaw angle (heading). |
double controllers::StanleyController::Calculate | ( | const geoops::GPSCoordinate & | stGPSCurrPos, |
const double | dVelocity, | ||
const double | dBearing | ||
) |
Calculate the steering control adjustment for an agent using the Stanley method.
This function computes the necessary change in yaw (steering angle) to align the agent with the predetermined path. The steering angle is limited by the proportional gain constant to prevent excessively sharp turns.
stGPSCurrPos | - The agent's current position in the GPS coordinate space. |
dVelocity | - The agent's current magnitude of velocity. |
dBearing | - The agent's current yaw angle (heading). |
void controllers::StanleyController::ResetProgress | ( | ) |
Resets the progress on the current path.
The stanley control algorithm prevents points that have been pass to be revisited to motivate the agent to go further along the path. Although sometimes it may be necessary to restart an agents progress if it deviates far enough from the path.
void controllers::StanleyController::SetSteeringControlGain | ( | const double | dKp | ) |
Setter for steering control gain.
dKp | - Steering control gain. |
void controllers::StanleyController::SetDistanceToFrontAxle | ( | const double | dDistToFrontAxle | ) |
Setter for distance to front axle.
dDistToFrontAxle | - Distance between the position sensor (GPS) and the front axle. |
void controllers::StanleyController::SetYawTolerance | ( | const double | dYawTolerance | ) |
Setter for yaw tolerance.
dYawTolerance | - Minimum yaw change threshold for execution. |
void controllers::StanleyController::SetPath | ( | std::vector< geoops::UTMCoordinate > & | vUTMPath | ) |
Setter for path.
vUTMPath | - Vector of UTM coordinates describing path to follow. |
void controllers::StanleyController::SetPath | ( | std::vector< geoops::GPSCoordinate > & | vGPSPath | ) |
Setter for path.
vGPSPath | - Vector of GPS coordinates describing path to follow. |
void controllers::StanleyController::ClearPath | ( | ) |
double controllers::StanleyController::GetSteeringControlGain | ( | ) | const |
Getter for steering control gain.
double controllers::StanleyController::GetDistanceToFrontAxle | ( | ) | const |
Getter for distance to the front axle.
double controllers::StanleyController::GetYawTolerance | ( | ) | const |
Getter for yaw tolerance.
unsigned int controllers::StanleyController::GetLastTargetIdx | ( | ) | const |
Getter for the index of the last target point on the path.
std::vector< geoops::UTMCoordinate > controllers::StanleyController::GetPathUTM | ( | ) | const |
Getter for path.
std::vector< geoops::GPSCoordinate > controllers::StanleyController::GetPathGPS | ( | ) | const |
Getter for path.
|
private |
Calculate the UTM coordinate of the center of the agent's front axle.
stUTMCurrPos | - The agent's current position in the UTM coordinate space. |
dBearing | - The current bearing of the agent, measured in degrees from 0 to 360. |
|
private |
Identifies the closest point to the center of the agent's front axle on the path.
This function scans through a set of path points to find the one that is nearest to the center of the agent's front axle, providing a crucial reference for any path corrections.
stUTMFrontAxlePos | - The UTM coordinate of the center of the agent's front axle. |
|
private |
Calculate the required bearing to navigate from the current target point to the subsequent point on the path.
unTargetIdx | - Index of the target point on the path. |
|
private |
Calculate the cross track error. This error expresses how far off the agent is from the path (lateral distance).
stUTMFrontAxlePos | - The UTM coordinate of the center of the agent's front axle. |
unTargetIdx | - Index of the target point on the path. |
dBearing | - The current bearing of the agent, measured in degrees from 0 to 360. |