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

Unit test for AStar algorithm class. More...

Include dependency graph for AStarPlanner.cc:

Classes

class  AStarPlannerTests
 Unit Test Class for the AStar Planner. More...

Functions

 TEST_F (AStarPlannerTests, DoesNotLeak)
 Check that AStar doesn't leak any memory.
 TEST_F (AStarPlannerTests, Leaks)
 This should fail when the –check_for_leaks command line flag is specified.
 TEST_F (AStarPlannerTests, PlanAvoidancePathWaypoints)
 Test AStar path planning functionality with Waypoints.
 TEST_F (AStarPlannerTests, PlanAvoidancePathUTMCoordinates)
 Test AStar path planning functionality.
 TEST_F (AStarPlannerTests, PlanAvoidancePathGPSCoordinates)
 Test AStar path planning functionality with GPSCoordinates.
 TEST_F (AStarPlannerTests, PlanAvoidancePathStartEndBlocked)
 Test AStar's ability to still plan a path when obstacles overlap the start and end coordinates. The start and end of the path will just shift around until they are no longer blocked.
 TEST_F (AStarPlannerTests, PlanAvoidancePathCancel)
 Test AStar path planning cancellation feature.
 TEST_F (AStarPlannerTests, ObstacleInitialization)
 Test AStar obstacle initialization.
 TEST_F (AStarPlannerTests, UpsertObstacleData)
 Test AStar obstacle data management functionality.
 TEST_F (AStarPlannerTests, AvoidObstaclesWhilePathing)
 Test AStar path obstacle avoidance for cardinal and diagonal directions.
 TEST_F (AStarPlannerTests, Maze)
 Tests to see if AStar can path through a maze which requires lots of doubling back.

Detailed Description

Unit test for AStar algorithm class.

Author
Kai Shafe (kasq5.nosp@m.m@um.nosp@m.syste.nosp@m.m.ed.nosp@m.u)
Date
2024-4-28

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( AStarPlannerTests ,
DoesNotLeak  )

Check that AStar doesn't leak any memory.

Author
Kai Shafe (kasq5.nosp@m.m@um.nosp@m.syste.nosp@m.m.ed.nosp@m.u)
Date
2024-04-28
79{
80 // Create a new AStar object.
82 // Delete object.
83 delete pAStar;
84 // Point to null.
85 pAStar = nullptr;
86}
Implements the A* (ASTAR) algorithm with the ability to plan paths around obstacles and provide path ...
Definition AStar.h:42

◆ TEST_F() [2/11]

TEST_F ( AStarPlannerTests ,
Leaks  )

This should fail when the –check_for_leaks command line flag is specified.

Author
Kai Shafe (kasq5.nosp@m.m@um.nosp@m.syste.nosp@m.m.ed.nosp@m.u)
Date
2024-04-28
96{
97 // Create a new AStar object.
99 EXPECT_TRUE(pAStar != nullptr);
100}

◆ TEST_F() [3/11]

TEST_F ( AStarPlannerTests ,
PlanAvoidancePathWaypoints  )

Test AStar path planning functionality with Waypoints.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-03-05
110{
111 // Create a new AStar object.
112 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
113
114 size_t siTestValuesLength = 8;
115
116 // Create start coordinate for AStar.
117 const double dEastingStart = 608120.0;
118 const double dNorthingStart = 4201140.0;
119 const geoops::Waypoint stStart = geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart, 15));
120
121 // Create goal coordinates for AStar.
122 const geoops::Waypoint aGoalCoordinates[siTestValuesLength] = {
123 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15)), // N
124 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart, 15)), // E
125 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15)), // S
126 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart, 15)), // W
127 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15)), // NE
128 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15)), // SE
129 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15)), // SW
130 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15)) // NW
131 };
132
133 // Compare output paths with expected paths.
134 for (size_t siIter = 0; siIter < siTestValuesLength; siIter++)
135 {
136 // Generate a path for this goal.
137 std::vector<geoops::Waypoint> vReturnedPath = pAStar->PlanAvoidancePath(stStart, aGoalCoordinates[siIter]);
138
139 // Validate that each node is separated by a valid distance.
140 // (no more than a node size difference between each coordinate value).
141 for (size_t siPathIter = 1; siPathIter < vReturnedPath.size(); siPathIter++)
142 {
143 bool bValidNodeDistance =
144 std::abs(vReturnedPath[siPathIter - 1].GetUTMCoordinate().dEasting - vReturnedPath[siPathIter].GetUTMCoordinate().dEasting) <= constants::ASTAR_NODE_SIZE;
145 bValidNodeDistance = bValidNodeDistance && std::abs(vReturnedPath[siPathIter - 1].GetUTMCoordinate().dNorthing -
146 vReturnedPath[siPathIter].GetUTMCoordinate().dNorthing) <= constants::ASTAR_NODE_SIZE;
147
148 EXPECT_TRUE(bValidNodeDistance);
149 }
150
151 // Validate start coordinate.
152 EXPECT_NEAR(stStart.GetUTMCoordinate().dEasting, vReturnedPath[0].GetUTMCoordinate().dEasting, 0.1);
153 EXPECT_NEAR(stStart.GetUTMCoordinate().dNorthing, vReturnedPath[0].GetUTMCoordinate().dNorthing, 0.1);
154
155 // Validate end coordinate.
156 EXPECT_NEAR(aGoalCoordinates[siIter].GetUTMCoordinate().dEasting, vReturnedPath.back().GetUTMCoordinate().dEasting, 0.1);
157 EXPECT_NEAR(aGoalCoordinates[siIter].GetUTMCoordinate().dNorthing, vReturnedPath.back().GetUTMCoordinate().dNorthing, 0.1);
158 }
159}
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:211
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:423
const geoops::UTMCoordinate & GetUTMCoordinate() const
Accessor for the geoops::UTMCoordinate member variable.
Definition GeospatialOperations.hpp:508
Here is the call graph for this function:

◆ TEST_F() [4/11]

TEST_F ( AStarPlannerTests ,
PlanAvoidancePathUTMCoordinates  )

Test AStar path planning functionality.

Author
Kai Shafe (kasq5.nosp@m.m@um.nosp@m.syste.nosp@m.m.ed.nosp@m.u)
Date
2024-04-28
169{
170 // Create a new AStar object.
171 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
172
173 size_t siTestValuesLength = 8;
174
175 // Create start coordinate for AStar.
176 const double dEastingStart = 608120.0;
177 const double dNorthingStart = 4201140.0;
178 const geoops::UTMCoordinate stStart = geoops::UTMCoordinate(dEastingStart, dNorthingStart, 15);
179
180 // Create goal coordinates for AStar.
181 const geoops::UTMCoordinate aGoalCoordinates[siTestValuesLength] = {
182 geoops::UTMCoordinate(dEastingStart, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15), // N
183 geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart, 15), // E
184 geoops::UTMCoordinate(dEastingStart, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15), // S
185 geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart, 15), // W
186 geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15), // NE
187 geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15), // SE
188 geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15), // SW
189 geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15) // NW
190 };
191
192 // Compare output paths with expected paths.
193 for (size_t siIter = 0; siIter < siTestValuesLength; siIter++)
194 {
195 // Generate a path for this goal.
196 std::vector<geoops::Waypoint> vReturnedPath = pAStar->PlanAvoidancePath(stStart, aGoalCoordinates[siIter]);
197
198 // Validate that each node is separated by a valid distance.
199 // (no more than a node size difference between each coordinate value).
200 for (size_t siPathIter = 1; siPathIter < vReturnedPath.size(); siPathIter++)
201 {
202 bool bValidNodeDistance =
203 std::abs(vReturnedPath[siPathIter - 1].GetUTMCoordinate().dEasting - vReturnedPath[siPathIter].GetUTMCoordinate().dEasting) <= constants::ASTAR_NODE_SIZE;
204 bValidNodeDistance = bValidNodeDistance && std::abs(vReturnedPath[siPathIter - 1].GetUTMCoordinate().dNorthing -
205 vReturnedPath[siPathIter].GetUTMCoordinate().dNorthing) <= constants::ASTAR_NODE_SIZE;
206
207 EXPECT_TRUE(bValidNodeDistance);
208 }
209
210 // Validate start coordinate.
211 EXPECT_NEAR(stStart.dEasting, vReturnedPath[0].GetUTMCoordinate().dEasting, 0.1);
212 EXPECT_NEAR(stStart.dNorthing, vReturnedPath[0].GetUTMCoordinate().dNorthing, 0.1);
213
214 // Validate end coordinate.
215 EXPECT_NEAR(aGoalCoordinates[siIter].dEasting, vReturnedPath.back().GetUTMCoordinate().dEasting, 0.1);
216 EXPECT_NEAR(aGoalCoordinates[siIter].dNorthing, vReturnedPath.back().GetUTMCoordinate().dNorthing, 0.1);
217 }
218}

◆ TEST_F() [5/11]

TEST_F ( AStarPlannerTests ,
PlanAvoidancePathGPSCoordinates  )

