EasyFleet
A simple-by-default framework for multi-robot, multi-capability fleets built on ROS 2
Loading...
Searching...
No Matches
Capability< ActionServerT > Class Template Reference

Lifecycle node that advertises a single action as a "capability". More...

#include <capability.hpp>

Inheritance diagram for Capability< ActionServerT >:
CapabilityNodeBase

Public Types

using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
 Lifecycle transition result type shared with rclcpp_lifecycle.
using ActionServerBaseT = ActionServerBase<typename ActionServerT::ActionType>
 The ActionServerBase<...> specialization backing this capability.
Public Types inherited from CapabilityNodeBase
using SharedPtr = std::shared_ptr<CapabilityNodeBase>
 Shared pointer to a CapabilityNodeBase.
using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
 Lifecycle transition result type shared with rclcpp_lifecycle.

Public Member Functions

 Capability (const std::string &capability_name, const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
 Constructs the capability node.
ActionServerBaseT::SharedPtr get_action_server () const noexcept
 The action server backing this capability.
const std::string & get_capability_name () const noexcept override
 The capability identity field published on /capabilities and /capabilities_status.
const std::string & get_robot_name () const noexcept override
 This node's namespace, without the leading '/' (empty if none), e.g.
const std::string & get_resolved_action_name () const noexcept
 Fully-qualified name of the action this capability exposes, e.g.
CallbackReturn configure_node () override
 Drive the underlying lifecycle node from UNCONFIGURED to INACTIVE.
CallbackReturn activate_node () override
 Drive the underlying lifecycle node from INACTIVE to ACTIVE.
CallbackReturn deactivate_node () override
 Drive the underlying lifecycle node from ACTIVE to INACTIVE.
CallbackReturn cleanup_node () override
 Drive the underlying lifecycle node from INACTIVE to UNCONFIGURED.
CallbackReturn shutdown_node () override
 Drive the underlying lifecycle node to FINALIZED, from whatever state it is currently in.
uint8_t get_current_state_id () const override
 The underlying lifecycle node's current state id.
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface () override
 So a Deployment can add the underlying node to its shared executor without knowing its concrete type.

Protected Member Functions

CallbackReturn on_configure (const rclcpp_lifecycle::State &previous_state) override
 Reads capabilities_file and configures the contained ActionServerT.
CallbackReturn on_activate (const rclcpp_lifecycle::State &previous_state) override
 Publishes the capability description and starts the status heartbeat.
CallbackReturn on_deactivate (const rclcpp_lifecycle::State &previous_state) override
 Stops the status heartbeat.
CallbackReturn on_cleanup (const rclcpp_lifecycle::State &previous_state) override
 Releases the resources acquired in on_configure().
CallbackReturn on_shutdown (const rclcpp_lifecycle::State &previous_state) override
 Stops the status heartbeat if still running.

Detailed Description

template<typename ActionServerT>
class easyfleet_core::Capability< ActionServerT >

Lifecycle node that advertises a single action as a "capability".

Capability<ActionServerT> is a rclcpp_lifecycle::LifecycleNode that:

  • owns an instance of ActionServerT (a concrete subclass of ActionServerBase<ActionType>, constructed as ActionServerT(rclcpp_lifecycle::LifecycleNode &, const std::string &)), exposed through its ActionServerBase<ActionType>::SharedPtr base type;
  • on on_activate, reads the file named by the capabilities_file string parameter and publishes it, together with its own runtime identity (namespace and fully-qualified action name), as an easyfleet_interfaces/CapabilityDescription on the reliable, transient-local /capabilities topic, so late subscribers still get it;
  • while active, publishes an easyfleet_interfaces/CapabilityStatus heartbeat once a second on /capabilities_status.

ActionServerT must publicly inherit ActionServerBase<SomeActionType> and be constructible as ActionServerT(LifecycleNode &, const std::string &).

The robot/capability/action_name identity published on both topics is resolved from this node's actual namespace at construction time, so a capability launched under namespace robot1 announces itself as such without any code changes – this is what lets a control center tell apart, say, robot1's and robot2's navigation capabilities.

Also implements CapabilityNodeBase, so a Robot/Deployment that doesn't know (and doesn't need to know) ActionServerT can still drive this instance's lifecycle and add its node to an executor – see capability_node_base.hpp and capability_factory.hpp.

Constructor & Destructor Documentation

◆ Capability()

template<typename ActionServerT>
Capability ( const std::string & capability_name,
const rclcpp::NodeOptions & options = rclcpp::NodeOptions() )
explicit

Constructs the capability node.

Parameters
capability_nameUsed as the node name, the action name of the contained action server, and the capability identity field.
optionsForwarded to the underlying LifecycleNode.

