0
$\begingroup$

Rosanswers logo

Hello,

I've been working through the smach and teer tutorials. Teer appears to make it easy to pause and resume a collection of tasks. I was wondering if there is a way to do something similar in SMACH.

My use case is a robot that is running around the house doing things by executing a SMACH state machine. However, it is also monitoring its battery levels using a SMACH MonitorState. When the battery levels fall too low, the robot should navigate to its docking station, recharge, then resume the execution of the original state machine where it left off.

I can imagine using a global "pause/resume" flag in the main state machine across all its contained states but this doesn't feel very SMACH-like. Does any one know how to implement this kind of pause/resume using SMACH?

Thanks!
patrick


Originally posted by Pi Robot on ROS Answers with karma: 4046 on 2013-04-21

Post score: 3

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

So, it is possible to set the initial state (and userdata) of a SMACH state machine with smach.Container.set_initial_state(). So if your battery monitor preempted the state machine, and you stored the active states of the containers you cared about, you could "resume" from a given state of execution later on. You'd have to do the bookkeeping on your own, but you should be able to get the behavior that you want.

What SMACH really needs is an extension for event-based transitions, and then you could distribute the responsibility of pausing / resuming in each active container.


Originally posted by jbohren with karma: 5809 on 2013-04-21

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by Pi Robot on 2013-04-21:
Many thanks @jbohren. This will definitely get me on the right track.

$\endgroup$
0
$\begingroup$

Rosanswers logo

I must say that this is half an answer, half a new question...

I have just learnt about the ActionServerWrapper and I think is the place to go. But you need an extending class to manage request belong currently supported start and cancel. I'm thinking in overloading the goal received callback and inspect the goal for a field like "sm_command" or so containing commands like "start", "pause", "resume", "stop", "set_userdata", etc. Of course, "start" would be just the current behavior of starting the state machine.

Do you think this can be a good idea?

Of course, we still need to implement some pause/resume mechanism, as @jbohren explained. Here I'm just guessing what could be a good external interface!


Originally posted by jorge with karma: 2284 on 2016-01-21

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.