Test AStar path planning functionality with GPSCoordinates.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-03-05
228{
229 // Create a new AStar object.
230 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
231
232 size_t siTestValuesLength = 8;
233
234 // Create start coordinate for AStar.
235 const double dEastingStart = 608120.0;
236 const double dNorthingStart = 4201140.0;
237 const geoops::GPSCoordinate stStart = geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart, 15)).GetGPSCoordinate();
238
239 // Create goal coordinates for AStar.
240 const geoops::GPSCoordinate aGoalCoordinates[siTestValuesLength] = {
241 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15)).GetGPSCoordinate(), // N
242 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart, 15)).GetGPSCoordinate(), // E
243 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15)).GetGPSCoordinate(), // S
244 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart, 15)).GetGPSCoordinate(), // W
245 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15))
246 .GetGPSCoordinate(), // NE
247 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15))
248 .GetGPSCoordinate(), // SE
249 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart - constants::ASTAR_MAX_SEARCH_GRID, 15))
250 .GetGPSCoordinate(), // SW
251 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID, 15))
252 .GetGPSCoordinate() // NW
253 };
254
255 // Compare output paths with expected paths.
256 for (size_t siIter = 0; siIter < siTestValuesLength; siIter++)
257 {
258 // Generate a path for this goal.
259 std::vector<geoops::Waypoint> vReturnedPath = pAStar->PlanAvoidancePath(stStart, aGoalCoordinates[siIter]);
260
261 // Validate that each node is separated by a valid distance.
262 // (no more than a node size difference between each coordinate value).
263 for (size_t siPathIter = 1; siPathIter < vReturnedPath.size(); siPathIter++)
264 {
265 bool bValidNodeDistance =
266 std::abs(vReturnedPath[siPathIter - 1].GetUTMCoordinate().dEasting - vReturnedPath[siPathIter].GetUTMCoordinate().dEasting) <= constants::ASTAR_NODE_SIZE;
267 bValidNodeDistance = bValidNodeDistance && std::abs(vReturnedPath[siPathIter - 1].GetUTMCoordinate().dNorthing -
268 vReturnedPath[siPathIter].GetUTMCoordinate().dNorthing) <= constants::ASTAR_NODE_SIZE;
269
270 EXPECT_TRUE(bValidNodeDistance);
271 }
272
273 // Validate start coordinate.
274 EXPECT_NEAR(stStart.dLatitude, vReturnedPath[0].GetGPSCoordinate().dLatitude, 0.1);
275 EXPECT_NEAR(stStart.dLongitude, vReturnedPath[0].GetGPSCoordinate().dLongitude, 0.1);
276
277 // Validate end coordinate.
278 EXPECT_NEAR(aGoalCoordinates[siIter].dLatitude, vReturnedPath.back().GetGPSCoordinate().dLatitude, 0.1);
279 EXPECT_NEAR(aGoalCoordinates[siIter].dLongitude, vReturnedPath.back().GetGPSCoordinate().dLongitude, 0.1);
280 }
281}
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:100
const geoops::GPSCoordinate & GetGPSCoordinate() const
Accessor for the geoops::GPSCoordinate member variable.
Definition GeospatialOperations.hpp:497
Here is the call graph for this function:

◆ TEST_F() [6/11]

TEST_F ( AStarPlannerTests ,
PlanAvoidancePathStartEndBlocked  )

Test AStar's ability to still plan a path when obstacles overlap the start and end coordinates. The start and end of the path will just shift around until they are no longer blocked.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-03-05
293{
294 // Create a new AStar object.
295 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
296
297 // Create start coordinate for AStar.
298 const double dEastingStart = 608120.0;
299 const double dNorthingStart = 4201140.0;
300 const geoops::UTMCoordinate stStart = geoops::UTMCoordinate(dEastingStart, dNorthingStart, 15);
301
302 // Create goal coordinates for AStar.
303 const geoops::UTMCoordinate stEnd(dEastingStart, dNorthingStart + 20, 15);
304
305 // Create obstacle for AStar initialization.
306 const geoops::UTMCoordinate stStartObstacleCenter = geoops::UTMCoordinate(dEastingStart, dNorthingStart - 1, 15);
307 const geoops::UTMCoordinate stEndObstacleCenter = geoops::UTMCoordinate(dEastingStart, dNorthingStart + 21, 15);
308 const double dObstacleSize = 3;
309 const geoops::Waypoint stObstacle1 = {stStartObstacleCenter, geoops::WaypointType::eObstacleWaypoint, dObstacleSize};
310 const geoops::Waypoint stObstacle2 = {stEndObstacleCenter, geoops::WaypointType::eObstacleWaypoint, dObstacleSize};
311
312 // Add obstacle to AStar.
313 pAStar->UpsertObstacleData(stObstacle1);
314 pAStar->UpsertObstacleData(stObstacle2);
315
316 // Generate a path for this goal.
317 std::vector<geoops::Waypoint> vReturnedPath = pAStar->PlanAvoidancePath(stStart, stEnd);
318
319 // Validate that the path has some points.
320 EXPECT_FALSE(vReturnedPath.empty());
321}

◆ TEST_F() [7/11]

TEST_F ( AStarPlannerTests ,
PlanAvoidancePathCancel  )

