Robotics StackExchange | Archived questions

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

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?

Asked by mr-hudson on 2017-06-04 14:02:12 UTC

Comments

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

Asked by DavidN on 2017-06-04 21:49:35 UTC

@DavidN The publisher should always be publishing.

Asked by mr-hudson on 2017-06-05 13:23:13 UTC

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.

Asked by DavidN on 2017-06-05 21:16:30 UTC

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

Asked by DavidN on 2017-06-05 21:17:09 UTC

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.

Asked by gvdhoorn on 2017-06-07 00:46:09 UTC

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

Asked by DavidN on 2017-06-07 00:48:46 UTC

Answers