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

How to trigger SMACH state transitions from another node

asked 2019-07-31 20:08:45 -0600

Frimann gravatar image


I'm using the SMACH state machine and want to trigger state changes from other nodes. For example from a keyboard node to ABORT the running process at any time.

One could of course do this by having the keyboard node send out an ABORT message on a topic and continuously monitor the given topic in each state, and induce a transition to an abort state if the ABORT message is received. But it sounds to me that it's to tedious to incorporate code in each state and at all waiting stages (for example while waiting for my laser to heat up or waiting for some other action to finish). Tedious and error prone.

Are there any other better ways to do this. Possibly some method to make this progress more event-driven.

regards - Frimann

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-15 17:29:37 -0600

achille gravatar image

Take a look at how FlexBE solves this. It's not entirely documented, but you can create a priority container which can interrupt another state machine containing several other states. Since FlexBE generates smach states, you could take a look at how it's doing that. Or you can just decide to use FlexBE without writing the smach states yourself, which I highly recommend.

edit flag offensive delete link more


Thanks for the reply. I switched to FlexBe long time ago, and liking the experience.

Frimann gravatar image Frimann  ( 2020-06-17 08:32:20 -0600 )edit

Question Tools



Asked: 2019-07-31 20:08:45 -0600

Seen: 412 times

Last updated: Jun 17 '20