Test AStar path planning cancellation feature.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-03-05
331{
332 // Create a new AStar object.
333 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
334 size_t siTestValuesLength = 8;
335
336 // Create start coordinate for AStar.
337 const double dEastingStart = 608120.0;
338 const double dNorthingStart = 4201140.0;
339 const geoops::UTMCoordinate stStart = geoops::UTMCoordinate(dEastingStart, dNorthingStart, 15);
340
341 // Create goal coordinates for AStar.
342 const geoops::UTMCoordinate stEnd(dEastingStart - constants::ASTAR_MAX_SEARCH_GRID * 1000, dNorthingStart + constants::ASTAR_MAX_SEARCH_GRID * 1000, 15);
343
344 // Get and store start time.
345 auto tStartTime = std::chrono::high_resolution_clock::now();
346 // Start planning avoidance path in a separate thread.
347 std::thread tPathThread([&] { pAStar->PlanAvoidancePath(stStart, stEnd); });
348 // Sleep for a short time to allow the path to start generating.
349 std::this_thread::sleep_for(std::chrono::milliseconds(5));
350 // Cancel the path generation.
351 pAStar->CancelPathGeneration();
352 // Join the thread.
353 tPathThread.join();
354 // Get and store end time.
355 auto tEndTime = std::chrono::high_resolution_clock::now();
356
357 // Calculate the time difference.
358 std::chrono::duration<double> dElapsedTime = tEndTime - tStartTime;
359 // Check if the time difference is less than 1 second. If it doesn't cancel, it will take longer than 1 second.
360 EXPECT_LT(dElapsedTime.count(), 1);
361 // Make sure the path is empty.
362 EXPECT_TRUE(pAStar->GetPath().empty());
363}

◆ TEST_F() [8/11]

TEST_F ( AStarPlannerTests ,
ObstacleInitialization  )

Test AStar obstacle initialization.

Author
Kai Shafe (kasq5.nosp@m.m@um.nosp@m.syste.nosp@m.m.ed.nosp@m.u)
Date
2024-09-15
373{
374 // Create a new AStar object.
375 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
376
377 // Create obstacle for AStar initialization.
378 const geoops::UTMCoordinate stObstacleCenter = geoops::UTMCoordinate(608120, 4201140, 15);
379 const double dObstacleSize = 3 * constants::ASTAR_NODE_SIZE;
380 const geoops::Waypoint stObstacle = {stObstacleCenter, geoops::WaypointType::eObstacleWaypoint, dObstacleSize};
381
382 // Add obstacle to AStar.
383 pAStar->UpsertObstacleData(stObstacle);
384
385 // Validate obstacle exists within AStar.
386 std::vector<geoops::Waypoint> vReturnVector = pAStar->GetObstacleData();
387 EXPECT_NEAR(stObstacle.GetUTMCoordinate().dEasting, vReturnVector[0].GetUTMCoordinate().dEasting, 0.1);
388 EXPECT_NEAR(stObstacle.GetUTMCoordinate().dNorthing, vReturnVector[0].GetUTMCoordinate().dNorthing, 0.1);
389 EXPECT_NEAR(stObstacle.dRadius, vReturnVector[0].dRadius, 0.1);
390
391 // Create obstacle vector for AStar re-initialization.
392 std::vector<geoops::Waypoint> vObstacles;
393 const geoops::UTMCoordinate stObstacle2Center = geoops::UTMCoordinate(608100, 4201100, 15);
394 const double dObstacle2Size = 2 * constants::ASTAR_NODE_SIZE;
395 const geoops::Waypoint stObstacle2 = {stObstacle2Center, geoops::WaypointType::eObstacleWaypoint, dObstacle2Size};
396 vObstacles.emplace_back(stObstacle);
397 vObstacles.emplace_back(stObstacle2);
398
399 // Reset obstacles within AStar.
400 pAStar->UpsertObstacleData(vObstacles);
401
402 // Validate obstacles exist within AStar.
403 vReturnVector = pAStar->GetObstacleData();
404 size_t siVectorSize = vReturnVector.size();
405 for (size_t siCounter = 0; siCounter < siVectorSize; siCounter++)
406 {
407 EXPECT_NEAR(vObstacles[siCounter].GetUTMCoordinate().dEasting, vReturnVector[siCounter].GetUTMCoordinate().dEasting, 0.1);
408 EXPECT_NEAR(vObstacles[siCounter].GetUTMCoordinate().dNorthing, vReturnVector[siCounter].GetUTMCoordinate().dNorthing, 0.1);
409 EXPECT_NEAR(vObstacles[siCounter].dRadius, vReturnVector[siCounter].dRadius, 0.1);
410 }
411}
Here is the call graph for this function:

◆ TEST_F() [9/11]

TEST_F ( AStarPlannerTests ,
UpsertObstacleData  )

Test AStar obstacle data management functionality.

Author
GitHub Copilot
Date
2025-03-05
420{
421 // Create a new AStar object
422 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
423
424 // Test single Waypoint obstacle
425 const geoops::UTMCoordinate stObstacle1UTM(608120, 4201140, 15);
426 const geoops::Waypoint stObstacle1(stObstacle1UTM, geoops::WaypointType::eObstacleWaypoint, 3.0);
427 pAStar->UpsertObstacleData(stObstacle1);
428
429 // Verify single Waypoint was added
430 std::vector<geoops::Waypoint> vObstacles = pAStar->GetObstacleData();
431 ASSERT_EQ(vObstacles.size(), 1);
432 EXPECT_EQ(vObstacles[0], stObstacle1);
433
434 // Test duplicate Waypoint (should not be added)
435 pAStar->UpsertObstacleData(stObstacle1);
436 EXPECT_EQ(pAStar->GetObstacleData().size(), 1);
437
438 // Test single UTMCoordinate obstacle
439 const geoops::UTMCoordinate stObstacle2UTM(608140, 4201160, 15);
440 pAStar->UpsertObstacleData(stObstacle2UTM);
441 vObstacles = pAStar->GetObstacleData();
442 ASSERT_EQ(vObstacles.size(), 2);
443 EXPECT_EQ(vObstacles[1].GetUTMCoordinate(), stObstacle2UTM);
444
445 // Test single GPSCoordinate obstacle
446 const geoops::GPSCoordinate stObstacle3GPS(37.9513, -91.7850);
447 pAStar->UpsertObstacleData(stObstacle3GPS);
448 vObstacles = pAStar->GetObstacleData();
449 ASSERT_EQ(vObstacles.size(), 3);
450 EXPECT_NEAR(vObstacles[2].GetGPSCoordinate().dLatitude, stObstacle3GPS.dLatitude, 0.0001);
451 EXPECT_NEAR(vObstacles[2].GetGPSCoordinate().dLongitude, stObstacle3GPS.dLongitude, 0.0001);
452
453 // Clear obstacles and verify
454 pAStar->ClearObstacleData();
455 EXPECT_EQ(pAStar->GetObstacleData().size(), 0);
456
457 // Test vector of Waypoints
458 std::vector<geoops::Waypoint> vWaypointObstacles;
459 vWaypointObstacles.push_back(stObstacle1);
460 vWaypointObstacles.push_back(geoops::Waypoint(stObstacle2UTM));
461 pAStar->UpsertObstacleData(vWaypointObstacles);
462 EXPECT_EQ(pAStar->GetObstacleData().size(), 2);
463
464 // Test vector of UTMCoordinates
465 std::vector<geoops::UTMCoordinate> vUTMObstacles;
466 vUTMObstacles.push_back(stObstacle1UTM);
467 vUTMObstacles.push_back(stObstacle2UTM);
468 pAStar->ClearObstacleData();
469 pAStar->UpsertObstacleData(vUTMObstacles);
470 EXPECT_EQ(pAStar->GetObstacleData().size(), 2);
471
472 // Test vector of GPSCoordinates
473 std::vector<geoops::GPSCoordinate> vGPSObstacles;
474 vGPSObstacles.push_back(stObstacle3GPS);
475 vGPSObstacles.push_back(geoops::GPSCoordinate(37.9514, -91.7851));
476 pAStar->ClearObstacleData();
477 pAStar->UpsertObstacleData(vGPSObstacles);
478 EXPECT_EQ(pAStar->GetObstacleData().size(), 2);
479}

◆ TEST_F() [10/11]

TEST_F ( AStarPlannerTests ,
AvoidObstaclesWhilePathing  )

Test AStar path obstacle avoidance for cardinal and diagonal directions.

