19#ifndef EASYNAV_SYSTEM__SYSTEMNODE_HPP_
20#define EASYNAV_SYSTEM__SYSTEMNODE_HPP_
31#include "rclcpp/rclcpp.hpp"
32#include "rclcpp/macros.hpp"
33#include "rclcpp_lifecycle/lifecycle_node.hpp"
34#include "geometry_msgs/msg/twist.hpp"
35#include "geometry_msgs/msg/twist_stamped.hpp"
36#include "std_msgs/msg/string.hpp"
39#include "easynav_core/SystemActions.hpp"
43#include "easynav_recovery/RecoveryManagerNode.hpp"
58 rclcpp_lifecycle::LifecycleNode::SharedPtr
node_ptr;
76 using
CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
82 explicit
SystemNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
185 const std::vector<ParameterChange> & changes,
const std::string & reason)
override;
210 void clear_cmd_vel();
213 void forward_deprecated_use_cmd_vel_stamped();
216 void configure_robot_geometry();
219 bool check_system_parameters();
222 bool check_component_frequencies();
225 void cleanup_subnodes();
228 std::map<std::string, rclcpp_lifecycle::LifecycleNode::SharedPtr> get_all_nodes();
234 std::chrono::steady_clock::time_point activated_at_;
235 std::chrono::steady_clock::time_point next_clock_check_;
241 std::mutex rt_mutex_;
244 bool active_ {
false};
247 rclcpp::CallbackGroup::SharedPtr realtime_cbg_;
250 ControllerNode::SharedPtr controller_node_;
253 LocalizerNode::SharedPtr localizer_node_;
256 MapsManagerNode::SharedPtr maps_manager_node_;
259 PlannerNode::SharedPtr planner_node_;
262 SensorsNode::SharedPtr sensors_node_;
265 RecoveryManagerNode::SharedPtr recovery_node_;
268 std::atomic<bool> shutdown_requested_ {
false};
269 std::string shutdown_reason_;
270 mutable std::mutex shutdown_reason_mutex_;
273 struct ReconfigureRequest
275 std::vector<ParameterChange> changes;
276 bool restore {
false};
279 std::optional<ReconfigureRequest> pending_reconfigure_;
280 mutable std::mutex reconfigure_mutex_;
283 std::map<std::string, ParameterChange> original_parameters_;
286 rclcpp_lifecycle::LifecycleNode::SharedPtr find_node(
const std::string & name);
290 bool restart_with(
const std::vector<ParameterChange> & changes);
293 std::shared_ptr<NavState> nav_state_;
296 GoalManager::SharedPtr goal_manager_;
300 rclcpp::Publisher<std_msgs::msg::String>::SharedPtr navstate_pub_;
Declaration of the ControllerNode class, a ROS 2 lifecycle node for speed computation in Easy Navigat...
Declaration of the GoalManager class.
Declaration of the LocalizerNode class, a ROS 2 lifecycle node for localization tasks in Easy Navigat...
Declaration of the MapsManagerNode class, a ROS 2 lifecycle node for map handling in Easy Navigation.
A blackboard-like structure to hold the current state of the navigation system.
Declaration of the PlannerNode class, a ROS 2 lifecycle node for computing navigation paths in Easy N...
Declaration of the SafetySupervisor class.
Declaration of the SensorsNode class, a ROS 2 lifecycle node for sensor fusion tasks in Easy Navigati...
A generic, type-safe, thread-safe blackboard to hold runtime state.
Definition NavState.hpp:87
void hold_mission_progress(bool hold) override
SystemActions: while held, GoalManager takes no goal as reached.
Definition SystemNode.cpp:488
CallbackReturnT on_activate(const rclcpp_lifecycle::State &state)
Activate the node.
Definition SystemNode.cpp:281
std::vector< std::string > get_nodes_without_clock()
EasyNav nodes with use_sim_time whose ROS clock has not started (still at 0): no /clock reaches them,...
Definition SystemNode.cpp:718
CallbackReturnT on_configure(const rclcpp_lifecycle::State &state)
Configure the node.
Definition SystemNode.cpp:113
CallbackReturnT on_shutdown(const rclcpp_lifecycle::State &state)
Shutdown the node.
Definition SystemNode.cpp:433
std::map< std::string, SystemNodeInfo > get_system_nodes()
Get all system nodes managed by this coordinator.
Definition SystemNode.cpp:748
CallbackReturnT on_cleanup(const rclcpp_lifecycle::State &state)
Cleanup the node.
Definition SystemNode.cpp:409
const safety::SafetySupervisor & get_safety() const
Safety mode, memory lock and configuration hash, as of the last configure.
Definition SystemNode.hpp:191
void abort_mission(const std::string &reason) override
SystemActions: aborts the active mission, if any, telling its client why.
Definition SystemNode.cpp:479
std::string get_shutdown_reason() const
Why the shutdown was requested.
Definition SystemNode.cpp:472
std::shared_ptr< NavState > get_nav_state() const
Access to the shared navigation state (for testing and tools).
Definition SystemNode.hpp:155
rclcpp::CallbackGroup::SharedPtr get_real_time_cbg()
Get the real-time callback group.
Definition SystemNode.cpp:654
bool request_reconfigure(const std::vector< ParameterChange > &changes, const std::string &reason) override
SystemActions: pending until apply_pending_reconfigure(); rejected in safety mode.
Definition SystemNode.cpp:508
CallbackReturnT on_error(const rclcpp_lifecycle::State &state)
Handle lifecycle transition error.
Definition SystemNode.cpp:440
bool request_restore_parameters(const std::string &reason) override
SystemActions: pending until apply_pending_reconfigure(); rejected in safety mode.
Definition SystemNode.cpp:520
bool apply_pending_reconfigure()
Applies the pending reconfiguration request, if any, while Active: cycles through unconfigured,...
Definition SystemNode.cpp:549
SystemNode(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructor.
Definition SystemNode.cpp:46
std::string get_configuration_dump()
Every EasyNav parameter, one "node/parameter=value" per line, sorted.
Definition SystemNode.cpp:275
void system_cycle()
Non-real-time system cycle.
Definition SystemNode.cpp:689
void system_cycle_rt()
Real-time system cycle.
Definition SystemNode.cpp:660
static constexpr std::chrono::seconds kClockCheckPeriod
While Active, how often system_cycle() warns about get_nodes_without_clock().
Definition SystemNode.hpp:162
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn CallbackReturnT
Definition SystemNode.hpp:76
bool is_reconfigure_pending() const
Whether a reconfiguration is pending.
Definition SystemNode.cpp:531
bool is_shutdown_requested() const
Whether the recovery system asked EasyNav to terminate (request_shutdown()).
Definition SystemNode.hpp:169
void request_shutdown(const std::string &reason) override
SystemActions: records that EasyNav must terminate (see is_shutdown_requested()).
Definition SystemNode.cpp:496
CallbackReturnT on_deactivate(const rclcpp_lifecycle::State &state)
Deactivate the node.
Definition SystemNode.cpp:310
What SystemNode does for safety, kept out of the navigation logic.
Definition SafetySupervisor.hpp:79
Definition CircularBuffer.hpp:24
Definition PointPerception.hpp:51
Structure holding runtime information for a subnode.
Definition SystemNode.hpp:56
rclcpp::CallbackGroup::SharedPtr realtime_cbg
Associated real-time callback group.
Definition SystemNode.hpp:60
rclcpp_lifecycle::LifecycleNode::SharedPtr node_ptr
Shared pointer to the managed lifecycle node.
Definition SystemNode.hpp:58