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
SearchPatternTests Class Reference

Unit Test Class for the SearchPattern. More...

Inheritance diagram for SearchPatternTests:
Collaboration diagram for SearchPatternTests:

Public Member Functions

 SearchPatternTests ()
 Construct a new Search Pattern Tests object.
 ~SearchPatternTests ()
 Destroy the Search Pattern Tests object.
void TestSetup () override
 Setup the Search Pattern Tests object.
void TestTeardown () override
 Teardown the Search Pattern Tests object.
Public Member Functions inherited from TestingBase< SearchPatternTests >
 TestingBase ()=default
 Construct a new Testing Base object.
virtual ~TestingBase ()=default
 Destroy the Testing Base object.

Protected Member Functions

bool IsOutwardSpiral (const std::vector< geoops::Waypoint > &vPoints)
 Function used in testing to determine if a returns list of waypoints is a good spiral.
bool IsZigZag (const std::vector< geoops::Waypoint > &vPoints, const double dSlopeThreshold=0.1)
 Function used in testing to determine if a returns list of waypoints is a good zigzag.
Protected Member Functions inherited from TestingBase< SearchPatternTests >
void RequiredSetup ()
 Required setup for all tests.
void RequiredTeardown ()
 Required teardown for all tests.
void SetupRoveComm ()
 Setup RoveComm for testing.
void TeardownRoveComm ()
 Teardown RoveComm for testing.

Additional Inherited Members

Static Public Member Functions inherited from TestingBase< SearchPatternTests >
static void SetCommandLineArgs (int argc, char **argv)
 Mutator for the Command Line Args private member.

Detailed Description

Unit Test Class for the SearchPattern.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09

Constructor & Destructor Documentation

◆ SearchPatternTests()

SearchPatternTests::SearchPatternTests ( )
inline

Construct a new Search Pattern Tests object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
168{}

◆ ~SearchPatternTests()

SearchPatternTests::~SearchPatternTests ( )
inline

Destroy the Search Pattern Tests object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
176{}

Member Function Documentation

◆ IsOutwardSpiral()

bool SearchPatternTests::IsOutwardSpiral ( const std::vector< geoops::Waypoint > & vPoints)
inlineprotected

Function used in testing to determine if a returns list of waypoints is a good spiral.

Parameters
vPoints- The list of waypoint that, in order, should form a spiral.
Returns
true - The list of waypoints is a valid spiral.
false - The list of waypoint is not a valid spiral.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-01
48 {
49 // At least 4 vPoints are needed to form a spiral.
50 if (vPoints.size() < 4)
51 {
52 return false;
53 }
54
55 // Store starting point.
56 geoops::UTMCoordinate stCenterPoint = vPoints[0].GetUTMCoordinate();
57 // Store geo distance information of last point.
58 geoops::GeoMeasurement stLastGeodesicFromCenterPoint;
59
60 // Loop through each waypoint.
61 for (int nIter = 1; nIter < vPoints.size(); ++nIter)
62 {
63 // Check if this is the first iteration.
64 if (nIter == 1)
65 {
66 // Just calculate geo distance between start and first point and store it.
67 stLastGeodesicFromCenterPoint = geoops::CalculateGeoMeasurement(stCenterPoint, vPoints[nIter].GetUTMCoordinate());
68 }
69 else
70 {
71 // Calculate geo measurement for new point.
72 geoops::GeoMeasurement stNewMeasurement = geoops::CalculateGeoMeasurement(stCenterPoint, vPoints[nIter].GetUTMCoordinate());
73
74 // Check that the measurement is further away from the center point that last time and is radially progressing in some direction.
75 if (stNewMeasurement.dDistanceMeters < stLastGeodesicFromCenterPoint.dDistanceMeters ||
76 stNewMeasurement.dStartRelativeBearing == stLastGeodesicFromCenterPoint.dStartRelativeBearing ||
77 stNewMeasurement.dEndRelativeBearing == stLastGeodesicFromCenterPoint.dEndRelativeBearing)
78 {
79 // Conditions net met, this is not a proper spiral.
80 return false;
81 }
82
83 // Update last measurement variable.
84 stLastGeodesicFromCenterPoint = stNewMeasurement;
85 }
86 }
87
88 return true;
89 }
GeoMeasurement CalculateGeoMeasurement(const GPSCoordinate &stCoord1, const GPSCoordinate &stCoord2)
The shortest path between two points on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the g...
Definition GeospatialOperations.hpp:553
Here is the call graph for this function:

◆ IsZigZag()

bool SearchPatternTests::IsZigZag ( const std::vector< geoops::Waypoint > & vPoints,
const double dSlopeThreshold = 0.1 )
inlineprotected

Function used in testing to determine if a returns list of waypoints is a good zigzag.

Parameters
vPoints- The list of waypoint that, in order, should form a zigzag.
Returns
true - The list of waypoints is a valid zigzag.
false - The list of waypoint is not a valid zigzag.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-01
103 {
104 // Create instance variables.
105 bool bZigZag = false;
106 double dExpectedSlope = 0.0;
107
108 // At least 3 points are needed for a zigzag.
109 if (vPoints.size() < 3)
110 {
111 return false;
112 }
113
114 // Loop through path points.
115 for (size_t siIter = 1; siIter < vPoints.size(); ++siIter)
116 {
117 // Calculate slope of last two points.
118 double dSlope = atan2(vPoints[siIter].GetUTMCoordinate().dNorthing - vPoints[siIter - 1].GetUTMCoordinate().dNorthing,
119 vPoints[siIter].GetUTMCoordinate().dEasting - vPoints[siIter - 1].GetUTMCoordinate().dEasting);
120
121 // Make sure this isn't the first iteration of the loop.
122 if (siIter > 1)
123 {
124 // Calculate the previous slope.
125 double dPrevSlope = atan2(vPoints[siIter - 1].GetUTMCoordinate().dNorthing - vPoints[siIter - 2].GetUTMCoordinate().dNorthing,
126 vPoints[siIter - 1].GetUTMCoordinate().dEasting - vPoints[siIter - 2].GetUTMCoordinate().dEasting);
127 // Check if the slope has changed.
128 if (std::abs(dSlope - dPrevSlope) > dSlopeThreshold)
129 {
130 // Check if the slope is the same value as the dExpected slope and has the same sign.
131 if ((dSlope - dPrevSlope) == dExpectedSlope)
132 {
133 // Set this is a zigzag.
134 bZigZag = true;
135 }
136 else
137 {
138 return false;
139 }
140 }
141 }
142 // This is the firs iteration.
143 if (siIter < vPoints.size() - 1)
144 {
145 // Calculate the next slope.
146 double dNextSlope = atan2(vPoints[siIter + 1].GetUTMCoordinate().dNorthing - vPoints[siIter].GetUTMCoordinate().dNorthing,
147 vPoints[siIter + 1].GetUTMCoordinate().dEasting - vPoints[siIter].GetUTMCoordinate().dEasting);
148 // Check if the slope has changed.
149 if (std::abs(dSlope - dNextSlope) > dSlopeThreshold)
150 {
151 // Store the next expected slope change. (will have opposite sign)
152 dExpectedSlope = -(dSlope - dNextSlope);
153 }
154 }
155 }
156
157 // If either increasing or decreasing slope condition is met, it's a zigzag.
158 return bZigZag;
159 }
__device__ __forceinline__ float1 atan2(const uchar1 &a, const uchar1 &b)

◆ TestSetup()

void SearchPatternTests::TestSetup ( )
inlineoverridevirtual

Setup the Search Pattern Tests object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09

Reimplemented from TestingBase< SearchPatternTests >.

184{}

◆ TestTeardown()

void SearchPatternTests::TestTeardown ( )
inlineoverridevirtual

Teardown the Search Pattern Tests object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09

Reimplemented from TestingBase< SearchPatternTests >.

192{}

The documentation for this class was generated from the following file: