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

Changing SMACH states on a service request

asked 2013-04-28 15:53:43 -0500

updated 2013-04-29 04:22:55 -0500

I am using SMACH to create a state machine. I would like to create a state machine that switches state when a service request is received (i.e. the state machine has a service server). I have a simple GUI with a START/STOP button. The GUI executes a service request when the button(s) are pressed. I would like to change from and IDLE state on START and go back to it when the STOP button is pressed. Is there a preferred way of embedding the service server in a SMACH state machine and what is the best way to trigger state transitions based on a service request event?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2013-04-29 07:23:41 -0500

jbohren gravatar image

updated 2013-04-29 07:24:44 -0500

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, and could be implemented without making SMACH much more complex).

edit flag offensive delete link more

Comments

I will have to consider using the ActionServerWrapper or one of the two other options. I should be able to make them work for my needs. I am interested in an event-driven approach as this is probably a better approach. We can discuss this offline, if I decide to take that approach.

sedwards gravatar image sedwards  ( 2013-04-29 08:44:59 -0500 )edit

Yeah, I think an exogenous event interface could be really powerful, in addition to the current endogenous outcome events. Feel free to ping me if you want to talk more about it, also I'll be at ICRA and ROSCon.

jbohren gravatar image jbohren  ( 2013-04-29 10:15:29 -0500 )edit

Hey, Any progress on this? I would also be very interested in the event-driven approach.

Chrisando gravatar image Chrisando  ( 2018-01-08 10:35:45 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2013-04-28 15:53:43 -0500

Seen: 1,224 times

Last updated: Apr 29 '13