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

Can a SMACH state machine be paused and resumed?

asked 2013-04-21 14:20:21 -0600

Pi Robot gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2013-04-21 14:30:24 -0600

jbohren gravatar image

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.

edit flag offensive delete link more

Comments

Many thanks @jbohren. This will definitely get me on the right track.

Pi Robot gravatar image Pi Robot  ( 2013-04-21 15:54:45 -0600 )edit
1

answered 2016-01-21 10:23:34 -0600

jorge gravatar image

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!

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2013-04-21 14:20:21 -0600

Seen: 1,499 times

Last updated: Jan 21 '16