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

The plain, manual controller: a mission script decides everything by hand (which robot runs which capability, when), SimpleController just hosts the FleetSession that makes talking to those robots possible. More...

#include <simple_controller.hpp>

Public Member Functions

void add_robot (RobotHandle &robot)
 Adds robot to this controller's session.
const std::vector< std::reference_wrapper< RobotHandle > > & robots () const noexcept
 See FleetSession::robots().
std::optional< std::reference_wrapper< RobotHandle > > find_robot (const std::string &name) const noexcept
 See FleetSession::find_robot().
void discover_capabilities (std::chrono::milliseconds window=std::chrono::milliseconds(2500))
 See FleetSession::discover_capabilities().
void spin_some ()
 See FleetSession::spin_some().
void spin_for (std::chrono::milliseconds duration)
 See FleetSession::spin_for().
rclcpp::Node::SharedPtr node () const noexcept
 See FleetSession::node().
void shutdown ()
 See FleetSession::shutdown().

Detailed Description

The plain, manual controller: a mission script decides everything by hand (which robot runs which capability, when), SimpleController just hosts the FleetSession that makes talking to those robots possible.

Owns a FleetSession by composition and forwards every call straight to it – there is no behavior here beyond the session's own. This is deliberate: SimpleController is meant to be the reference example of "a controller with zero decision-making logic of its own", so it also doubles as the template for writing a different one (an LLMController, a PlanSys2Controller, or one of your own) – see FleetSession's own doc comment for why those should be built the same way (own a FleetSession, add logic around it) rather than by subclassing this class.

Usage:

easyfleet::init(argc, argv);
easyfleet::RobotHandle robot_1("robot_1");
easyfleet::RobotHandle robot_2("robot_2");
controller.add_robot(robot_1);
controller.add_robot(robot_2);
controller.discover_capabilities();
// ... robot_1.run_capability(...), controller.spin_some()/spin_for(...) ...
controller.shutdown();
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 shutdown()
See FleetSession::shutdown().
Definition simple_controller.hpp:109
void add_robot(RobotHandle &robot)
Adds robot to this controller's session.
Definition simple_controller.hpp:71

Member Function Documentation

◆ add_robot()

void add_robot ( RobotHandle & robot)
inline

Adds robot to this controller's session.

Parameters
robotMust outlive this SimpleController.

◆ discover_capabilities()

void discover_capabilities ( std::chrono::milliseconds window = std::chrono::milliseconds(2500))
inline

See FleetSession::discover_capabilities().

Parameters
windowHow long to listen before returning.

◆ find_robot()

std::optional< std::reference_wrapper< RobotHandle > > find_robot ( const std::string & name) const
inlinenoexcept

See FleetSession::find_robot().

Parameters
nameName to look up, as passed to RobotHandle's constructor.
Returns
The matching robot, or std::nullopt if none was added under that name.

◆ node()

rclcpp::Node::SharedPtr node ( ) const
inlinenoexcept

See FleetSession::node().

Returns
The underlying ROS node.

◆ robots()

const std::vector< std::reference_wrapper< RobotHandle > > & robots ( ) const
inlinenoexcept

See FleetSession::robots().

Returns
Every robot added so far.

◆ spin_for()

void spin_for ( std::chrono::milliseconds duration)
inline

See FleetSession::spin_for().

Parameters
durationHow long to block for.

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