C++ YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
AddTwoIntsState Class Reference

State for calling the AddTwoInts service in ROS 2. More...

Inheritance diagram for AddTwoIntsState:
Collaboration diagram for AddTwoIntsState:

Public Member Functions

 AddTwoIntsState ()
 Constructor for AddTwoIntsState.
 
example_interfaces::srv::AddTwoInts::Request::SharedPtr create_request_handler (yasmin::Blackboard::SharedPtr blackboard)
 Creates a service request using values from the blackboard.
 
std::string response_handler (yasmin::Blackboard::SharedPtr blackboard, example_interfaces::srv::AddTwoInts::Response::SharedPtr response)
 Handles the service response and stores the result in the blackboard.
 
- Public Member Functions inherited from yasmin_ros::ServiceState< example_interfaces::srv::AddTwoInts >
 ServiceState (const std::string &srv_name, CreateRequestHandler create_request_handler, int wait_timeout=-1, int response_timeout=-1, int maximum_retry=3)
 Shared pointer type for ServiceState.
 
 ServiceState (const std::string &srv_name, CreateRequestHandler create_request_handler, const yasmin::Outcomes &outcomes, int wait_timeout=-1, int response_timeout=-1, int maximum_retry=3)
 Construct a ServiceState with a request handler and outcomes.
 
 ServiceState (const std::string &srv_name, CreateRequestHandler create_request_handler, const yasmin::Outcomes &outcomes, rclcpp::CallbackGroup::SharedPtr callback_group=nullptr, int wait_timeout=-1, int response_timeout=-1, int maximum_retry=3)
 Construct a ServiceState with a request handler and outcomes.
 
 ServiceState (const std::string &srv_name, CreateRequestHandler create_request_handler, ResponseHandler response_handler, int wait_timeout=-1, int response_timeout=-1, int maximum_retry=3)
 Construct a ServiceState with a request handler and response handler.
 
 ServiceState (const std::string &srv_name, CreateRequestHandler create_request_handler, const yasmin::Outcomes &outcomes, ResponseHandler response_handler, int wait_timeout=-1, int response_timeout=-1, int maximum_retry=3)
 Construct a ServiceState with a request handler and response handler.
 
 ServiceState (const rclcpp::Node::SharedPtr &node, const std::string &srv_name, CreateRequestHandler create_request_handler, const yasmin::Outcomes &outcomes, ResponseHandler response_handler, rclcpp::CallbackGroup::SharedPtr callback_group, int wait_timeout=-1, int response_timeout=-1, int maximum_retry=3)
 Construct a ServiceState with a ROS 2 node and handlers.
 
std::string execute (yasmin::Blackboard::SharedPtr blackboard) override
 Execute the service call and handle the response.
 
- Public Member Functions inherited from yasmin::State
 State (const Outcomes &outcomes)
 Shared pointer type for State.
 
virtual ~State ()=default
 Virtual destructor for proper polymorphic destruction.
 
bool is_idle () const noexcept
 Checks if the state is idle.
 
bool is_running () const noexcept
 Checks if the state is currently running.
 
bool is_canceled () const noexcept
 Checks if the state has been canceled.
 
bool is_completed () const noexcept
 Checks if the state has completed execution.
 
std::string operator() (Blackboard::SharedPtr blackboard)
 Executes the state and returns the outcome.
 
virtual void cancel_state ()
 Cancels the current state execution.
 
Outcomes const & get_outcomes () const noexcept
 Gets the set of possible outcomes for this state.
 
virtual std::string to_string () const
 Converts the state to a string representation.
 

Additional Inherited Members

- Protected Attributes inherited from yasmin_ros::ServiceState< example_interfaces::srv::AddTwoInts >
rclcpp::Node::SharedPtr node_
 Shared pointer to the ROS 2 node.
 
- Protected Attributes inherited from yasmin::State
Outcomes outcomes
 The possible outcomes of this state.
 

Detailed Description

State for calling the AddTwoInts service in ROS 2.

This state constructs and sends a service request to add two integers, and processes the response to retrieve and store the result in the blackboard.

Constructor & Destructor Documentation

◆ AddTwoIntsState()

AddTwoIntsState::AddTwoIntsState ( )
inline

Constructor for AddTwoIntsState.

Initializes the service state with the specified service name and handlers for request creation and response processing.

Member Function Documentation

◆ create_request_handler()

example_interfaces::srv::AddTwoInts::Request::SharedPtr AddTwoIntsState::create_request_handler ( yasmin::Blackboard::SharedPtr blackboard)
inline

Creates a service request using values from the blackboard.

Retrieves integers "a" and "b" from the blackboard and sets them in the request.

Parameters
blackboardShared pointer to the blackboard for retrieving values.
Returns
example_interfaces::srv::AddTwoInts::Request::SharedPtr The service request.

◆ response_handler()

std::string AddTwoIntsState::response_handler ( yasmin::Blackboard::SharedPtr blackboard,
example_interfaces::srv::AddTwoInts::Response::SharedPtr response )
inline

Handles the service response and stores the result in the blackboard.

Retrieves the sum from the service response and stores it in the blackboard.

Parameters
blackboardShared pointer to the blackboard for storing values.
responseShared pointer to the service response containing the sum.
Returns
std::string Outcome indicating success.

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