Author
Sam Nolte (samno.nosp@m.lte0.nosp@m.302@g.nosp@m.mail.nosp@m..com)
Date
2024-11-19
489{
490 // Create a new AStar object
491 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
492
493 // Start coordinate for AStar
494 const double dEastingStart = 608120.0;
495 const double dNorthingStart = 4201140.0;
496 const geoops::UTMCoordinate stStartCoordinate(dEastingStart, dNorthingStart, 15, true);
497
498 // Create goal coordinates for AStar
499 const std::vector<geoops::UTMCoordinate> vGoalCoordinates = {
500 geoops::UTMCoordinate(dEastingStart, dNorthingStart + 10, 15, true), // N
501 geoops::UTMCoordinate(dEastingStart + 10, dNorthingStart, 15, true), // E
502 geoops::UTMCoordinate(dEastingStart, dNorthingStart - 10, 15, true), // S
503 geoops::UTMCoordinate(dEastingStart - 10, dNorthingStart, 15, true), // W
504 geoops::UTMCoordinate(dEastingStart + 10, dNorthingStart + 10, 15, true), // NE
505 geoops::UTMCoordinate(dEastingStart + 10, dNorthingStart - 10, 15, true), // SE
506 geoops::UTMCoordinate(dEastingStart - 10, dNorthingStart - 10, 15, true), // SW
507 geoops::UTMCoordinate(dEastingStart - 10, dNorthingStart + 10, 15, true) // NW
508 };
509
510 // Create obstacle coordinates for AStar
511 const double dObstacleSize = 3 * constants::ASTAR_NODE_SIZE;
512 const std::vector<geoops::Waypoint> vObstacles = {
513 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart + 5, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // N
514 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + 5, dNorthingStart, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // E
515 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart, dNorthingStart - 5, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // S
516 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - 5, dNorthingStart, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // W
517 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + 5, dNorthingStart + 5, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // NE
518 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart + 5, dNorthingStart - 5, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // SE
519 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - 5, dNorthingStart - 5, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize), // SW
520 geoops::Waypoint(geoops::UTMCoordinate(dEastingStart - 5, dNorthingStart + 5, 15, true), geoops::WaypointType::eObstacleWaypoint, dObstacleSize) // NW
521 };
522
523 for (size_t siI = 0; siI < 8; siI++)
524 {
525 // Add obstacle to AStar
526 pAStar->ClearObstacleData();
527 pAStar->UpsertObstacleData(std::vector<geoops::Waypoint>{vObstacles[siI]});
528
529 // Get AStar path
530 std::vector<geoops::Waypoint> vReturnedPath = pAStar->PlanAvoidancePath(stStartCoordinate, vGoalCoordinates[siI]);
531
532 // Make sure AStar actually found a path
533 EXPECT_TRUE(vReturnedPath.size() != 0);
534
535 // Check for pathing through obstacles
536 for (size_t siJ = 0; siJ < vReturnedPath.size(); siJ++)
537 {
538 // Check to see if current coordinate is within obstacle bounds
539 EXPECT_FALSE(vReturnedPath[siJ].GetUTMCoordinate().dNorthing >= vObstacles[siI].GetUTMCoordinate().dNorthing - vObstacles[siI].dRadius &&
540 vReturnedPath[siJ].GetUTMCoordinate().dNorthing <= vObstacles[siI].GetUTMCoordinate().dNorthing + vObstacles[siI].dRadius &&
541 vReturnedPath[siJ].GetUTMCoordinate().dEasting >= vObstacles[siI].GetUTMCoordinate().dEasting - vObstacles[siI].dRadius &&
542 vReturnedPath[siJ].GetUTMCoordinate().dEasting <= vObstacles[siI].GetUTMCoordinate().dEasting + vObstacles[siI].dRadius);
543 }
544
545 // Make sure path hit goal point
546 EXPECT_NEAR(vGoalCoordinates[siI].dEasting, vReturnedPath.back().GetUTMCoordinate().dEasting, 0.1);
547 EXPECT_NEAR(vGoalCoordinates[siI].dNorthing, vReturnedPath.back().GetUTMCoordinate().dNorthing, 0.1);
548 }
549}

◆ TEST_F() [11/11]

TEST_F ( AStarPlannerTests ,
Maze  )

Tests to see if AStar can path through a maze which requires lots of doubling back.

