Class AStarPlanner
Defined in File AStarPlanner.hpp
Inheritance Relationships
Base Type
public PlannerMethodBase
Class Documentation
A planner implementing the A* algorithm on a ::navmap::NavMap grid.
This class generates a collision-free path using A* search over a surface-based NavMap. It supports cost-based penalties and anisotropic movement costs.
Public Functions
Default constructor.
Initializes internal parameters and configuration values.
Initializes the planner.
Loads planner parameters, sets up ROS publishers, and prepares the NavMap-based planning environment.
- Throws:
std::runtime_error – if initialization fails.
Executes a planning cycle using the current navigation state.
Computes a path from the robot’s current pose to the goal using A*.
- Parameters:
nav_state – Current shared navigation state (input/output).
Protected Functions
Ensure internal caches (centroids and A* buffers) are sized for the given map.
This avoids reallocations on every planning call. Values in g_ and parent_ are reset for the current run.
- Parameters:
map – The NavMap for which caches must be valid.
Smooth a Path in XY while keeping every waypoint inside its original NavCel.
The algorithm performs several iterations of Laplacian smoothing on XY: p_i’ = (1 - alpha) * p_i + alpha * 0.5 * (p_{i-1} + p_{i+1}) For each i, the candidate point is clamped to the original triangle (NavCel) using closest-point-on-triangle, so it never leaves that NavCel. The final z’ is the triangle height at the resulting (x’, y’).
Endpoints are kept fixed. Optionally, points forming a sharp angle are also kept (see
corner_keep_deg).- Parameters:
in_path – Input nav_msgs::msg::Path (world coordinates).
navmap – The NavMap where the path lies on.
iterations – Number of smoothing iterations (>= 1). Default: 5.
alpha – Smoothing factor in (0, 0.5]. Default: 0.4.
corner_keep_deg – Angle threshold (degrees): if the interior angle at a point is below this value, the point is kept as an anchor. Set <= 0 to disable. Default: 0 (disabled).
- Returns:
nav_msgs::msg::Path Smoothed path, same frame_id and header stamp as input.
Internal A* path planning routine.
Computes a path on the given NavMap from the start pose to the goal pose.
Movement cost is influenced by:
The cost of each NavCel (retrieved from a layer).
Additional inflation penalties near obstacles.
- Parameters:
map – The NavMap to plan over.
start – The robot’s starting pose in world coordinates.
goal – The goal pose in world coordinates.
- Returns:
A vector of poses representing the planned path.
Protected Attributes
Scaling factor applied to cell cost values.
Extra cost penalty for paths near inflated obstacles.
Cost multiplier for axial (horizontal/vertical) moves.
Cost multiplier for diagonal moves.
Whether to replan the path at control frequency.
Most recently computed path.
Current goal.
Publisher for the computed navigation path (for visualization or monitoring).
Cached centroids for each NavCel (same indexing as ::navmap::NavMap::navcels).
Cached per-NavCel occupancy / cost values (0..255).
Reusable buffers for A* search cost and parent links.