Easy Navigation
Loading...
Searching...
No Matches
ControllerNode.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 GNU General Public License v3.0.
5// See <http://www.gnu.org/licenses/> for details.
6//
7// Easy Navigation program is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
22
23#ifndef EASYNAV_CONTROLLER__CONTROLLERNODE_HPP_
24#define EASYNAV_CONTROLLER__CONTROLLERNODE_HPP_
25
26#include "rclcpp/macros.hpp"
27#include "rclcpp_lifecycle/lifecycle_node.hpp"
28#include "easynav_core/ControllerMethodBase.hpp"
29#include "pluginlib/class_loader.hpp"
30
31namespace easynav
32{
33
36
44
45class ControllerNode : public rclcpp_lifecycle::LifecycleNode
46{
47public:
48 RCLCPP_SMART_PTR_DEFINITIONS(ControllerNode)
49 using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
50
55 explicit ControllerNode(
56 const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
57
62
70 CallbackReturnT on_configure(const rclcpp_lifecycle::State & state);
71
79 CallbackReturnT on_activate(const rclcpp_lifecycle::State & state);
80
88 CallbackReturnT on_deactivate(const rclcpp_lifecycle::State & state);
89
97 CallbackReturnT on_cleanup(const rclcpp_lifecycle::State & state);
98
106 CallbackReturnT on_shutdown(const rclcpp_lifecycle::State & state);
107
115 CallbackReturnT on_error(const rclcpp_lifecycle::State & state);
116
125 rclcpp::CallbackGroup::SharedPtr get_real_time_cbg();
126
135 bool cycle_rt(std::shared_ptr<NavState> nav_state, bool trigger = false);
136
137private:
141 rclcpp::CallbackGroup::SharedPtr realtime_cbg_;
142
148 std::shared_ptr<ControllerMethodBase> controller_method_ {nullptr};
149
155 const std::shared_ptr<const NavState> nav_state_;
156
163 std::unique_ptr<pluginlib::ClassLoader<easynav::ControllerMethodBase>> controller_loader_;
164};
165
166} // namespace easynav
167
168#endif // EASYNAV_CONTROLLER__CONTROLLERNODE_HPP_
CallbackReturnT on_activate(const rclcpp_lifecycle::State &state)
Activates the ControllerNode node.
Definition ControllerNode.cpp:129
CallbackReturnT on_configure(const rclcpp_lifecycle::State &state)
Configures the ControllerNode node.
Definition ControllerNode.cpp:83
CallbackReturnT on_shutdown(const rclcpp_lifecycle::State &state)
Shuts down the ControllerNode node.
Definition ControllerNode.cpp:152
CallbackReturnT on_cleanup(const rclcpp_lifecycle::State &state)
Cleans up the ControllerNode node.
Definition ControllerNode.cpp:145
ControllerNode(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs a ControllerNode lifecycle node with the specified options.
Definition ControllerNode.cpp:37
bool cycle_rt(std::shared_ptr< NavState > nav_state, bool trigger=false)
Executes one cycle of real-time controller logic.
Definition ControllerNode.cpp:172
rclcpp::CallbackGroup::SharedPtr get_real_time_cbg()
Returns the real-time callback group.
Definition ControllerNode.cpp:166
CallbackReturnT on_error(const rclcpp_lifecycle::State &state)
Handles errors in the ControllerNode node.
Definition ControllerNode.cpp:159
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn CallbackReturnT
Definition ControllerNode.hpp:49
CallbackReturnT on_deactivate(const rclcpp_lifecycle::State &state)
Deactivates the ControllerNode node.
Definition ControllerNode.cpp:137
A generic, type-safe, lock-free blackboard to hold runtime state.
Definition NavState.hpp:62
Definition RTTFBuffer.hpp:30
Definition PointPerception.hpp:56