18#ifndef EASYNAV_SYSTEM__GOALMANAGER_HPP_
19#define EASYNAV_SYSTEM__GOALMANAGER_HPP_
25#include "rclcpp/subscription.hpp"
26#include "rclcpp/publisher.hpp"
27#include "rclcpp/macros.hpp"
28#include "rclcpp_lifecycle/lifecycle_node.hpp"
29#include "easynav_interfaces/msg/navigation_control.hpp"
30#include "easynav_interfaces/msg/goal_manager_info.hpp"
31#include "geometry_msgs/msg/pose_stamped.hpp"
32#include "nav_msgs/msg/goals.hpp"
80 rclcpp_lifecycle::LifecycleNode::SharedPtr parent_node);
86 [[nodiscard]]
inline nav_msgs::msg::Goals
get_goals()
const {
return goals_;}
98 [[nodiscard]]
inline bool is_paused()
const {
return paused_;}
115 void set_error(
const std::string & reason);
146 const geometry_msgs::msg::Pose & current_pose,
147 const GoalTolerance & goal_tolerance
153 rclcpp_lifecycle::LifecycleNode::SharedPtr get_node()
const;
156 std::weak_ptr<rclcpp_lifecycle::LifecycleNode> parent_node_;
159 GoalTolerance goal_tolerance_ {};
162 nav_msgs::msg::Goals goals_;
165 rclcpp::Publisher<easynav_interfaces::msg::NavigationControl>::SharedPtr control_pub_;
168 rclcpp::Subscription<easynav_interfaces::msg::NavigationControl>::SharedPtr control_sub_;
171 rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr comanded_pose_sub_;
174 rclcpp::Publisher<easynav_interfaces::msg::GoalManagerInfo>::SharedPtr info_pub_;
177 easynav_interfaces::msg::NavigationControl::UniquePtr last_control_;
183 std::string current_client_id_;
186 bool allow_preempt_goal_ {
true};
189 rclcpp::Time nav_start_time_;
192 double update_frequency_ {20.0};
195 rclcpp::Duration update_period_ {0, 0};
198 rclcpp::Time last_update_time_;
201 bool first_update_ {
true};
205 const easynav_interfaces::msg::NavigationControl & msg,
206 easynav_interfaces::msg::NavigationControl & response);
209 void control_callback(easynav_interfaces::msg::NavigationControl::UniquePtr msg);
212 void comanded_pose_callback(geometry_msgs::msg::PoseStamped::UniquePtr msg);
215 void set_preempted();
222 bool paused_ {
false};
225 std::atomic<bool> progress_held_ {
false};
233 bool last_synced_paused_ {
false};
237 bool goals_synced_empty_ {
true};
240 easynav_interfaces::msg::GoalManagerInfo info_;
243 bool info_final_pending_ {
false};
246 void publish_final_info();
A blackboard-like structure to hold the current state of the navigation system.
void set_progress_held(bool held)
Holds or releases the mission's progress.
Definition GoalManager.cpp:349
void update(NavState &nav_state)
Update internal logic, including preemption and timeout checks.
Definition GoalManager.cpp:422
nav_msgs::msg::Goals get_goals() const
Get current goals.
Definition GoalManager.hpp:86
GoalManager(NavState &nav_state, rclcpp_lifecycle::LifecycleNode::SharedPtr parent_node)
Constructor.
Definition GoalManager.cpp:72
void set_finished()
Mark the current goal as successfully completed.
Definition GoalManager.cpp:327
State
Current internal goal state.
Definition GoalManager.hpp:54
@ IDLE
No active goal.
Definition GoalManager.hpp:55
void set_error(const std::string &reason)
Mark the system as in error state.
Definition GoalManager.cpp:364
void check_goals(const geometry_msgs::msg::Pose ¤t_pose, const GoalTolerance &goal_tolerance)
Check if the robot is currently at the first goal.
Definition GoalManager.cpp:547
void read_parameters(NavState &nav_state)
(Re)reads the parameters (on every configure: the GoalManager outlives cleanup).
Definition GoalManager.cpp:130
bool is_paused() const
Whether the current navigation (if any) is currently paused.
Definition GoalManager.hpp:98
State get_state() const
Get current internal goal state.
Definition GoalManager.hpp:92
void set_failed(const std::string &reason)
Mark the current goal as failed.
Definition GoalManager.cpp:386
bool is_progress_held() const
Whether the mission's progress is held (see set_progress_held()).
Definition GoalManager.hpp:126
A generic, type-safe, thread-safe blackboard to hold runtime state.
Definition NavState.hpp:87
Definition CircularBuffer.hpp:24
A structure to represent the goal tolerances.
Definition GoalManager.hpp:64
double yaw
Angular tolerance in radians for the yaw angle.
Definition GoalManager.hpp:70
double height
Positional tolerance for z axis in meters. Large default: height ignored.
Definition GoalManager.hpp:68
double position
Positional tolerance for x/y in meters.
Definition GoalManager.hpp:66