Member Function Documentation

◆ activate_node()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn activate_node ( )
overridevirtual

Drive the underlying lifecycle node from INACTIVE to ACTIVE.

Returns
The resulting lifecycle transition outcome.

Implements CapabilityNodeBase.

◆ cleanup_node()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn cleanup_node ( )
overridevirtual

Drive the underlying lifecycle node from INACTIVE to UNCONFIGURED.

Returns
The resulting lifecycle transition outcome.

Implements CapabilityNodeBase.

◆ configure_node()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn configure_node ( )
overridevirtual

Drive the underlying lifecycle node from UNCONFIGURED to INACTIVE.

Returns
The resulting lifecycle transition outcome.

Implements CapabilityNodeBase.

◆ deactivate_node()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn deactivate_node ( )
overridevirtual

Drive the underlying lifecycle node from ACTIVE to INACTIVE.

Returns
The resulting lifecycle transition outcome.

Implements CapabilityNodeBase.

◆ get_action_server()

template<typename ActionServerT>
Capability< ActionServerT >::ActionServerBaseT::SharedPtr get_action_server ( ) const
noexcept

The action server backing this capability.

Returns
The contained ActionServerT, through its ActionServerBaseT::SharedPtr base type.

◆ get_capability_name()

template<typename ActionServerT>
const std::string & get_capability_name ( ) const
overridevirtualnoexcept

The capability identity field published on /capabilities and /capabilities_status.

Returns
The capability identity field published on /capabilities and /capabilities_status.

Implements CapabilityNodeBase.

◆ get_current_state_id()

template<typename ActionServerT>
uint8_t get_current_state_id ( ) const
overridevirtual

The underlying lifecycle node's current state id.

Returns
The underlying lifecycle node's current state id (one of the lifecycle_msgs::msg::State::PRIMARY_STATE_* constants).

Implements CapabilityNodeBase.

◆ get_node_base_interface()

template<typename ActionServerT>
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface ( )
overridevirtual

So a Deployment can add the underlying node to its shared executor without knowing its concrete type.

Returns
The underlying node's base interface.

Implements CapabilityNodeBase.

◆ get_resolved_action_name()

template<typename ActionServerT>
const std::string & get_resolved_action_name ( ) const
noexcept

Fully-qualified name of the action this capability exposes, e.g.

"/robot1/navigation". This is the action_name identity field published on /capabilities and /capabilities_status.

Returns
The resolved, fully-qualified action name.

◆ get_robot_name()

template<typename ActionServerT>
const std::string & get_robot_name ( ) const
overridevirtualnoexcept

This node's namespace, without the leading '/' (empty if none), e.g.

"robot1". This is the robot identity field published on /capabilities and /capabilities_status.

Returns
This node's resolved robot name.

Implements CapabilityNodeBase.

◆ on_activate()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn on_activate ( const rclcpp_lifecycle::State & previous_state)
overrideprotected

Publishes the capability description and starts the status heartbeat.

Parameters
previous_stateState this node is transitioning from.
Returns
CallbackReturn::SUCCESS on success, CallbackReturn::FAILURE otherwise.

◆ on_cleanup()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn on_cleanup ( const rclcpp_lifecycle::State & previous_state)
overrideprotected

Releases the resources acquired in on_configure().

Parameters
previous_stateState this node is transitioning from.
Returns
CallbackReturn::SUCCESS on success, CallbackReturn::FAILURE otherwise.

◆ on_configure()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn on_configure ( const rclcpp_lifecycle::State & previous_state)
overrideprotected

Reads capabilities_file and configures the contained ActionServerT.

Parameters
previous_stateState this node is transitioning from.
Returns
CallbackReturn::SUCCESS on success, CallbackReturn::FAILURE otherwise.

◆ on_deactivate()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn on_deactivate ( const rclcpp_lifecycle::State & previous_state)
overrideprotected

Stops the status heartbeat.

Parameters
previous_stateState this node is transitioning from.
Returns
CallbackReturn::SUCCESS on success, CallbackReturn::FAILURE otherwise.

◆ on_shutdown()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn on_shutdown ( const rclcpp_lifecycle::State & previous_state)
overrideprotected

Stops the status heartbeat if still running.

Parameters
previous_stateState this node is transitioning from.
Returns
CallbackReturn::SUCCESS on success, CallbackReturn::FAILURE otherwise.

◆ shutdown_node()

template<typename ActionServerT>
Capability< ActionServerT >::CallbackReturn shutdown_node ( )
overridevirtual

Drive the underlying lifecycle node to FINALIZED, from whatever state it is currently in.

Returns
The resulting lifecycle transition outcome.

Implements CapabilityNodeBase.


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