Week 11 - Finishing subtree composition with depth N
Summary
This week, I resolved the issues identified in the backend to enable multilevel composition. I also began developing a basic library of reusable behaviors that users can easily import into their projects.
Multilevel composition in the backend
Storing subtrees also as XML
First, I changed a little how the subtree XML files were being managed. Now, when the user creates (or saves) a subtree, it is not only stored as JSON: an XML version is also created and stored. Before, this tree was only generated on app generation time and never stored. This new behavior has two main advantages:
- All the info of the subtrees of the project is ready when the user want to generate an app.
- The subtree implementation can easily be checked and debugged.
Recursive subtree substitution
Previously, tree generation only checked for subtrees at the first level. I expanded its functionality to iterate over the generated XML until no subtrees remain.
This is done by comparing the XML tags against a list of possible subtrees, which can conveniently be obtained by just listing all files in the subtree subdirectory.
Basic library of behaviors
With the composition tools fully functional, I created four basic subtrees that can be useful across a wide range of robotic applications. The goal is for users to import the ones they need and begin working from a solid foundation. In the future, this library could grow to include a variety of community-created behaviors, organized into different categories.
The created behaviors are:
- AlignPerson: allows a robot with a person using images
- DistanceWatcher: checks if the robot is at a given instance to an obstacle.
- FollowPerson: reactively follows a person using images
- MoveAvoidingObstacles: the robot goes straight until it finds an obstacle, then it tries to find the nearest clear space.
I expanded the tree creation endpoints so that when a user enters the name of an existing behavior, it is imported from the library instead of creating a new blank subtree. This includes both the JSON and the XML files.