19#ifndef EASYNAV_CONTROLLER__CONTROLLERNODE_HPP_
20#define EASYNAV_CONTROLLER__CONTROLLERNODE_HPP_
28#include "geometry_msgs/msg/twist.hpp"
29#include "geometry_msgs/msg/twist_stamped.hpp"
34#include "easynav_core/ControllerMethodBase.hpp"
35#include "easynav_core/RobotLimits.hpp"
36#include "easynav_core/SafetyChannel.hpp"
37#include "easynav_core/PluginSwitcher.hpp"
38#include "rclcpp/macros.hpp"
39#include "rclcpp_lifecycle/lifecycle_node.hpp"
75 using
CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
82 const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
192 void read_parameters();
195 void publish(const geometry_msgs::msg::TwistStamped & cmd);
201 bool check_cmd_timeout();
204 void apply_safety_channel(const SafetyChannelState & state);
206 RobotLimits robot_limits_;
207 SafetyChannelState safety_channel_;
208 std::set<
std::
string> configured_limits_;
209 mutable
std::mutex robot_limits_mutex_;
211 bool use_cmd_vel_stamped_ {
false};
212 rclcpp::Publisher<geometry_msgs::msg::TwistStamped>::SharedPtr vel_pub_stamped_;
213 rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr vel_pub_;
220 std::optional<rclcpp::Time> last_smoother_step_;
224 bool last_published_zero_ {
false};
229 rclcpp::CallbackGroup::SharedPtr realtime_cbg_;
238 PluginSwitcher<easynav::ControllerMethodBase> controller_;
245 const std::shared_ptr<const NavState> nav_state_;
Declaration of the CommandGuard class.
Declaration of the VelocityMux class.
Declaration of the VelocitySmoother class.
CallbackReturnT on_activate(const rclcpp_lifecycle::State &state)
Activates the ControllerNode node.
Definition ControllerNode.cpp:189
CallbackReturnT on_configure(const rclcpp_lifecycle::State &state)
Configures the ControllerNode node.
Definition ControllerNode.cpp:136
CallbackReturnT on_shutdown(const rclcpp_lifecycle::State &state)
Shuts down the ControllerNode node.
Definition ControllerNode.cpp:216
std::string get_loaded_controller() const
Alias of the loaded controller (its "controller_types" entry).
Definition ControllerNode.cpp:260
CallbackReturnT on_cleanup(const rclcpp_lifecycle::State &state)
Cleans up the ControllerNode node.
Definition ControllerNode.cpp:207
ControllerNode(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs a ControllerNode lifecycle node with the specified options.
Definition ControllerNode.cpp:72
bool cycle_rt(std::shared_ptr< NavState > nav_state, bool trigger=false)
Executes one cycle of real-time controller logic.
Definition ControllerNode.cpp:240
void publish_cmd_vel_rt(std::shared_ptr< NavState > nav_state)
Selects, smooths and publishes this RT cycle's velocity command.
Definition ControllerNode.cpp:267
rclcpp::CallbackGroup::SharedPtr get_real_time_cbg()
Returns the real-time callback group.
Definition ControllerNode.cpp:234
CallbackReturnT on_error(const rclcpp_lifecycle::State &state)
Handles errors in the ControllerNode node.
Definition ControllerNode.cpp:227
bool is_robot_limit_configured(const std::string &field) const override
Whether "robot_limits.<field>" was configured explicitly.
Definition ControllerNode.cpp:313
RobotLimits get_robot_limits() const override
Robot limits being enforced: the configured ones, cut down to the safety channel's safely limited spe...
Definition ControllerNode.cpp:306
void set_robot_limits(const RobotLimits &limits) override
Replaces the limits enforced until the next configure.
Definition ControllerNode.cpp:320
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn CallbackReturnT
Definition ControllerNode.hpp:75
CallbackReturnT on_deactivate(const rclcpp_lifecycle::State &state)
Deactivates the ControllerNode node.
Definition ControllerNode.cpp:199
A generic, type-safe, thread-safe blackboard to hold runtime state.
Definition NavState.hpp:87
Decides, every RT cycle, which velocity command is sent to the robot.
Definition VelocityMux.hpp:44
Brings the commanded velocity towards a target within the robot limits.
Definition VelocitySmoother.hpp:38
Keeps the velocity command sent to the robot from being stale or invalid.
Definition CommandGuard.hpp:51
Definition CircularBuffer.hpp:24
Definition PointPerception.hpp:51