|
|
bool | aStarSearch (const IMapNeighbors< T > &map, const Coordinate< T > &start, const Coordinate< T > &goal, std::unordered_map< Coordinate< T >, Coordinate< T >, std::hash< Coordinate< T > >, std::equal_to< Coordinate< T > >, AllocatorPSRAM< std::pair< const Coordinate< T >, Coordinate< T > > > > *cameFrom, std::unordered_map< Coordinate< T >, float, std::hash< Coordinate< T > >, std::equal_to< Coordinate< T > >, AllocatorPSRAM< std::pair< const Coordinate< T >, float > > > *outCostSoFar) |
| |
|
Path< Coordinate< T > > | reconstructPath (const std::unordered_map< Coordinate< T >, Coordinate< T >, std::hash< Coordinate< T > >, std::equal_to< Coordinate< T > >, AllocatorPSRAM< std::pair< const Coordinate< T >, Coordinate< T > > > > &cameFrom, const Coordinate< T > &start, const Coordinate< T > &goal) |
| |
template<typename T = DistanceM>
class tinyrobotics::AStar< T >
Flexible A* pathfinding algorithm for any map implementing IMap<T> and using Coordinate<T> nodes.
The AStar class implements the A* search algorithm for any map or graph that implements the IMap<T> interface. It uses Coordinate<T> as the node type and supports user-defined cost and validity callbacks for custom metrics, obstacle handling, and heuristics.
Features:
- Finds the optimal path from a start node to a goal node using A* search
- Works with any map implementing IMap<T> (e.g., grids, navigation graphs, road networks)
- Supports user-provided cost and validity callbacks for maximum flexibility
- Allows passing a user reference/context pointer to callbacks (for map data, etc.)
- Provides both full path reconstruction and efficient next-step queries
Usage:
- Create an AStar instance (optionally providing cost and validity callbacks).
- Call
findPath(map, start, goal) to get the optimal path as a Path<Coordinate<T>> object.
- Optionally, use
nextStep(map, start, goal) to get only the next move.
- Customize cost and heuristic logic via the cost callback (e.g., Euclidean, Manhattan, or domain-specific).
Example:
});
auto path = astar.
findPath(map, start, goal);
if (!path.empty()) {
}
Flexible A* pathfinding algorithm for any map implementing IMap<T> and using Coordinate<T> nodes.
Definition: AStar.h:52
Path< Coordinate< T > > findPath(const IMapNeighbors< T > &map, const Coordinate< T > &start, const Coordinate< T > &goal)
Definition: AStar.h:70
void setCostCallback(CostCallback cb)
Definition: AStar.h:61
A generic 3D coordinate class for robotics, navigation, and spatial calculations.
Definition: Coordinate.h:57
DistanceM distance(const Coordinate &other, DistanceUnit unit=DistanceUnit::M) const
Definition: Coordinate.h:79
This class is suitable for embedded and desktop robotics, navigation, and any application requiring flexible, efficient pathfinding.