How to have a publisher that publishes in parallel with the SMACH state machines?

asked 2017-06-04 14:02:12 -0500

mr-hudson gravatar image

updated 2017-06-05 13:24:13 -0500

I require a publisher that runs in parallel with the SMACH state machines for informing other nodes (GUI, for example) about the currently executing SMACH state machines. I thought of using a top level Concurrence container that makes my main logic run in parallel with the state machine that runs the publisher. Is there a better way of accomplishing this task?

edit retag flag offensive close merge delete

Comments

Do you want the publisher to keep publishing or only publish once when the state changes?

DavidN gravatar image DavidN  ( 2017-06-04 21:49:35 -0500 )edit

@DavidN The publisher should always be publishing.

mr-hudson gravatar image mr-hudson  ( 2017-06-05 13:23:13 -0500 )edit

To keep publishing a topic in SMACH is a bit tricky. I guess it might involve multi-threads. 1 suggestion is to monitoring the topic your_introspection_server/smach/container_status which has msg type of smach_msgs/SmachContainerStatus.

DavidN gravatar image DavidN  ( 2017-06-05 21:16:30 -0500 )edit

Do note that the topic your_introspection_server/smach/container_status might be abit confusing if you use nested state machines

DavidN gravatar image DavidN  ( 2017-06-05 21:17:09 -0500 )edit
2

An alternative approach: use your state machine to only coordinate other nodes, not to actually do any work in the states themselves. Then you can make use of a concurrent container that controls an external node to do the publishing for it.

Personally I like such a design more: less coupling.

gvdhoorn gravatar image gvdhoorn  ( 2017-06-07 00:46:09 -0500 )edit

Totally agree with @gvdhoom about the "only coordinate other nodes, not to actually do any work in the states themselves"

DavidN gravatar image DavidN  ( 2017-06-07 00:48:46 -0500 )edit