splintered-reality/py_trees

Best way to cancel action at shutdown?

Closed this issue · 0 comments

I need to cancel all move_base goals when I shut down my py_trees script. My move_base action behaviours use py_trees_ros.actions.ActionClient and I can move the robot around appropriately depending on the state of my behaviour tree. However, when I Ctrl-C my script, I need the robot to stop immediately so I need to cancel all move_base goals. I can do this by creating a standalone move_base action client via actionlib.SimpleActionClient in the main script and then calling cancel_all_goals() in my rospy.on_shutdown() function but this does not seem like a very "behaviour tree-like" way to do things.

Is there a better way using py_trees behaviors? I tried defining terminate() and/or stop() overrides for my move_base behaviors that then call move_base.cancel_all_goals() but these do not stop the robot from moving when doing a Ctrl-C on the main script.