ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

First, have you thought of making your SMACH state machine controlled by the actionlib API with the SMACH ActionServerWrapper? This lets you start and preempt execution of a SMACH container over actionlib actions, which are basically preemptable service calls. ActionServerWrapper wraps a SMACH container in an actionlib server, and then you can "command" the SMACH plan with the normal actionlib API.

If you really must use a service, then I have two thoughts:

  1. To make a SMACH state that responds to service requests with the current API, you can model a custom SMACH state type similar to the SMACH MonitorState. This state would represent waiting for a service call, so it would block until it receives a service call, or until it's preempted. Then that service call could cause the state to have a specific outcome, which could start execution.
  2. To create a wrapper that controls a SMACH plan through service calls, you could build something similar to ActionServerWrapper, but use service calls instead of actionlib.

Additionally, this is a really good use case for event-driven SMACH state transitions (something which I think SMACH could really use).

First, have you thought of making your SMACH state machine controlled by the actionlib API with the SMACH ActionServerWrapper? This lets you start and preempt execution of a SMACH container over actionlib actions, which are basically preemptable service calls. ActionServerWrapper wraps a SMACH container in an actionlib server, and then you can "command" the SMACH plan with the normal actionlib API.

If you really must use a service, then I have two thoughts:

  1. To make a SMACH state that responds to service requests with the current API, you can model a custom SMACH state type similar to the SMACH MonitorState. This state would represent waiting for a service call, so it would block until it receives a service call, or until it's preempted. Then that service call could cause the state to have a specific outcome, which could start execution.
  2. To create a wrapper that controls a SMACH plan through service calls, you could build something similar to ActionServerWrapper, but use service calls instead of actionlib.

Additionally, this is a really good use case for event-driven SMACH state transitions (something which I think SMACH could really use).use, and could be implemented without making SMACH much more complex).