TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Path< CoordinateT, AllocatorT > Class Template Reference

A simple path class that holds a sequence of waypoints. Each waypoint is e.g. a coordinate (e.g., x,y,z) that the robot should follow. The path can be used for navigation, motion planning, or trajectory execution. It provides methods to add waypoints. More...

#include <Path.h>

Public Member Functions

 Path ()=default
 Default constructor.
 
template<typename... Args>
 Path (const Args &... args)
 Construct a path from a variable number of waypoints.
 
 Path (const std::vector< CoordinateT > &waypoints)
 Construct a path from a vector of waypoints.
 
void addWaypoint (const CoordinateT &waypoint)
 Add a single waypoint to the path.
 
void addWaypoints (const std::vector< CoordinateT > &new_waypoints)
 Add multiple waypoints from a vector.
 
void addWaypoints ()
 Helper for variadic addWaypoints (base case)
 
template<typename First , typename... Rest>
void addWaypoints (const First &first, const Rest &... rest)
 Helper for variadic addWaypoints (recursive case)
 
void setWaypoints (const std::vector< CoordinateT > &new_waypoints)
 Replace all waypoints with a new vector.
 
bool setWaypoint (int pos, const CoordinateT &waypoint)
 Set a waypoint at a specific position.
 
std::vector< CoordinateT, AllocatorT > getWaypoints () const
 Get all waypoints as a vector.
 
std::optional< CoordinateT > getWaypoint (size_t index) const
 Get a waypoint by index (returns std::nullopt if out of bounds)
 
std::optional< CoordinateT > getLastWaypoint () const
 Get the last waypoint (returns std::nullopt if empty)
 
bool removeHead ()
 Remove the first waypoint in the path (e.g., after reaching it). Returns true if a waypoint was removed, false if the path was already empty.
 
CoordinateT & operator[] (size_t index)
 Non-const index operator.
 
const CoordinateT & operator[] (size_t index) const
 Const index operator.
 
size_t size () const
 Get the number of waypoints.
 
bool isEmpty () const
 Check if the path is empty.
 
void reverse ()
 Reverse the order of waypoints.
 
void clear ()
 Remove all waypoints.
 
float distance () const
 Calculate the total distance.
 

Protected Attributes

std::vector< CoordinateT, AllocatorT > waypoints
 

Detailed Description

template<typename CoordinateT = Coordinate<DistanceM>, typename AllocatorT = AllocatorPSRAM<CoordinateT>>
class tinyrobotics::Path< CoordinateT, AllocatorT >

A simple path class that holds a sequence of waypoints. Each waypoint is e.g. a coordinate (e.g., x,y,z) that the robot should follow. The path can be used for navigation, motion planning, or trajectory execution. It provides methods to add waypoints.

Template Parameters
TCoordinate e.g. GPSCoordinate, Coordinate, ScheduledWayPoint, WayPointAndSpeed etc.

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