Easy Navigation
Loading...
Searching...
No Matches
PlannerNode.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
18
19#ifndef EASYNAV_PLANNER__PLANNERNODE_HPP_
20#define EASYNAV_PLANNER__PLANNERNODE_HPP_
21
22#include <optional>
23#include <memory>
24
25#include "rclcpp/macros.hpp"
26#include "rclcpp_lifecycle/lifecycle_node.hpp"
27#include "easynav_core/PlannerMethodBase.hpp"
28#include "easynav_core/PluginSwitcher.hpp"
29#include "nav_msgs/msg/path.hpp"
31
32namespace easynav
33{
34
44class PlannerNode : public rclcpp_lifecycle::LifecycleNode
45{
46public:
47 RCLCPP_SMART_PTR_DEFINITIONS(PlannerNode)
48 using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
49
54 explicit PlannerNode(
55 const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
56
58 ~PlannerNode();
59
65 CallbackReturnT on_configure(const rclcpp_lifecycle::State & state);
66
72 CallbackReturnT on_activate(const rclcpp_lifecycle::State & state);
73
79 CallbackReturnT on_deactivate(const rclcpp_lifecycle::State & state);
80
86 CallbackReturnT on_cleanup(const rclcpp_lifecycle::State & state);
87
93 CallbackReturnT on_shutdown(const rclcpp_lifecycle::State & state);
94
100 CallbackReturnT on_error(const rclcpp_lifecycle::State & state);
101
106 [[nodiscard]] nav_msgs::msg::Path get_path() const;
107
113 void cycle(std::shared_ptr<NavState> nav_state, bool trigger = false);
114
119 const rclcpp::Time get_last_rt_execution_ts() const;
120
125 const rclcpp::Time get_last_execution_ts() const;
126
127private:
129 void check_path(NavState & nav_state);
130
132 std::optional<bool> last_path_finite_;
133
136 PluginSwitcher<PlannerMethodBase> planner_;
137};
138
139} // namespace easynav
140
141#endif // EASYNAV_PLANNER__PLANNERNODE_HPP_
A blackboard-like structure to hold the current state of the navigation system.
A generic, type-safe, thread-safe blackboard to hold runtime state.
Definition NavState.hpp:87
void cycle(std::shared_ptr< NavState > nav_state, bool trigger=false)
Execute a non-real-time cycle.
Definition PlannerNode.cpp:103
CallbackReturnT on_activate(const rclcpp_lifecycle::State &state)
Activate the node.
Definition PlannerNode.cpp:66
CallbackReturnT on_configure(const rclcpp_lifecycle::State &state)
Configure the node.
Definition PlannerNode.cpp:60
CallbackReturnT on_shutdown(const rclcpp_lifecycle::State &state)
Shutdown the node.
Definition PlannerNode.cpp:89
const rclcpp::Time get_last_execution_ts() const
Get the timestamp of the last non-RT execution.
Definition PlannerNode.cpp:165
CallbackReturnT on_cleanup(const rclcpp_lifecycle::State &state)
Clean up the node.
Definition PlannerNode.cpp:82
nav_msgs::msg::Path get_path() const
Get the current planned path.
const rclcpp::Time get_last_rt_execution_ts() const
Get the timestamp of the last real-time execution.
Definition PlannerNode.cpp:156
CallbackReturnT on_error(const rclcpp_lifecycle::State &state)
Handle lifecycle transition errors.
Definition PlannerNode.cpp:96
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn CallbackReturnT
Definition PlannerNode.hpp:48
PlannerNode(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructor.
Definition PlannerNode.cpp:35
CallbackReturnT on_deactivate(const rclcpp_lifecycle::State &state)
Deactivate the node.
Definition PlannerNode.cpp:76
Definition CircularBuffer.hpp:24
Definition PointPerception.hpp:51