13#include "../../handlers/LiDARHandler.h"
14#include "../../util/GeospatialOperations.hpp"
17#include <RoveComm/RoveComm.h>
18#include <RoveComm/RoveCommManifest.h>
23#include <unordered_map>
24#include <unordered_set>
56 double dGridResolution = 0.5,
57 double dHeuristicWeight = 1.5,
58 double dBetaBias = 1.0,
59 double dMinTravScore = 0.0,
60 int nDilationPasses = 2,
61 double dSafeTravScoreThreshold = 0.5,
62 int nMaxSpiralSearchRadius = 20,
63 size_t siMaxPlotPointsPerTile = 10,
64 double dPenaltyScalingFactor = 10.0,
65 double dPenaltyPower = 2.0,
66 double dPathWaypointTolerance = 0.5);
72 double dSearchRadius = 3.0,
73 double dMaxSearchTimeSeconds = 120.0,
74 double dCorridorPadding = 100.0);
111 double dTravScore = -1.0;
112 double dAltitude = 0.0;
113 int nClosestPointID = -1;
115 bool bInNorthernHemisphere =
true;
130 double dGCost = std::numeric_limits<double>::infinity();
147 return (stLeftHandSide.dGCost + stLeftHandSide.dHCost) > (stRightHandSide.dGCost + stRightHandSide.dHCost);
186 size_t operator()(
const TileKey& stKey)
const noexcept
189 return (std::hash<int>()(stKey.nX) << 16) ^ std::hash<int>()(stKey.nY);
203 bool operator()(
const TileKey& stLeftHandSide,
const TileKey& stRightHandSide)
const noexcept
206 return (stLeftHandSide.nX == stRightHandSide.nX) && (stLeftHandSide.nY == stRightHandSide.nY);
220 double EuclideanDistance(
double dEasting1,
double dNorthing1,
double dEasting2,
double dNorthing2)
const;
232 inline int GetGridIndex(
int nX,
int nY)
const {
return nY * m_nGridWidth + nX; }
246 nY = nIndex / m_nGridWidth;
247 nX = nIndex % m_nGridWidth;
257 [
this](
const rovecomm::RoveCommPacket<float>& stPacket,
const sockaddr_in& stdAddr)
262 if (stPacket.vData.size() > 0)
264 m_dMinTravScore =
static_cast<double>(stPacket.vData[0]);
267 LOG_NOTICE(logging::g_qSharedLogger,
268 "Incoming Packet: Setting GeoPlanner minimum travel score to {}. The tile cache has also been cleared.",
269 this->m_dMinTravScore);
279 const std::function<void(
const rovecomm::RoveCommPacket<float>&,
const sockaddr_in&)>
fnBetaBiasCallback =
280 [
this](
const rovecomm::RoveCommPacket<float>& stPacket,
const sockaddr_in& stdAddr)
285 if (stPacket.vData.size() > 0)
287 m_dBeta =
static_cast<double>(stPacket.vData[0]);
289 LOG_NOTICE(logging::g_qSharedLogger,
"Incoming Packet: Setting GeoPlanner beta bias to {}", this->m_dBeta);
299 double m_dGridResolution;
300 double m_dHeuristicWeight;
302 double m_dMinTravScore;
303 int m_nDilationPasses;
304 double m_dSafeTravScoreThreshold;
305 int m_nMaxSpiralSearchRadius;
306 size_t m_siMaxPlotPointsPerTile;
307 double m_dPenaltyScalingFactor;
308 double m_dPenaltyPower;
309 double m_dPathWaypointTolerance;
312 double m_dSearchRadius;
313 double m_dMaxSearchTimeSeconds;
314 double m_dCorridorPadding;
318 std::mutex m_muPathGenMutex;
321 double m_dGridOriginEasting;
322 double m_dGridOriginNorthing;
328 std::vector<GridCell> m_vCostmap;
331 std::priority_queue<PlannerState, std::vector<PlannerState>, PlannerStateCompare> m_pqOpenSetNextBest;
332 std::vector<int> m_vPredecessors;
333 std::vector<bool> m_vbClosedSet;
334 std::vector<double> m_vdGCosts;
337 std::unordered_map<TileKey, std::vector<LiDARHandler::PointRow>, TileKeyHash, TileKeyEqual>
The LiDARHandler class manages runtime queries against a LiDAR point cloud database for autonomy navi...
Definition LiDARHandler.h:40
This class implements a geospatial path planner that uses a discrete 2.5D Costmap and a fast Weighted...
Definition GeoPlanner.h:49
std::vector< geoops::Waypoint > ReconstructPath() const
Transforms the abstract 1D computational grid configurations logically backward to rebuild a continuo...
Definition GeoPlanner.cpp:589
double GetMinTravScore() const
Retrieves the actively configured minimum travel score parameter limit.
Definition GeoPlanner.cpp:255
void SetTileSize(double dTileSize)
Sets the dimensional size of database tiles mapped during planning.
Definition GeoPlanner.cpp:203
void SetMinTravScore(double dMinTravScore)
Sets the absolute minimum travel score required for a valid cell.
Definition GeoPlanner.cpp:216
const std::function< void(const rovecomm::RoveCommPacket< float > &, const sockaddr_in &)> fnMinTravScoreCallback
Callback function used to set the minimum travel score for path planning.
Definition GeoPlanner.h:256
double GetBetaBias() const
Retrieves the beta heuristic bias factor configured dynamically.
Definition GeoPlanner.cpp:268
~GeoPlanner()
Destroy the Geo Planner:: Geo Planner object.
Definition GeoPlanner.cpp:96
const std::function< void(const rovecomm::RoveCommPacket< float > &, const sockaddr_in &)> fnBetaBiasCallback
Callback function used to set the beta bias for travel scores in path planning.
Definition GeoPlanner.h:279
double EuclideanDistance(double dEasting1, double dNorthing1, double dEasting2, double dNorthing2) const
Calculates the standard 2D Euclidean distance between two geographic coordinates. This establishes ma...
Definition GeoPlanner.cpp:861
void UnloadLiDARTiles(double minX, double maxX, double minY, double maxY)
Unload tile LiDAR data.
Definition GeoPlanner.cpp:742
int FindNearestValidCell(int nStartIndex) const
Expands outward concentrically from a target grid cell to locate the nearest neighboring cell that co...
Definition GeoPlanner.cpp:776
int GetGridIndex(int nX, int nY) const
Inline helper to convert 2D grid coordinates to a 1D vector index.
Definition GeoPlanner.h:232
void CheckAndLoadTile(int nTileX, int nTileY)
Checks if a specific tile is loaded in the cache, and if not, fetches the relevant LiDAR point cloud ...
Definition GeoPlanner.cpp:645
bool PreloadCorridorAndBuildGrid(const geoops::UTMCoordinate &stStart, const geoops::UTMCoordinate &stEnd)
Calculates a bounding box based on Start and End coordinates, preloads LiDAR chunks,...
Definition GeoPlanner.cpp:285
void SearchAStar()
Actively runs a highly optimized Weighted A* pathfinding search upon the 1D Costmap grid utilizing ki...
Definition GeoPlanner.cpp:454
void FillGridHoles()
Performs morphological dilation on the costmap to fill in structural voids or gaps caused by sparse L...
Definition GeoPlanner.cpp:679
void SetBetaBias(double dBetaBias)
Sets the algorithm's penalty sensitivity bias multiplier.
Definition GeoPlanner.cpp:229
std::vector< geoops::Waypoint > PlanPath(LiDARHandler *pLiDARHandler, const geoops::UTMCoordinate &stStart, const geoops::UTMCoordinate &stEnd, double dSearchRadius=3.0, double dMaxSearchTimeSeconds=120.0, double dCorridorPadding=100.0)
Plan an optimal trajectory path from the start UTM to the end UTM coordinate utilizing a 2....
Definition GeoPlanner.cpp:116
double GetTileSize() const
Retrieves the currently configured database tile size constraint.
Definition GeoPlanner.cpp:242
void ClearGeoCache()
Explicitly zeroes and reclaims internal spatial database mapping arrays.
Definition GeoPlanner.cpp:188
void GetGridCoords(int nIndex, int &nX, int &nY) const
Inline helper to convert a 1D vector index back into 2D grid coordinates.
Definition GeoPlanner.h:244
This namespace stores classes, functions, and structs that are used to implement different path plann...
Definition AStar.cpp:30
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:211
Represents a single cell in our 2.5D discretized Costmap grid. This is used to aggregate sparse point...
Definition GeoPlanner.h:109
This struct is used to compare two PlannerState objects based on their cost to properly sort the prio...
Definition GeoPlanner.h:142
This struct represents the state of a node in the A* algorithm. Optimized to work with a flat 1D vect...
Definition GeoPlanner.h:127
This struct is used to compare two TileKey objects for equality after a hash collision is triggered.
Definition GeoPlanner.h:201
This struct is used to hash TileKey objects for use in unordered maps.
Definition GeoPlanner.h:184
This struct represents a tile key in the implicit graph representation. We divide the plan into a reg...
Definition GeoPlanner.h:159
bool operator==(const TileKey &stOther) const
Overridden operator equals for TileKey struct.
Definition GeoPlanner.h:174