Easy Navigation
Loading...
Searching...
No Matches
ControllerNode Class Reference

ROS 2 lifecycle node that manages calculating speeds for the Easy Navigation system. More...

#include <ControllerNode.hpp>

Inheritance diagram for ControllerNode:
Collaboration diagram for ControllerNode:

Public Types

using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn

Public Member Functions

 ControllerNode (const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
 Constructs a ControllerNode lifecycle node with the specified options.
bool cycle_rt (std::shared_ptr< NavState > nav_state, bool trigger=false)
 Executes one cycle of real-time controller logic.
std::string get_loaded_controller () const
 Alias of the loaded controller (its "controller_types" entry).
rclcpp::CallbackGroup::SharedPtr get_real_time_cbg ()
 Returns the real-time callback group.
RobotLimits get_robot_limits () const override
 Robot limits being enforced: the configured ones, cut down to the safety channel's safely limited speed, if any.
bool is_robot_limit_configured (const std::string &field) const override
 Whether "robot_limits.<field>" was configured explicitly.
CallbackReturnT on_activate (const rclcpp_lifecycle::State &state)
 Activates the ControllerNode node.
CallbackReturnT on_cleanup (const rclcpp_lifecycle::State &state)
 Cleans up the ControllerNode node.
CallbackReturnT on_configure (const rclcpp_lifecycle::State &state)
 Configures the ControllerNode node.
CallbackReturnT on_deactivate (const rclcpp_lifecycle::State &state)
 Deactivates the ControllerNode node.
CallbackReturnT on_error (const rclcpp_lifecycle::State &state)
 Handles errors in the ControllerNode node.
CallbackReturnT on_shutdown (const rclcpp_lifecycle::State &state)
 Shuts down the ControllerNode node.
void publish_cmd_vel_rt (std::shared_ptr< NavState > nav_state)
 Selects, smooths and publishes this RT cycle's velocity command.
void set_robot_limits (const RobotLimits &limits) override
 Replaces the limits enforced until the next configure.
 ~ControllerNode ()
 Destroys the ControllerNode object.

Detailed Description

ROS 2 lifecycle node that manages calculating speeds for the Easy Navigation system.

This node provides the interface between the controller module in EasyNav and the ROS 2 ecosystem. It handles lifecycle transitions, real-time scheduling of periodic tasks, and parameter setup.

It is also the single point where the velocity command leaves EasyNav:

  • it owns the robot limits ("robot_limits.*"), which controller plugins query through ControllerMethodBase::get_robot_limits();
  • every RT cycle, publish_cmd_vel_rt() selects the command (VelocityMux: override > takeover > pause > controller), smooths it within those limits (except an override) and publishes it on "cmd_vel" (or "cmd_vel_stamped", see "use_cmd_vel_stamped");
  • on deactivation or shutdown, it brakes within the deceleration limits and ends by publishing an exact zero.

safety::CommandGuard keeps the command from being stale or invalid ("cmd_timeout", "cmd_vel_keepalive_period", non-finite commands, "diagnostics.cmd_vel").

The safety channel's state in NavState ("safety_status", see SafetyChannelState) is applied every RT cycle: zero during a protective stop, and the robot limits cut down to its safely limited speed.

Member Typedef Documentation

◆ CallbackReturnT

using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn

Constructor & Destructor Documentation

◆ ControllerNode()

ControllerNode ( const rclcpp::NodeOptions & options = rclcpp::NodeOptions())
explicit

Constructs a ControllerNode lifecycle node with the specified options.

Parameters
optionsNode options to configure the ControllerNode node.

◆ ~ControllerNode()

Destroys the ControllerNode object.

Member Function Documentation

◆ cycle_rt()

bool cycle_rt ( std::shared_ptr< NavState > nav_state,
bool trigger = false )

Executes one cycle of real-time controller logic.

This method is invoked periodically by a high-priority timer and is expected to compute control commands based on the current navigation state and input data.

Parameters
nav_stateShared pointer to the navigation state structure.
Returns
Bool value to indicate if trigger subsequent processes

◆ get_loaded_controller()

std::string get_loaded_controller ( ) const

Alias of the loaded controller (its "controller_types" entry).

Returns
The alias, or an empty string if no controller is loaded.

◆ get_real_time_cbg()

rclcpp::CallbackGroup::SharedPtr get_real_time_cbg ( )

Returns the real-time callback group.

This callback group can be used to assign callbacks that require low latency or have real-time constraints.

Returns
Shared pointer to the real-time callback group.

◆ get_robot_limits()

RobotLimits get_robot_limits ( ) const
override

Robot limits being enforced: the configured ones, cut down to the safety channel's safely limited speed, if any.

◆ is_robot_limit_configured()

bool is_robot_limit_configured ( const std::string & field) const
override

Whether "robot_limits.<field>" was configured explicitly.

◆ on_activate()

CallbackReturnT on_activate ( const rclcpp_lifecycle::State & state)

Activates the ControllerNode node.

This starts periodic navigation control cycles.

Parameters
stateThe current lifecycle state.
Returns
CallbackReturnT::SUCCESS if activation is successful.

◆ on_cleanup()

CallbackReturnT on_cleanup ( const rclcpp_lifecycle::State & state)

Cleans up the ControllerNode node.

Releases resources and resets the internal state.

Parameters
stateThe current lifecycle state.
Returns
CallbackReturnT::SUCCESS indicating cleanup is complete.

◆ on_configure()

CallbackReturnT on_configure ( const rclcpp_lifecycle::State & state)

Configures the ControllerNode node.

This is typically where parameters and interfaces are declared.

Parameters
stateThe current lifecycle state.
Returns
CallbackReturnT::SUCCESS if configuration is successful.

◆ on_deactivate()

CallbackReturnT on_deactivate ( const rclcpp_lifecycle::State & state)

Deactivates the ControllerNode node.

Control loops are stopped and interfaces are disabled.

Parameters
stateThe current lifecycle state.
Returns
CallbackReturnT::SUCCESS if deactivation is successful.

◆ on_error()

CallbackReturnT on_error ( const rclcpp_lifecycle::State & state)

Handles errors in the ControllerNode node.

This is called when a failure occurs during a lifecycle transition.

Parameters
stateThe current lifecycle state.
Returns
CallbackReturnT::SUCCESS indicating error handling is complete.

◆ on_shutdown()

CallbackReturnT on_shutdown ( const rclcpp_lifecycle::State & state)

Shuts down the ControllerNode node.

Called on final shutdown of the node's lifecycle.

Parameters
stateThe current lifecycle state.
Returns
CallbackReturnT::SUCCESS indicating shutdown is complete.

◆ publish_cmd_vel_rt()

void publish_cmd_vel_rt ( std::shared_ptr< NavState > nav_state)

Selects, smooths and publishes this RT cycle's velocity command.

VelocityMux picks, by priority, among the commands proposed this cycle (see velocity_command): zero during a protective stop, an override (published as is), a takeover, zero while paused, or the controller's. Publishes when a new command was proposed, or while the smoother is still ramping towards the last one.

Parameters
nav_stateShared navigation state.

◆ set_robot_limits()

void set_robot_limits ( const RobotLimits & limits)
override

Replaces the limits enforced until the next configure.


The documentation for this class was generated from the following files: