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?
Do you want the publisher to keep publishing or only publish once when the state changes?
@DavidN The publisher should always be publishing.
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 ofsmach_msgs/SmachContainerStatus
.Do note that the topic
your_introspection_server/smach/container_status
might be abit confusing if you use nested state machinesAn 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.
Totally agree with @gvdhoom about the "only coordinate other nodes, not to actually do any work in the states themselves"