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
PredictiveStanleyController.cc File Reference

Unit Test Class for the PredictiveStanleyController. More...

Include dependency graph for PredictiveStanleyController.cc:

Classes

class  PredictiveStanleyControllerTests
 Test Class for the PredictiveStanleyController. More...

Functions

 TEST_F (PredictiveStanleyControllerTests, DefaultConstructor)
 Test the default constructor of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, ParameterizedConstructor)
 Test the parameterized constructor of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, SetControlGain)
 Test the SetControlGain method of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, SetAngularVelocityLimit)
 Test the SetAngularVelocityLimit method of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, SetReferencePath)
 Test the SetReferencePath method of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, SetReferencePathUTM)
 Test the SetReferencePath with UTM coordinates method of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, SetReferencePathGPS)
 Test the SetReferencePath with GPS coordinates method of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, CalculateEmptyPath)
 Test the Calculate method of PredictiveStanleyController when no reference path is set.
 TEST_F (PredictiveStanleyControllerTests, CalculateFullPath)
 Test the Calculate method of PredictiveStanleyController when a reference path is set.
 TEST_F (PredictiveStanleyControllerTests, DriveTowardsEndOfPath)
 Test the reached end of path logic in the Calculate method of PredictiveStanleyController.
 TEST_F (PredictiveStanleyControllerTests, GetPathTargetIndex)
 Test the GetPathTargetIndex method of PredictiveStanleyController.

Detailed Description

Unit Test Class for the PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( PredictiveStanleyControllerTests ,
DefaultConstructor  )

Test the default constructor of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
80{
82 EXPECT_NEAR(Controller.GetControlGain(), 0.1, 0.01);
83 EXPECT_NEAR(Controller.GetAngularVelocityLimit(), 90.0, 0.01);
84}
This class implements the Predictive Stanley Controller. This controller is used to follow a path usi...
Definition PredictiveStanleyController.h:44
double GetControlGain() const
Accessor for the control gain of the stanley controller.
Definition PredictiveStanleyController.cpp:340
double GetAngularVelocityLimit() const
Accessor for the angular velocity limit of the stanley controller.
Definition PredictiveStanleyController.cpp:353
Here is the call graph for this function:

◆ TEST_F() [2/11]

TEST_F ( PredictiveStanleyControllerTests ,
ParameterizedConstructor  )

Test the parameterized constructor of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
94{
95 controllers::PredictiveStanleyController Controller(2.0, 1.5, 10, 0.1);
96 EXPECT_NEAR(Controller.GetControlGain(), 2.0, 0.01);
97 EXPECT_NEAR(Controller.GetAngularVelocityLimit(), 1.5, 0.01);
98}
Here is the call graph for this function:

◆ TEST_F() [3/11]

TEST_F ( PredictiveStanleyControllerTests ,
SetControlGain  )

Test the SetControlGain method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
108{
110 Controller.SetControlGain(3.0);
111 EXPECT_NEAR(Controller.GetControlGain(), 3.0, 0.01);
112}
void SetControlGain(const double dControlGain)
Setter for the control gain of the stanley controller.
Definition PredictiveStanleyController.cpp:314
Here is the call graph for this function:

◆ TEST_F() [4/11]

TEST_F ( PredictiveStanleyControllerTests ,
SetAngularVelocityLimit  )

Test the SetAngularVelocityLimit method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
122{
124 Controller.SetAngularVelocityLimit(25.0);
125 EXPECT_NEAR(Controller.GetAngularVelocityLimit(), 25.0, 0.01);
126}
void SetAngularVelocityLimit(const double dAngularVelocityLimit)
Setter for the angular velocity limit of the stanley controller.
Definition PredictiveStanleyController.cpp:327
Here is the call graph for this function:

◆ TEST_F() [5/11]

TEST_F ( PredictiveStanleyControllerTests ,
SetReferencePath  )

Test the SetReferencePath method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
136{
138 std::vector<geoops::Waypoint> vPath = {geoops::GPSCoordinate(0.0, 0.0), geoops::GPSCoordinate(1.0, 1.0), geoops::GPSCoordinate(2.0, 2.0)};
139 Controller.SetReferencePath(vPath);
140 EXPECT_EQ(Controller.GetReferencePath().size(), vPath.size());
141
142 // Create a very complex path with a lot of waypoints.
143 std::vector<geoops::Waypoint> vComplexPath;
144 for (int i = 0; i < 1000; i++)
145 {
146 vComplexPath.push_back(geoops::GPSCoordinate(i * 0.1, i * 0.1));
147 }
148 Controller.SetReferencePath(vComplexPath);
149
150 EXPECT_TRUE(Controller.GetReferencePath().size() <= vComplexPath.size());
151}
void SetReferencePath(const std::vector< geoops::Waypoint > &vReferencePath)
Sets the path that the controller will follow.
Definition PredictiveStanleyController.cpp:250
std::vector< geoops::Waypoint > GetReferencePath() const
Accessor for the reference path that the controller is following.
Definition PredictiveStanleyController.cpp:366
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:100
Here is the call graph for this function:

