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

A remote robot's capabilities, as seen and commanded from a mission script. More...

#include <robot_handle.hpp>

Public Member Functions

 RobotHandle (std::string name)
 Constructs a handle for the robot identified by name.
const std::string & name () const noexcept
 This robot's identity, as passed to the constructor.
bool has_capability (const std::string &capability_type) const
 True if this robot announced an active capability of this type (per the SimpleController's last discover_capabilities() pass).
template<typename ActionT>
void run_capability (const std::string &capability_type, const typename ActionT::Goal &goal=typename ActionT::Goal(), std::chrono::seconds timeout=easyfleet_mission_manager::kRunTimeout)
 Sends goal to capability_type and returns immediately – the counterpart to today's blocking easyfleet_mission_manager::run_capability<ActionT>().
void stop_capability (const std::string &capability_type)
 Asks capability_type to stop whatever it's doing, if anything.
bool is_capability_running (const std::string &capability_type) const
 Shorthand for capability_state(capability_type) == CapabilityState::RUNNING.
CapabilityState capability_state (const std::string &capability_type) const
 Current state of the last run_capability() call for this type (or IDLE if none has been made).
bool is_alive (const std::string &capability_type) const
 Whether a heartbeat has been seen recently on /capabilities_status for this capability – continuously tracked for the whole mission (not a one-off discovery-time snapshot the way today's CapabilityInfo::active is), so it reflects the current liveness of the capability's process, including one that dies mid-mission.
void print_capabilities () const
 Prints every discovered capability of this robot, like today's print_capability_info()/print_capability_summary_line() free functions.
const std::vector< easyfleet_mission_manager::CapabilityInfo > & capabilities () const noexcept
 Every capability this robot announced, as discovered – the full CapabilityInfo (type, action name, description JSON, active/busy state), not just a yes/no check like has_capability().

Friends

class FleetSession

Detailed Description

A remote robot's capabilities, as seen and commanded from a mission script.

The client-side counterpart to easyfleet_core::Robot (which hosts real capability nodes) – deliberately a different type, since a RobotHandle owns no nodes at all: it's a thin proxy over whatever this robot announced on /capabilities, discovered by the FleetSession it's added to (directly, or through whichever Controller-flavored class owns that session – see FleetSession's own doc comment for why RobotHandle depends on the shared session, not on any one controller type: it's meant to work the same under SimpleController, an LLMController, a PlanSys2Controller, or any other controller a user writes).

Everything here is non-blocking and observable, replacing the pattern every current mission script hand-rolls: raw std::thread objects for parallel robots, manual CapabilityClient null-checks at every call site, and manual StatusMarkerPublisher::set_status() calls at every transition (easy to forget – see refactor.md). run_capability() publishes that status text itself, automatically, for the life of the goal; a mission script using RobotHandle never touches StatusMarkerPublisher directly.

Usage:

easyfleet::RobotHandle robot_1("robot_1");
controller.add_robot(robot_1);
controller.discover_capabilities();
if (!robot_1.has_capability("navigation")) { ... }
robot_1.run_capability("navigation", "kitchen");
while (robot_1.is_capability_running("navigation")) {
controller.spin_some();
}
if (robot_1.capability_state("navigation") == easyfleet::CapabilityState::FAILED) { ... }
A remote robot's capabilities, as seen and commanded from a mission script.
Definition robot_handle.hpp:75
The plain, manual controller: a mission script decides everything by hand (which robot runs which cap...
Definition simple_controller.hpp:65
void discover_capabilities(std::chrono::milliseconds window=std::chrono::milliseconds(2500))
See FleetSession::discover_capabilities().
Definition simple_controller.hpp:92
void spin_some()
See FleetSession::spin_some().
Definition simple_controller.hpp:98
void add_robot(RobotHandle &robot)
Adds robot to this controller's session.
Definition simple_controller.hpp:71

Constructor & Destructor Documentation

◆ RobotHandle()

RobotHandle ( std::string name)
explicit

Constructs a handle for the robot identified by name.

Parameters
nameThis robot's identity, matching the robot identity field it announces on /capabilities (e.g. its ROS namespace).

Member Function Documentation

◆ capabilities()

const std::vector< easyfleet_mission_manager::CapabilityInfo > & capabilities ( ) const
noexcept

Every capability this robot announced, as discovered – the full CapabilityInfo (type, action name, description JSON, active/busy state), not just a yes/no check like has_capability().

Meant for code that needs to reason about what a robot can do, not just command a specific known capability by name – e.g. a controller that builds an LLM prompt describing every robot's capabilities, or generates a PDDL problem instance from them.

Returns
Every capability this robot announced, as discovered.

◆ capability_state()

CapabilityState capability_state ( const std::string & capability_type) const

Current state of the last run_capability() call for this type (or IDLE if none has been made).

See CapabilityState for what each value means and how they differ from a plain running/not-running bool.

Parameters
capability_typeCapability type to check (e.g. "navigation").
Returns
The capability's current state.

◆ has_capability()

bool has_capability ( const std::string & capability_type) const

True if this robot announced an active capability of this type (per the SimpleController's last discover_capabilities() pass).

Parameters
capability_typeCapability type to look up (e.g. "navigation").
Returns
Whether the capability is currently active on this robot.

◆ is_alive()

bool is_alive ( const std::string & capability_type) const

Whether a heartbeat has been seen recently on /capabilities_status for this capability – continuously tracked for the whole mission (not a one-off discovery-time snapshot the way today's CapabilityInfo::active is), so it reflects the current liveness of the capability's process, including one that dies mid-mission.

Parameters
capability_typeCapability type to check (e.g. "navigation").
Returns
Whether a recent heartbeat was observed for this capability.

◆ is_capability_running()

bool is_capability_running ( const std::string & capability_type) const

Shorthand for capability_state(capability_type) == CapabilityState::RUNNING.

Parameters
capability_typeCapability type to check (e.g. "navigation").
Returns
Whether the capability's last run_capability() call is still running.

◆ name()

const std::string & name ( ) const
noexcept

This robot's identity, as passed to the constructor.

Returns
This robot's identity, as passed to the constructor.

◆ run_capability()

template<typename ActionT>
void run_capability ( const std::string & capability_type,
const typename ActionT::Goal & goal = typename ActionT::Goal(),
std::chrono::seconds timeout = easyfleet_mission_manager::kRunTimeout )

Sends goal to capability_type and returns immediately – the counterpart to today's blocking easyfleet_mission_manager::run_capability<ActionT>().

Also publishes an automatic status marker above this robot, kept up to date until the goal settles or is stopped. ActionT is not inferred from capability_type (a runtime string can't select a compile-time type): the caller states it explicitly, typically via one of mission_helpers.hpp's make_navigation_goal()/ make_manipulation_goal()/make_perception_goal() convenience overloads (e.g. run_capability<Navigation>("navigation", make_navigation_goal("kitchen"))), or by building an ActionT::Goal by hand for anything those don't cover. The first run_capability() call for a given capability_type on this handle fixes which ActionT that capability type means from then on; a later call with a different ActionT for the same capability_type is a caller bug (mismatched action type) and is rejected – see @throws below – rather than silently sending a goal of the wrong type.

Parameters
capability_typeCapability type to command (e.g. "navigation").
goalGoal to send, fully typed. Defaults to a default-constructed ActionT::Goal – deliberately not one of mission_helpers.hpp's own demo defaults (e.g. make_perception_goal()'s "gato"), to avoid baking per-ActionT knowledge back into this generic method; a default-constructed goal may or may not be accepted by a given backend (e.g. the mock perception capability rejects an empty object_classes) – pass an explicit goal when that matters.
timeoutStop the goal if it hasn't finished on its own within this long. Does not block – check is_capability_running()/ capability_state() (or SimpleController::spin_for()) to observe the outcome.
Exceptions
std::logic_errorif capability_type was already run with a different ActionT on this handle.

◆ stop_capability()

void stop_capability ( const std::string & capability_type)

Asks capability_type to stop whatever it's doing, if anything.

Parameters
capability_typeCapability type to stop (e.g. "navigation").

The documentation for this class was generated from the following files:
  • easyfleet_mission_manager/include/easyfleet_mission_manager/robot_handle.hpp
  • easyfleet_mission_manager/include/easyfleet_mission_manager/detail/robot_handle_impl.hpp
  • easyfleet_mission_manager/src/easyfleet_mission_manager/robot_handle.cpp