Capabilities2 0.3.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
capabilities2_runner::RunnerBase Class Referenceabstract

base class for all runners More...

#include "runner_base.hpp"

Inheritance diagram for capabilities2_runner::RunnerBase:
Inheritance graph
[legend]
Collaboration diagram for capabilities2_runner::RunnerBase:
Collaboration graph
[legend]

Public Member Functions

 RunnerBase ()
 
 ~RunnerBase ()=default
 
virtual void start (rclcpp::Node::SharedPtr node, const runner_opts &run_config, const std::string &bond_id)=0
 start the runner
 
virtual void stop (const std::string &bond_id, const std::string &instance_id="")=0
 stop the runner
 
virtual void trigger (capabilities2_events::EventParameters &parameters, const std::string &bond_id, const std::string &instance_id)=0
 Trigger the runner.
 
void init_base (rclcpp::Node::SharedPtr node, const runner_opts &run_config)
 Initializer function for initializing the base runner in place of constructor due to plugin semantics.
 
void enable_events (std::shared_ptr< capabilities2_events::EventBase > events)
 enable events system for this runner
 
void add_connection (const std::string &connection_id, const capabilities2_msgs::msg::CapabilityEventCode &type, const capabilities2_msgs::msg::Capability &target, std::function< void(const std::string &, const std::string &, const std::string &, capabilities2_events::EventParameters)> callback)
 make EventNode::add_connection public method on runner api.
 
const std::string get_package_name ()
 get the package name to which the runner belong to.
 
const std::string & get_interface () const
 get the interface of the runner.
 
const std::string & get_provider () const
 get the provider of the runner.
 
const std::string & get_started_by () const
 get the starter of the runner.
 
const std::string & get_pid () const
 get the pid of the runner.
 
- Public Member Functions inherited from capabilities2_events::EventNode
 EventNode (std::shared_ptr< EventBase > event_emitter=nullptr)
 
virtual ~EventNode ()=default
 
void emit_event (const std::string &bond_id, const std::string &instance_id, const uint8_t &event_type, capabilities2_events::EventParameters parameters=capabilities2_events::EventParameters())
 emit an event from this event node to all matching connections
 

Protected Member Functions

virtual capabilities2_events::EventParameters param_on_started ()
 Update on_started event parameters with new data if available.
 
virtual capabilities2_events::EventParameters param_on_stopped ()
 Update on_stopped event parameters with new data if available.
 
virtual capabilities2_events::EventParameters param_on_failure ()
 Update on_failure event parameters with new data if available.
 
virtual capabilities2_events::EventParameters param_on_success ()
 Update on_success event parameters with new data if available.
 
const std::string get_resource_name_by_type (const std::string &resource_type, const std::string &msg_type) const
 Get a resource name by data type from the config.
 
const std::string get_parameter_name_by_type (const std::string &param_type) const
 Get a parameter name by type.
 
const std::string get_topic_name_by_type (const std::string &topic_type) const
 Get a topic name by type.
 
const std::string get_service_name_by_type (const std::string &srv_type) const
 Get a service name by type.
 
const std::string get_action_name_by_type (const std::string &action_type) const
 Get the action name by type object.
 
const std::string get_first_resource_name (const std::string &resource_type) const
 get first name of a given resource
 
const std::string get_first_parameter_name () const
 Get the first parameter name.
 
const std::string get_first_topic_name () const
 Get the first topic name.
 
const std::string get_first_service_name () const
 Get the first service name.
 
const std::string get_first_action_name () const
 Get the first action name.
 
void emit_started (const std::string &bond_id, const std::string &instance_id, capabilities2_events::EventParameters parameters=capabilities2_events::EventParameters())
 emit STARTED event
 
void emit_stopped (const std::string &bond_id, const std::string &instance_id, capabilities2_events::EventParameters parameters=capabilities2_events::EventParameters())
 emit STOPPED event
 
void emit_succeeded (const std::string &bond_id, const std::string &instance_id, capabilities2_events::EventParameters parameters=capabilities2_events::EventParameters())
 emit SUCCEEDED event
 
void emit_failed (const std::string &bond_id, const std::string &instance_id, capabilities2_events::EventParameters parameters=capabilities2_events::EventParameters())
 emit FAILED event
 
- Protected Member Functions inherited from capabilities2_events::EventNode
void set_source (const capabilities2_msgs::msg::Capability &src)
 Set the source object.
 
void set_event_emitter (std::shared_ptr< EventBase > event_emitter)
 event emitter for this event node
 
void add_connection (const std::string &connection_id, const capabilities2_msgs::msg::CapabilityEventCode &type, const capabilities2_msgs::msg::Capability &target, EventBase::event_callback_t event_cb)
 make EventNode::add_connection public method on runner api.
 
void remove_connection (const std::string &connection_id)
 Remove a connection by its id.
 
void clear_connections ()
 clear all connections from this event node
 
std::vector< capabilities2_msgs::msg::CapabilityConnection > list_connections () const
 List all connections from this event node.
 
bool has_connection (const std::string &connection_id) const
 Check if a connection exists.
 
size_t connection_count () const
 current connection count
 
const std::string & get_id () const
 unique id of this event node
 
const capabilities2_msgs::msg::Capability & get_source () const
 source capability of this event node
 
bool is_event_emitter_set () const
 event emitter is set on this node
 

Protected Attributes

rclcpp::Node::SharedPtr node_
 shared pointer to the capabilities node Allows to use ros node related functionalities
 
runner_opts run_config_
 run_config_ runner configuration
 

Detailed Description

base class for all runners

Defines the runner plugin api. Inherits from EventNode to provide event emission

Constructor & Destructor Documentation

◆ RunnerBase()

capabilities2_runner::RunnerBase::RunnerBase ( )
inline

◆ ~RunnerBase()

capabilities2_runner::RunnerBase::~RunnerBase ( )
default

Member Function Documentation

◆ add_connection()

void capabilities2_runner::RunnerBase::add_connection ( const std::string &  connection_id,
const capabilities2_msgs::msg::CapabilityEventCode &  type,
const capabilities2_msgs::msg::Capability &  target,
std::function< void(const std::string &, const std::string &, const std::string &, capabilities2_events::EventParameters)>  callback 
)
inline

make EventNode::add_connection public method on runner api.

add connection to this runner to target capability this allows the runner to emit events on state changes to the target capability the connection ID format is: "bond_id/trigger_id" which allows event emission to extract bond_id for access control

Parameters
connection_idunique identifier for the connection (format: "bond_id/trigger_id")
typetype of event to connect to
targettarget capability to connect to
callbackcallback to trigger target capability with (capability, parameters, bond_id)

◆ emit_failed()

void capabilities2_runner::RunnerBase::emit_failed ( const std::string &  bond_id,
const std::string &  instance_id,
capabilities2_events::EventParameters  parameters = capabilities2_events::EventParameters() 
)
inlineprotected

emit FAILED event

Parameters
bond_id
parameters

◆ emit_started()

void capabilities2_runner::RunnerBase::emit_started ( const std::string &  bond_id,
const std::string &  instance_id,
capabilities2_events::EventParameters  parameters = capabilities2_events::EventParameters() 
)
inlineprotected

emit STARTED event

Parameters
bond_id
parameters

◆ emit_stopped()

void capabilities2_runner::RunnerBase::emit_stopped ( const std::string &  bond_id,
const std::string &  instance_id,
capabilities2_events::EventParameters  parameters = capabilities2_events::EventParameters() 
)
inlineprotected

emit STOPPED event

Parameters
bond_id
parameters

◆ emit_succeeded()

void capabilities2_runner::RunnerBase::emit_succeeded ( const std::string &  bond_id,
const std::string &  instance_id,
capabilities2_events::EventParameters  parameters = capabilities2_events::EventParameters() 
)
inlineprotected

emit SUCCEEDED event

Parameters
bond_id
parameters

◆ enable_events()

void capabilities2_runner::RunnerBase::enable_events ( std::shared_ptr< capabilities2_events::EventBase events)
inline

enable events system for this runner

Parameters
eventsevent emitter to be used by this runner

◆ get_action_name_by_type()

const std::string capabilities2_runner::RunnerBase::get_action_name_by_type ( const std::string &  action_type) const
inlineprotected

Get the action name by type object.

Parameters
action_type
Returns
const std::string

◆ get_first_action_name()

const std::string capabilities2_runner::RunnerBase::get_first_action_name ( ) const
inlineprotected

Get the first action name.

Returns
const std::string

◆ get_first_parameter_name()

const std::string capabilities2_runner::RunnerBase::get_first_parameter_name ( ) const
inlineprotected

Get the first parameter name.

Returns
const std::string

◆ get_first_resource_name()

const std::string capabilities2_runner::RunnerBase::get_first_resource_name ( const std::string &  resource_type) const
inlineprotected

get first name of a given resource

This can be used to get the name of the first action resource in the runner config

Returns
std::string

◆ get_first_service_name()

const std::string capabilities2_runner::RunnerBase::get_first_service_name ( ) const
inlineprotected

Get the first service name.

Returns
const std::string

◆ get_first_topic_name()

const std::string capabilities2_runner::RunnerBase::get_first_topic_name ( ) const
inlineprotected

Get the first topic name.

Returns
const std::string

◆ get_interface()

const std::string & capabilities2_runner::RunnerBase::get_interface ( ) const
inline

get the interface of the runner.

◆ get_package_name()

const std::string capabilities2_runner::RunnerBase::get_package_name ( )
inline

get the package name to which the runner belong to.

◆ get_parameter_name_by_type()

const std::string capabilities2_runner::RunnerBase::get_parameter_name_by_type ( const std::string &  param_type) const
inlineprotected

Get a parameter name by type.

Parameters
param_type
Returns
const std::string

◆ get_pid()

const std::string & capabilities2_runner::RunnerBase::get_pid ( ) const
inline

get the pid of the runner.

◆ get_provider()

const std::string & capabilities2_runner::RunnerBase::get_provider ( ) const
inline

get the provider of the runner.

◆ get_resource_name_by_type()

const std::string capabilities2_runner::RunnerBase::get_resource_name_by_type ( const std::string &  resource_type,
const std::string &  msg_type 
) const
inlineprotected

Get a resource name by data type from the config.

This helps to navigate remappings from the runner config

WARNING: this only gets the first resource found of the given type

Parameters
resource_type
msg_type
Returns
const std::string

◆ get_service_name_by_type()

const std::string capabilities2_runner::RunnerBase::get_service_name_by_type ( const std::string &  srv_type) const
inlineprotected

Get a service name by type.

Parameters
srv_type
Returns
const std::string

◆ get_started_by()

const std::string & capabilities2_runner::RunnerBase::get_started_by ( ) const
inline

get the starter of the runner.

◆ get_topic_name_by_type()

const std::string capabilities2_runner::RunnerBase::get_topic_name_by_type ( const std::string &  topic_type) const
inlineprotected

Get a topic name by type.

Parameters
topic_type
Returns
const std::string

◆ init_base()

void capabilities2_runner::RunnerBase::init_base ( rclcpp::Node::SharedPtr  node,
const runner_opts run_config 
)
inline

Initializer function for initializing the base runner in place of constructor due to plugin semantics.

Parameters
nodeshared pointer to the capabilities node. Allows to use ros node related functionalities
run_configrunner configuration loaded from the yaml file

◆ param_on_failure()

virtual capabilities2_events::EventParameters capabilities2_runner::RunnerBase::param_on_failure ( )
inlineprotectedvirtual

Update on_failure event parameters with new data if available.

This function is used to inject new data into the CapabilityOptions containing parameters related to the on_failure trigger event

A pattern needs to be implemented in the derived class

Returns
CapabilityOptions containing new parameters

◆ param_on_started()

virtual capabilities2_events::EventParameters capabilities2_runner::RunnerBase::param_on_started ( )
inlineprotectedvirtual

Update on_started event parameters with new data if available.

This function is used to inject new data into the CapabilityOptions containing parameters related to the on_started trigger event

A pattern needs to be implemented in the derived class

Returns
CapabilityOptions containing new parameters

◆ param_on_stopped()

virtual capabilities2_events::EventParameters capabilities2_runner::RunnerBase::param_on_stopped ( )
inlineprotectedvirtual

Update on_stopped event parameters with new data if available.

This function is used to inject new data into the CapabilityOptions containing parameters related to the on_stopped trigger event

A pattern needs to be implemented in the derived class

Returns
CapabilityOptions containing new parameters

◆ param_on_success()

virtual capabilities2_events::EventParameters capabilities2_runner::RunnerBase::param_on_success ( )
inlineprotectedvirtual

Update on_success event parameters with new data if available.

This function is used to inject new data into the CapabilityOptions containing parameters related to the on_success trigger event

A pattern needs to be implemented in the derived class

Returns
CapabilityOptions containing new parameters

Reimplemented in capabilities2_runner::GetCapabilitySpecsRunner.

◆ start()

virtual void capabilities2_runner::RunnerBase::start ( rclcpp::Node::SharedPtr  node,
const runner_opts run_config,
const std::string &  bond_id 
)
pure virtual

start the runner

runner plugin api

Parameters
nodeshared pointer to the capabilities node. Allows to use ros node related functionalities
run_configrunner configuration loaded from the yaml file
Attention
Must call init_base in derived class implementation and should call start event

Implemented in capabilities2_runner::LaunchRunner, capabilities2_runner::GetCapabilitySpecsRunner, capabilities2_runner::InputMultiplexRunner, and capabilities2_runner::DummyRunner.

◆ stop()

virtual void capabilities2_runner::RunnerBase::stop ( const std::string &  bond_id,
const std::string &  instance_id = "" 
)
pure virtual

◆ trigger()

virtual void capabilities2_runner::RunnerBase::trigger ( capabilities2_events::EventParameters parameters,
const std::string &  bond_id,
const std::string &  instance_id 
)
pure virtual

Trigger the runner.

FIXME: implement new event subsystem

This method allows insertion of parameters in a runner after it has been initialized. it is an approach to parameterise capabilities. Internally starts up RunnerBase::triggerExecution in a thread

Parameters
parameterscapability options that contain parameters for the trigger
bond_idunique identifier for the group of connections associated with this runner trigger event
instance_idunique identifier for the instance of the capability
Attention
should call success and failure events with parameters and bond_id when the trigger process completes.

Implemented in capabilities2_runner::ThreadTriggerRunner, capabilities2_runner::NoTriggerRunner, and capabilities2_runner::DummyRunner.

Member Data Documentation

◆ node_

rclcpp::Node::SharedPtr capabilities2_runner::RunnerBase::node_
protected

shared pointer to the capabilities node Allows to use ros node related functionalities

◆ run_config_

runner_opts capabilities2_runner::RunnerBase::run_config_
protected

run_config_ runner configuration


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