Capabilities2 0.3.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
capabilities2_runner::ActionRunner< ActionT > Class Template Referenceabstract

action runner base class More...

#include "action_runner.hpp"

Inheritance diagram for capabilities2_runner::ActionRunner< ActionT >:
Inheritance graph
[legend]
Collaboration diagram for capabilities2_runner::ActionRunner< ActionT >:
Collaboration graph
[legend]

Public Member Functions

 ActionRunner ()
 Constructor which needs to be empty due to plugin semantics.
 
virtual void init_action (rclcpp::Node::SharedPtr node, const runner_opts &run_config, const std::string &action_name)
 Initializer function for initializing the action runner in place of constructor due to plugin semantics.
 
virtual void stop (const std::string &bond_id, const std::string &instance_id="") override
 stop function to cease functionality and shutdown
 
- Public Member Functions inherited from capabilities2_runner::ThreadTriggerRunner
 ThreadTriggerRunner ()
 
 ~ThreadTriggerRunner ()
 
virtual void trigger (capabilities2_events::EventParameters &parameters, const std::string &bond_id, const std::string &instance_id) override
 Trigger the runner.
 
- Public Member Functions inherited from capabilities2_runner::RunnerBase
 RunnerBase ()
 
 ~RunnerBase ()=default
 
virtual void start (rclcpp::Node::SharedPtr node, const runner_opts &run_config, const std::string &bond_id)=0
 start 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 void execution (capabilities2_events::EventParameters parameters, const std::string &thread_id) override
 Trigger process to be executed.
 
virtual ActionT::Goal generate_goal (capabilities2_events::EventParameters &parameters)=0
 Generate a goal from parameters.
 
virtual std::string generate_feedback (const typename ActionT::Feedback::ConstSharedPtr msg)=0
 Generate a std::string from feedback message.
 
- Protected Member Functions inherited from capabilities2_runner::RunnerBase
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_action::Client< ActionT >::SharedPtr action_client_
 
rclcpp_action::Client< ActionT >::SendGoalOptions send_goal_options_
 
rclcpp_action::ClientGoalHandle< ActionT >::SharedPtr goal_handle_
 
rclcpp_action::ClientGoalHandle< ActionT >::WrappedResult wrapped_result_
 
ActionT::Result::SharedPtr result_
 
ActionT::Goal goal_msg_
 
std::shared_future< typename rclcpp_action::ClientGoalHandle< ActionT >::SharedPtr > goal_handle_future_
 
std::shared_future< typename rclcpp_action::ClientGoalHandle< ActionT >::WrappedResult > result_future_
 
- Protected Attributes inherited from capabilities2_runner::ThreadTriggerRunner
std::map< std::string, std::thread > execution_thread_pool_
 dictionary of threads that executes the execute function
 
std::mutex mutex_
 mutex for threadpool synchronisation.
 
std::atomic< bool > execution_should_stop_
 flag to signal execution threads to stop.
 
- Protected Attributes inherited from capabilities2_runner::RunnerBase
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
 

Additional Inherited Members

- Static Public Member Functions inherited from capabilities2_runner::ThreadTriggerRunner
static const std::string bond_from_thread_id (const std::string &thread_id)
 helper function to extract bond_id from thread_id
 
static const std::string instance_from_thread_id (const std::string &thread_id)
 helper function to extract instance_id from thread_id
 

Detailed Description

template<typename ActionT>
class capabilities2_runner::ActionRunner< ActionT >

action runner base class

Create an action client to run an action based capability

Constructor & Destructor Documentation

◆ ActionRunner()

template<typename ActionT >
capabilities2_runner::ActionRunner< ActionT >::ActionRunner ( )
inline

Constructor which needs to be empty due to plugin semantics.

Member Function Documentation

◆ execution()

template<typename ActionT >
virtual void capabilities2_runner::ActionRunner< ActionT >::execution ( capabilities2_events::EventParameters  parameters,
const std::string &  thread_id 
)
inlineoverrideprotectedvirtual

Trigger process to be executed.

This method utilizes paramters set via the trigger() function

Parameters
parameterspointer to capabilities2_events::EventParameters that contains parameters

Implements capabilities2_runner::ThreadTriggerRunner.

◆ generate_feedback()

template<typename ActionT >
virtual std::string capabilities2_runner::ActionRunner< ActionT >::generate_feedback ( const typename ActionT::Feedback::ConstSharedPtr  msg)
protectedpure virtual

Generate a std::string from feedback message.

This function is used to convert feedback messages into generic strings

A pattern needs to be implemented in the derived class. If the feedback string is empty, nothing will be printed on the screen

Parameters
msgthe feedback message received from the action server
Returns
ActionT::Feedback the received feedback

◆ generate_goal()

template<typename ActionT >
virtual ActionT::Goal capabilities2_runner::ActionRunner< ActionT >::generate_goal ( capabilities2_events::EventParameters parameters)
protectedpure virtual

Generate a goal from parameters.

This function is used in conjunction with the trigger function to inject type erased parameters into the typed action

A pattern needs to be implemented in the derived class

Parameters
parameterscapability options that contain parameters for the instance
Returns
ActionT::Goal the generated goal

◆ init_action()

template<typename ActionT >
virtual void capabilities2_runner::ActionRunner< ActionT >::init_action ( rclcpp::Node::SharedPtr  node,
const runner_opts run_config,
const std::string &  action_name 
)
inlinevirtual

Initializer function for initializing the action 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
action_nameaction name used in the yaml file, used to load specific configuration from the run_config

◆ stop()

template<typename ActionT >
virtual void capabilities2_runner::ActionRunner< ActionT >::stop ( const std::string &  bond_id,
const std::string &  instance_id = "" 
)
inlineoverridevirtual

stop function to cease functionality and shutdown

Implements capabilities2_runner::RunnerBase.

Member Data Documentation

◆ action_client_

template<typename ActionT >
rclcpp_action::Client<ActionT>::SharedPtr capabilities2_runner::ActionRunner< ActionT >::action_client_
protected

< action client

◆ goal_handle_

template<typename ActionT >
rclcpp_action::ClientGoalHandle<ActionT>::SharedPtr capabilities2_runner::ActionRunner< ActionT >::goal_handle_
protected

goal handle parameter to capture goal response from goal_response_callback

◆ goal_handle_future_

template<typename ActionT >
std::shared_future<typename rclcpp_action::ClientGoalHandle<ActionT>::SharedPtr> capabilities2_runner::ActionRunner< ActionT >::goal_handle_future_
protected

Goal Handle Future message

◆ goal_msg_

template<typename ActionT >
ActionT::Goal capabilities2_runner::ActionRunner< ActionT >::goal_msg_
protected

Goal message

◆ result_

template<typename ActionT >
ActionT::Result::SharedPtr capabilities2_runner::ActionRunner< ActionT >::result_
protected

Result

◆ result_future_

template<typename ActionT >
std::shared_future<typename rclcpp_action::ClientGoalHandle<ActionT>::WrappedResult> capabilities2_runner::ActionRunner< ActionT >::result_future_
protected

Result Future

◆ send_goal_options_

template<typename ActionT >
rclcpp_action::Client<ActionT>::SendGoalOptions capabilities2_runner::ActionRunner< ActionT >::send_goal_options_
protected

Send Goal Option struct to link result_callback, feedback_callback and goal_response_callback with action client

◆ wrapped_result_

template<typename ActionT >
rclcpp_action::ClientGoalHandle<ActionT>::WrappedResult capabilities2_runner::ActionRunner< ActionT >::wrapped_result_
protected

Wrapped Result


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