splintered-reality / py_trees

Python implementation of behaviour trees.
Other
416 stars 140 forks source link

Saving Tree & Blackboard State #349

Closed gycn closed 1 year ago

gycn commented 2 years ago

Hi, we're trying to use this library to control a dual arm manipulator to perform an assembly task. Sometimes we'll get errors in the middle of the task due to things like singularities or collisions, and we'll want to restart the task from where we left off. Is it possible to record the state of the tree and the blackboard so that this information is available for us to start in the middle? I saw that there's a Coming Soon section in the tutorials for Bagging Trees which might be relevant.

stonier commented 2 years ago

The devil in the detail here - hidden state in behaviours.

Regular py_tree behaviours and user behaviours don't go as far as ensuring that state is exposed, capturable and reconstructable. That would raise the level of complexity of the library rather significantly.

I suspect however, you don't need to capture every single detail of the tree state (and hidden state). You could create your own post-tick handler that captures the few details you need, saves them somewhere if there's been a change and create your own method to recreate the tree from there. This would be wholly or partially application dependent though.