Author
Sam Nolte (samno.nosp@m.lte0.nosp@m.302@g.nosp@m.mail.nosp@m..com)
Date
2025-04-04
559{
560 // Create a new AStar object
561 std::unique_ptr<pathplanners::AStar> pAStar = std::make_unique<pathplanners::AStar>();
562
563 // Start coordinate for AStar
564 const double dEastingStart = 50.0;
565 const double dNorthingStart = 50.0;
566 const geoops::UTMCoordinate stStartCoordinate(dEastingStart, dNorthingStart, 15, true);
567
568 // Create goal coordinates for AStar
569 const geoops::UTMCoordinate stGoalCoordinate = geoops::UTMCoordinate(dEastingStart, dNorthingStart + 10, 15, true);
570
571 // Create obstacle coordinates for AStar https://imgur.com/a/pWpyLAI
572 const std::vector<geoops::Waypoint> vObstacles = {
573 geoops::Waypoint(geoops::UTMCoordinate(50, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
574 geoops::Waypoint(geoops::UTMCoordinate(50.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
575 geoops::Waypoint(geoops::UTMCoordinate(51, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
576 geoops::Waypoint(geoops::UTMCoordinate(51.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
577 geoops::Waypoint(geoops::UTMCoordinate(52, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
578 geoops::Waypoint(geoops::UTMCoordinate(52.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
579 geoops::Waypoint(geoops::UTMCoordinate(53, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
580 geoops::Waypoint(geoops::UTMCoordinate(53.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
581 geoops::Waypoint(geoops::UTMCoordinate(53.5, 50, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
582 geoops::Waypoint(geoops::UTMCoordinate(53.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
583 geoops::Waypoint(geoops::UTMCoordinate(53.5, 51, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
584 geoops::Waypoint(geoops::UTMCoordinate(53.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
585 geoops::Waypoint(geoops::UTMCoordinate(53.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
586 geoops::Waypoint(geoops::UTMCoordinate(53.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
587 geoops::Waypoint(geoops::UTMCoordinate(53.5, 53, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
588 geoops::Waypoint(geoops::UTMCoordinate(53.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
589 geoops::Waypoint(geoops::UTMCoordinate(53.5, 54, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
590 geoops::Waypoint(geoops::UTMCoordinate(53.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
591 geoops::Waypoint(geoops::UTMCoordinate(53.5, 55, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
592 geoops::Waypoint(geoops::UTMCoordinate(53.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
593 geoops::Waypoint(geoops::UTMCoordinate(53.5, 56, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
594 geoops::Waypoint(geoops::UTMCoordinate(53.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
595 geoops::Waypoint(geoops::UTMCoordinate(53, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
596 geoops::Waypoint(geoops::UTMCoordinate(52.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
597 geoops::Waypoint(geoops::UTMCoordinate(52, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
598 geoops::Waypoint(geoops::UTMCoordinate(51.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
599 geoops::Waypoint(geoops::UTMCoordinate(51, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
600 geoops::Waypoint(geoops::UTMCoordinate(50.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
601 geoops::Waypoint(geoops::UTMCoordinate(49.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
602 geoops::Waypoint(geoops::UTMCoordinate(49, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
603 geoops::Waypoint(geoops::UTMCoordinate(48.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
604 geoops::Waypoint(geoops::UTMCoordinate(48, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
605 geoops::Waypoint(geoops::UTMCoordinate(47.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
606 geoops::Waypoint(geoops::UTMCoordinate(47, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
607 geoops::Waypoint(geoops::UTMCoordinate(46.5, 56.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
608 geoops::Waypoint(geoops::UTMCoordinate(46.5, 56, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
609 geoops::Waypoint(geoops::UTMCoordinate(46.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
610 geoops::Waypoint(geoops::UTMCoordinate(46.5, 55, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
611 geoops::Waypoint(geoops::UTMCoordinate(46.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
612 geoops::Waypoint(geoops::UTMCoordinate(46.5, 54, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
613 geoops::Waypoint(geoops::UTMCoordinate(46.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
614 geoops::Waypoint(geoops::UTMCoordinate(46.5, 53, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
615 geoops::Waypoint(geoops::UTMCoordinate(46.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
616 geoops::Waypoint(geoops::UTMCoordinate(46.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
617 geoops::Waypoint(geoops::UTMCoordinate(46.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
618 geoops::Waypoint(geoops::UTMCoordinate(46.5, 51, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
619 geoops::Waypoint(geoops::UTMCoordinate(46.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
620 geoops::Waypoint(geoops::UTMCoordinate(46.5, 50, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
621 geoops::Waypoint(geoops::UTMCoordinate(46.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
622 geoops::Waypoint(geoops::UTMCoordinate(47, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
623 geoops::Waypoint(geoops::UTMCoordinate(47.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
624 geoops::Waypoint(geoops::UTMCoordinate(48, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
625 geoops::Waypoint(geoops::UTMCoordinate(48.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
626 geoops::Waypoint(geoops::UTMCoordinate(49, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
627 geoops::Waypoint(geoops::UTMCoordinate(49.5, 49.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
628 geoops::Waypoint(geoops::UTMCoordinate(51.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
629 geoops::Waypoint(geoops::UTMCoordinate(52, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
630 geoops::Waypoint(geoops::UTMCoordinate(52.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
631 geoops::Waypoint(geoops::UTMCoordinate(52.5, 51, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
632 geoops::Waypoint(geoops::UTMCoordinate(52.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
633 geoops::Waypoint(geoops::UTMCoordinate(52.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
634 geoops::Waypoint(geoops::UTMCoordinate(52.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
635 geoops::Waypoint(geoops::UTMCoordinate(52.5, 53, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
636 geoops::Waypoint(geoops::UTMCoordinate(52.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
637 geoops::Waypoint(geoops::UTMCoordinate(52, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
638 geoops::Waypoint(geoops::UTMCoordinate(51.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
639 geoops::Waypoint(geoops::UTMCoordinate(51, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
640 geoops::Waypoint(geoops::UTMCoordinate(50.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
641 geoops::Waypoint(geoops::UTMCoordinate(50.5, 54, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
642 geoops::Waypoint(geoops::UTMCoordinate(50.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
643 geoops::Waypoint(geoops::UTMCoordinate(50.5, 55, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
644 geoops::Waypoint(geoops::UTMCoordinate(50.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
645 geoops::Waypoint(geoops::UTMCoordinate(50.5, 53, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
646 geoops::Waypoint(geoops::UTMCoordinate(50.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
647 geoops::Waypoint(geoops::UTMCoordinate(50, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
648 geoops::Waypoint(geoops::UTMCoordinate(49.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
649 geoops::Waypoint(geoops::UTMCoordinate(49.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
650 geoops::Waypoint(geoops::UTMCoordinate(49.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
651 geoops::Waypoint(geoops::UTMCoordinate(49, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
652 geoops::Waypoint(geoops::UTMCoordinate(48.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
653 geoops::Waypoint(geoops::UTMCoordinate(48.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
654 geoops::Waypoint(geoops::UTMCoordinate(48.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
655 geoops::Waypoint(geoops::UTMCoordinate(49.5, 53, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
656 geoops::Waypoint(geoops::UTMCoordinate(49.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
657 geoops::Waypoint(geoops::UTMCoordinate(49.5, 54, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
658 geoops::Waypoint(geoops::UTMCoordinate(49.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
659 geoops::Waypoint(geoops::UTMCoordinate(49, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
660 geoops::Waypoint(geoops::UTMCoordinate(48.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
661 geoops::Waypoint(geoops::UTMCoordinate(48.5, 55, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
662 geoops::Waypoint(geoops::UTMCoordinate(48.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
663 geoops::Waypoint(geoops::UTMCoordinate(48, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
664 geoops::Waypoint(geoops::UTMCoordinate(47.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
665 geoops::Waypoint(geoops::UTMCoordinate(49.5, 55, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
666 geoops::Waypoint(geoops::UTMCoordinate(49.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
667 geoops::Waypoint(geoops::UTMCoordinate(49.5, 56, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
668 geoops::Waypoint(geoops::UTMCoordinate(47.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
669 geoops::Waypoint(geoops::UTMCoordinate(47, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
670 geoops::Waypoint(geoops::UTMCoordinate(51.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
671 geoops::Waypoint(geoops::UTMCoordinate(51.5, 55, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
672 geoops::Waypoint(geoops::UTMCoordinate(51.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
673 geoops::Waypoint(geoops::UTMCoordinate(51, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
674 geoops::Waypoint(geoops::UTMCoordinate(52, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
675 geoops::Waypoint(geoops::UTMCoordinate(52.5, 55.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
676 geoops::Waypoint(geoops::UTMCoordinate(53, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
677 geoops::Waypoint(geoops::UTMCoordinate(52.5, 54.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
678 geoops::Waypoint(geoops::UTMCoordinate(49.5, 50, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
679 geoops::Waypoint(geoops::UTMCoordinate(49.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
680 geoops::Waypoint(geoops::UTMCoordinate(50, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
681 geoops::Waypoint(geoops::UTMCoordinate(50.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
682 geoops::Waypoint(geoops::UTMCoordinate(50.5, 51, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
683 geoops::Waypoint(geoops::UTMCoordinate(50.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
684 geoops::Waypoint(geoops::UTMCoordinate(51, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
685 geoops::Waypoint(geoops::UTMCoordinate(51.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
686 geoops::Waypoint(geoops::UTMCoordinate(51.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
687 geoops::Waypoint(geoops::UTMCoordinate(51.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
688 geoops::Waypoint(geoops::UTMCoordinate(49, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
689 geoops::Waypoint(geoops::UTMCoordinate(48.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
690 geoops::Waypoint(geoops::UTMCoordinate(48, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
691 geoops::Waypoint(geoops::UTMCoordinate(47.5, 50.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
692 geoops::Waypoint(geoops::UTMCoordinate(47.5, 51, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
693 geoops::Waypoint(geoops::UTMCoordinate(47.5, 51.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
694 geoops::Waypoint(geoops::UTMCoordinate(47.5, 52, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
695 geoops::Waypoint(geoops::UTMCoordinate(47.5, 52.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
696 geoops::Waypoint(geoops::UTMCoordinate(47.5, 53, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
697 geoops::Waypoint(geoops::UTMCoordinate(47.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
698 geoops::Waypoint(geoops::UTMCoordinate(48, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
699 geoops::Waypoint(geoops::UTMCoordinate(48.5, 53.5, 15, true), geoops::WaypointType::eObstacleWaypoint, 0.1),
700 };
701
702 // Add obstacle to AStar
703 pAStar->UpsertObstacleData(vObstacles);
704
705 // Make sure AStar paths
706 std::vector<geoops::Waypoint> vReturnedPath = pAStar->PlanAvoidancePath(stStartCoordinate, stGoalCoordinate);
707 EXPECT_TRUE(vReturnedPath.size() != 0);
708
709 // Make sure path hit goal point
710 EXPECT_NEAR(stGoalCoordinate.dEasting, vReturnedPath.back().GetUTMCoordinate().dEasting, 0.1);
711 EXPECT_NEAR(stGoalCoordinate.dNorthing, vReturnedPath.back().GetUTMCoordinate().dNorthing, 0.1);
712}