EasyNav Plugins
Loading...
Searching...
No Matches
AStarPlanner.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// This file is part of the project Easy Navigation (EasyNav in short)
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
18
19#ifndef EASYNAV_NAVMAP_PLANNER__NAVMAPPLANNER_HPP_
20#define EASYNAV_NAVMAP_PLANNER__NAVMAPPLANNER_HPP_
21
22#include <vector>
23#include <cstdint>
24#include <Eigen/Core>
25
26#include "nav_msgs/msg/path.hpp"
27
28#include "easynav_core/PlannerMethodBase.hpp"
29#include "navmap_core/NavMap.hpp"
30#include "easynav_common/types/NavState.hpp"
31
32namespace easynav
33{
34namespace navmap
35{
36
42{
43public:
49 explicit AStarPlanner();
50
59 virtual void on_initialize() override;
60
68 void update(NavState & nav_state) override;
69
70protected:
71 double cost_factor_;
73 double cost_axial_;
75 std::string layer_name_;
76 bool continuous_replan_ {true};
77 nav_msgs::msg::Path current_path_;
78 geometry_msgs::msg::Pose current_goal_;
79
81 rclcpp::Publisher<nav_msgs::msg::Path>::SharedPtr path_pub_;
82
84 std::vector<Eigen::Vector3f> centroids_;
85
87 std::vector<std::uint8_t> occ_;
88
90 std::vector<double> g_;
91 std::vector<::navmap::NavCelId> parent_;
92
101 void ensure_graph_cache(const ::navmap::NavMap & map);
102
124 nav_msgs::msg::Path path_smoother(
125 const nav_msgs::msg::Path & in_path,
126 const ::navmap::NavMap & navmap,
127 int iterations = 5,
128 float alpha = 0.4f,
129 float corner_keep_deg = 0.0f);
130
145 std::vector<geometry_msgs::msg::Pose> a_star_path(
146 const ::navmap::NavMap & map,
147 const geometry_msgs::msg::Pose & start,
148 const geometry_msgs::msg::Pose & goal);
149};
150
151} // namespace navmap
152
153} // namespace easynav
154
155#endif // EASYNAV_NAVMAP_PLANNER__NAVMAPPLANNER_HPP_
std::vector< Eigen::Vector3f > centroids_
Cached centroids for each NavCel (same indexing as navmap::NavMap::navcels).
Definition AStarPlanner.hpp:84
void ensure_graph_cache(const ::navmap::NavMap &map)
Ensure internal caches (centroids and A* buffers) are sized for the given map.
Definition AStarPlanner.cpp:285
void update(NavState &nav_state) override
Executes a planning cycle using the current navigation state.
Definition AStarPlanner.cpp:77
AStarPlanner()
Default constructor.
Definition AStarPlanner.cpp:50
bool continuous_replan_
Whether to replan the path at control frequency.
Definition AStarPlanner.hpp:76
double cost_axial_
Cost multiplier for axial (horizontal/vertical) moves.
Definition AStarPlanner.hpp:73
nav_msgs::msg::Path path_smoother(const nav_msgs::msg::Path &in_path, const ::navmap::NavMap &navmap, int iterations=5, float alpha=0.4f, float corner_keep_deg=0.0f)
Smooth a Path in XY while keeping every waypoint inside its original NavCel.
Definition AStarPlanner.cpp:135
std::vector< geometry_msgs::msg::Pose > a_star_path(const ::navmap::NavMap &map, const geometry_msgs::msg::Pose &start, const geometry_msgs::msg::Pose &goal)
Internal A* path planning routine.
Definition AStarPlanner.cpp:321
std::string layer_name_
Definition AStarPlanner.hpp:75
double cost_factor_
Scaling factor applied to cell cost values.
Definition AStarPlanner.hpp:71
nav_msgs::msg::Path current_path_
Most recently computed path.
Definition AStarPlanner.hpp:77
std::vector<::navmap::NavCelId > parent_
Definition AStarPlanner.hpp:91
geometry_msgs::msg::Pose current_goal_
Current goal.
Definition AStarPlanner.hpp:78
std::vector< double > g_
Reusable buffers for A* search cost and parent links.
Definition AStarPlanner.hpp:90
double cost_diagonal_
Cost multiplier for diagonal moves.
Definition AStarPlanner.hpp:74
rclcpp::Publisher< nav_msgs::msg::Path >::SharedPtr path_pub_
Publisher for the computed navigation path (for visualization or monitoring).
Definition AStarPlanner.hpp:81
virtual void on_initialize() override
Initializes the planner.
Definition AStarPlanner.cpp:62
std::vector< std::uint8_t > occ_
Cached per-NavCel occupancy / cost values (0..255).
Definition AStarPlanner.hpp:87
double inflation_penalty_
Extra cost penalty for paths near inflated obstacles.
Definition AStarPlanner.hpp:72
Definition AMCLLocalizer.hpp:41
Provides a mapping for often used cost values.
Definition cost_values.hpp:41