◆ TEST_F() [6/11]

TEST_F ( PredictiveStanleyControllerTests ,
SetReferencePathUTM  )

Test the SetReferencePath with UTM coordinates method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
161{
163 std::vector<geoops::UTMCoordinate> vPath = {{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}};
164 Controller.SetReferencePath(vPath);
165 EXPECT_EQ(Controller.GetReferencePath().size(), vPath.size());
166}
Here is the call graph for this function:

◆ TEST_F() [7/11]

TEST_F ( PredictiveStanleyControllerTests ,
SetReferencePathGPS  )

Test the SetReferencePath with GPS coordinates method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
176{
178 std::vector<geoops::GPSCoordinate> vPath = {{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}};
179 Controller.SetReferencePath(vPath);
180 EXPECT_EQ(Controller.GetReferencePath().size(), vPath.size());
181}
Here is the call graph for this function:

◆ TEST_F() [8/11]

TEST_F ( PredictiveStanleyControllerTests ,
CalculateEmptyPath  )

Test the Calculate method of PredictiveStanleyController when no reference path is set.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
191{
193 geoops::RoverPose stPose = {geoops::GPSCoordinate{0.0, 0.0}, 0.0};
195 EXPECT_NEAR(driveVector.dThetaHeading, 0.0, 0.01);
196}
DriveVector Calculate(const geoops::RoverPose &stCurrentPose, const double dMaxSpeed=constants::NAVIGATING_MOTOR_POWER)
Calculate an updated steering angle for the rover based on the current pose using the predictive stan...
Definition PredictiveStanleyController.cpp:78
Definition PredictiveStanleyController.h:50
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:708
Here is the call graph for this function:

◆ TEST_F() [9/11]

TEST_F ( PredictiveStanleyControllerTests ,
CalculateFullPath  )

Test the Calculate method of PredictiveStanleyController when a reference path is set.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
206{
208 std::vector<geoops::Waypoint> vPath = {geoops::GPSCoordinate(0.0, 0.0), geoops::GPSCoordinate(1.0, 1.0), geoops::GPSCoordinate(2.0, 2.0)};
209 Controller.SetReferencePath(vPath);
210 geoops::RoverPose stPose = {geoops::GPSCoordinate{1.0, 1.0}, 0.0};
212 EXPECT_NEAR(driveVector.dThetaHeading, 58, 1.0);
213}
Here is the call graph for this function:

◆ TEST_F() [10/11]

TEST_F ( PredictiveStanleyControllerTests ,
DriveTowardsEndOfPath  )

Test the reached end of path logic in the Calculate method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-03-04
223{
225 std::vector<geoops::Waypoint> vPath = {geoops::GPSCoordinate(0.0, 0.0), geoops::GPSCoordinate(1.0, 1.0), geoops::GPSCoordinate(2.0, 2.0)};
226 Controller.SetReferencePath(vPath);
227 geoops::RoverPose stPose = {geoops::GPSCoordinate{3.0, 3.0}, 45.0};
229 driveVector = Controller.Calculate(stPose);
230 EXPECT_NEAR(driveVector.dThetaHeading, 225, 1.0);
231}
Here is the call graph for this function:

◆ TEST_F() [11/11]

TEST_F ( PredictiveStanleyControllerTests ,
GetPathTargetIndex  )

Test the GetPathTargetIndex method of PredictiveStanleyController.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-11
241{
243 std::vector<geoops::Waypoint> vPath = {geoops::GPSCoordinate(0.0, 0.0), geoops::GPSCoordinate(1.0, 1.0), geoops::GPSCoordinate(2.0, 2.0)};
244 Controller.SetReferencePath(vPath);
245 Controller.Calculate({geoops::GPSCoordinate{2.0, 2.0}, 0.0});
246 EXPECT_EQ(Controller.GetReferencePathTargetIndex(), 1);
247}
double GetReferencePathTargetIndex() const
Accessor for the current target index in the reference path.
Definition PredictiveStanleyController.cpp:379
Here is the call graph for this function: