yasmin_demos.service_client_demo module
- class yasmin_demos.service_client_demo.AddTwoIntsState(*args: Any, **kwargs: Any)
Bases:
ServiceState
A state that calls the AddTwoInts service to add two integers.
This class is a state in a finite state machine that sends a request to the AddTwoInts service, retrieves the response, and updates the blackboard with the result.
- Attributes:
service_type (type): The service type being used (AddTwoInts). service_name (str): The name of the service. outcomes (list): The list of possible outcomes for this state.
- create_request_handler(blackboard: yasmin.Blackboard) example_interfaces.srv.AddTwoInts.Request
Creates the service request from the blackboard data.
- Args:
blackboard (Blackboard): The blackboard containing the input values.
- Returns:
AddTwoInts.Request: The request object populated with values from the blackboard.
- response_handler(blackboard: yasmin.Blackboard, response: example_interfaces.srv.AddTwoInts.Response) str
Processes the response from the AddTwoInts service.
Updates the blackboard with the sum result from the response.
- Args:
blackboard (Blackboard): The blackboard to update with the sum. response (AddTwoInts.Response): The response from the service call.
- Returns:
str: The outcome of the operation, which is “outcome1”.
- yasmin_demos.service_client_demo.main()
The main function to execute the finite state machine (FSM).
This function initializes the ROS 2 environment, sets up logging, creates the FSM with defined states, and executes the FSM.
- Raises:
KeyboardInterrupt: If the user interrupts the program.
- yasmin_demos.service_client_demo.print_sum(blackboard: yasmin.Blackboard) str
Logs the sum value from the blackboard.
This function retrieves the sum from the blackboard and logs it.
- Args:
blackboard (Blackboard): The blackboard from which to retrieve the sum.
- Returns:
str: The outcome of the operation, which is SUCCEED.
- yasmin_demos.service_client_demo.set_ints(blackboard: yasmin.Blackboard) str
Sets the integer values in the blackboard.
This function initializes the blackboard with two integer values to be added.
- Args:
blackboard (Blackboard): The blackboard to update with integer values.
- Returns:
str: The outcome of the operation, which is SUCCEED.