splintered-reality / py_trees

Python implementation of behaviour trees.
Other
430 stars 143 forks source link

Design by YAML #63

Open naveedhd opened 7 years ago

naveedhd commented 7 years ago

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.

stonier commented 7 years ago

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:

stonier commented 5 years ago

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:

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, ...).

facontidavide commented 5 years ago

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/

erichlf commented 1 month ago

I have created an xml parser for py_trees. It isn't ready to be released just yet, but my intention is to publish the code.