TinyRobotics
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Dijkstra< T > Class Template Reference

Generic Dijkstra shortest path algorithm for graphs/maps with callback-based cost and validity. More...

#include <Dijkstra.h>

Public Types

using CostCallback = std::function< float(const Coordinate< T > &, const Coordinate< T > &, void *ref)>
 
using ValidCallback = std::function< bool(const Coordinate< T > &, void *ref)>
 

Public Member Functions

void setCostCallback (CostCallback cb)
 
void setValidCallback (ValidCallback cb)
 provide a callback to determine if a node is valid (e.g., not an obstacle)
 
void setReference (void *reference)
 
Path< Coordinate< T > > findPath (const IMapNeighbors< T > &map, const Coordinate< T > &start, const Coordinate< T > &goal)
 Finds the shortest path from start to goal.
 

Static Protected Member Functions

static float defaultCost (const Coordinate< T > &from, const Coordinate< T > &to, void *ref)
 
static bool defaultValid (const Coordinate< T > &node, void *ref)
 

Protected Attributes

CostCallback cost_cb = defaultCost
 
ValidCallback valid_cb = defaultValid
 
void * ref = this
 

Detailed Description

template<typename T = DistanceM>
class tinyrobotics::Dijkstra< T >

Generic Dijkstra shortest path algorithm for graphs/maps with callback-based cost and validity.

Template Parameters
MapTypeMust provide:
  • std::vector<Node> getNeighbors(const Node& node) const

Member Function Documentation

◆ findPath()

Path< Coordinate< T > > findPath ( const IMapNeighbors< T > &  map,
const Coordinate< T > &  start,
const Coordinate< T > &  goal 
)
inline

Finds the shortest path from start to goal.

Parameters
startThe starting node.
goalThe goal node.
Returns
Vector of nodes representing the path (empty if no path found).

◆ setCostCallback()

void setCostCallback ( CostCallback  cb)
inline

provide a callback to determine the cost of moving from one node to another

◆ setReference()

void setReference ( void *  reference)
inline

provide reference for callbacks (e.g., to access map data or other context)


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