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.
Loading...
Searching...
No Matches
StanleyController.h
Go to the documentation of this file.
1
11#ifndef STANLEY_CONTROLLER_H
12#define STANLEY_CONTROLLER_H
13
14#include "../../util/GeospatialOperations.hpp"
15#include "../../util/NumberOperations.hpp"
16
18// Put implicit includes in here.
19
20#include <cmath>
21#include <gtest/gtest.h>
22#include <limits>
23#include <vector>
24
26
27
36namespace controllers
37{
38
50 {
51 public:
53 // Declare public methods and member variables.
56 StanleyController(const double dKp, const double dDistToFrontAxle, const double dYawTolerance);
57 StanleyController(const std::vector<geoops::UTMCoordinate>& vUTMPath, const double dKp, const double dDistToFrontAxle, const double dYawTolerance);
58 StanleyController(const std::vector<geoops::GPSCoordinate>& vGPSPath, const double dKp, const double dDistToFrontAxle, const double dYawTolerance);
60
61 double Calculate(const geoops::UTMCoordinate& stUTMCurrPos, const double dVelocity, const double dBearing);
62 double Calculate(const geoops::GPSCoordinate& stGPSCurrPos, const double dVelocity, const double dBearing);
63 void ResetProgress();
64
66 // Setters.
68
69 void SetSteeringControlGain(const double dKpp);
70 void SetDistanceToFrontAxle(const double dDistToFrontAxle);
71 void SetYawTolerance(const double dYawTolerance);
72
73 void SetPath(std::vector<geoops::UTMCoordinate>& vUTMPath);
74 void SetPath(std::vector<geoops::GPSCoordinate>& vGPSPath);
75
76 void ClearPath();
77
79 // Getters.
81
82 double GetSteeringControlGain() const;
83 double GetDistanceToFrontAxle() const;
84 double GetYawTolerance() const;
85 unsigned int GetLastTargetIdx() const;
86 std::vector<geoops::UTMCoordinate> GetPathUTM() const;
87 std::vector<geoops::GPSCoordinate> GetPathGPS() const;
88
89 private:
91 // Declare private methods.
93
94 geoops::UTMCoordinate CalculateFrontAxleCoordinate(const geoops::UTMCoordinate& stUTMCurrPos, const double dBearing) const;
95 unsigned int IdentifyTargetIdx(const geoops::UTMCoordinate& stUTMFrontAxlePos) const;
96 double CalculateTargetBearing(const unsigned int unTargetIdx) const;
97 double CalculateCrossTrackError(const geoops::UTMCoordinate& stUTMFrontAxlePos, const unsigned int unTargetIdx, const double dBearing) const;
98
100 // Declare private member variables.
102
103 double m_dKp; // Steering control gain.
104 double m_dDistToFrontAxle; // Distance between the position sensor (GPS) and the front axle.
105 double m_dYawTolerance; // Minimum yaw change threshold for execution.
106 unsigned int m_unLastTargetIdx; // Index of last point on path used in Stanley calculation.
107 std::vector<geoops::UTMCoordinate> m_vUTMPath; // Stores the sequence of UTM coordinates defining the navigational path.
108 std::vector<geoops::GPSCoordinate> m_vGPSPath; // Stores the sequence of GPS coordinates defining the navigational path.
109 };
110} // namespace controllers
111
112#endif
Provides an implementation of a lightweight lateral StanleyController. This algorithm is used to prec...
Definition StanleyController.h:50
std::vector< geoops::UTMCoordinate > GetPathUTM() const
Getter for path.
Definition StanleyController.cpp:375
std::vector< geoops::GPSCoordinate > GetPathGPS() const
Getter for path.
Definition StanleyController.cpp:388
unsigned int GetLastTargetIdx() const
Getter for the index of the last target point on the path.
Definition StanleyController.cpp:362
double Calculate(const geoops::UTMCoordinate &stUTMCurrPos, const double dVelocity, const double dBearing)
Calculate the steering control adjustment for an agent using the Stanley method.
Definition StanleyController.cpp:150
void ResetProgress()
Resets the progress on the current path.
Definition StanleyController.cpp:224
StanleyController()
Default constructor for Stanley Controller.
Definition StanleyController.cpp:35
double CalculateTargetBearing(const unsigned int unTargetIdx) const
Calculate the required bearing to navigate from the current target point to the subsequent point on t...
Definition StanleyController.cpp:479
double GetDistanceToFrontAxle() const
Getter for distance to the front axle.
Definition StanleyController.cpp:336
~StanleyController()
Destroy the Stanley Contoller:: Stanley Contoller object.
Definition StanleyController.cpp:131
void SetYawTolerance(const double dYawTolerance)
Setter for yaw tolerance.
Definition StanleyController.cpp:263
unsigned int IdentifyTargetIdx(const geoops::UTMCoordinate &stUTMFrontAxlePos) const
Identifies the closest point to the center of the agent's front axle on the path.
Definition StanleyController.cpp:444
void SetDistanceToFrontAxle(const double dDistToFrontAxle)
Setter for distance to front axle.
Definition StanleyController.cpp:250
double GetYawTolerance() const
Getter for yaw tolerance.
Definition StanleyController.cpp:349
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...
Definition StanleyController.cpp:532
void SetSteeringControlGain(const double dKpp)
Setter for steering control gain.
Definition StanleyController.cpp:237
double GetSteeringControlGain() const
Getter for steering control gain.
Definition StanleyController.cpp:323
geoops::UTMCoordinate CalculateFrontAxleCoordinate(const geoops::UTMCoordinate &stUTMCurrPos, const double dBearing) const
Calculate the UTM coordinate of the center of the agent's front axle.
Definition StanleyController.cpp:409
void SetPath(std::vector< geoops::UTMCoordinate > &vUTMPath)
Setter for path.
Definition StanleyController.cpp:276
This namespace stores classes, functions, and structs that are used to implement different controller...
Definition PIDController.cpp:26
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:148
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:244