py_trees icon indicating copy to clipboard operation
py_trees copied to clipboard

Design by YAML

Open naveedhd opened this issue 8 years ago • 5 comments

What do you think about the generating trees by parsing yaml file.

something like

root:
  name: Reality
  type: composites.Parallel
  children: child_a

child_a:
  name: My Timer
  type: timer.Timer
  duration: 5.0

I'm not sure if it would be useful for writing big but for small scripts (that I usually write to learn/verify) could be useful.

naveedhd avatar Jul 14 '17 13:07 naveedhd

I have no strong objections. Python should still be the first class citizen, but there are cases requiring serializable formats. YAML is ok, JSON might be an alternative so you can communicate with web apps (e.g. behaviour3's JSON format, check out the editor.

Other thoughts:

  • a parameter list for passing to the constructor
  • include the package name, e.g. py_trees.composites.Parallel

stonier avatar Jul 17 '17 00:07 stonier

Just some notes:

The lads here at TRI have been playing around with the idea of serialising the recipe for construction of a py_tree (note this is different than serialising the snapshot of a py_tree). This would serve some useful workflows:

  • Export format from an editor
  • Export format for converting from one form to another (e.g. we use for converting from log to scenario, where the scenario is represented by a behaviour tree)

If just doing it for minimising scripting boilerplate ... the python code is already actually super minimal. For a simple script, you're only adding a few lines extra to tick/render it and in some cases, saving effort by creating similar behaviours in a loop.

Both of the workflows above could, ostensibly, generate python code, but that is typically harder to do versioning on (and automatic upgrades of older version files lying around). Another benefit is that it could be used to generate the behaviour trees in a different language if ever this library decided to try it's hand at supporting it's implementations across languages (c++, javascript, ...).

stonier avatar Oct 12 '18 02:10 stonier

In BehaviorTree.CPP we did something similar, using XML as "scripting language".

To give you an idea of what it look like.... https://www.behaviortree.dev/xml_format/

facontidavide avatar May 29 '19 12:05 facontidavide