[Plugin Parsing] Updates the plugin parsing of the scenery builder to support the new "Plugin.json" metamodel, and the new floorplan_model folder structure #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Plugins
Mandatory Plugins
Initial Plugin
Every door should always have an instance of the initial state plugin. “@id” will usually be chosen from a predefined set of plugin configurations.
Currently, there exist three different configurations:
If these are not suitable for your specific case, you may also create new plugin configuration. We will get to how to add your own plugins and configurations a bit later.
The following is an example illustrates how to add a initial plugin with the configuration “partially-opened”, to the graph for the door-instance-1:
Optional Plugins
Dynamic Plugin
The dynamic plugin currently only has one ID in use. Since JSON-LD does allow for dynamic variable passing, and the URI will be a link to a file containing the keyframes at which the door should open/close, it is not predefined in some config, but needs to be set manually as shown in the example:
Adversarial Plugin
The adversarial plugin utilizes transitions from a start-state, to a end-state. Currently, there exist three different states:
each combination of these states has its own transition.
In addition to that, we also need to set a “distance” parameter here, which is the distance at which the distance at which the robot will trigger the transition from start-state to the end-state
So in general an adversarial plugin will always look as follows:
This is a specific example for start-state “opened”, and end-state “closed”, which triggers if the robots distance to the door is 90cm:
Adding New Plugins and Configurations
If you want to create a plugin of a new type, you must first create a new file
new-plugin-states.sjon
using the following template:If your plugin benefits from having a dynamic parameter similar to the
uri
parameter from the dynamic plugin, or thedistance
parameter from the adversarial plugin, then you must add a new parameter tometamodels/floor-plan/plugin.json
, using the following template:Adding the New Plugin to the Template
First we need to access all parameters needed for our plugin. This is done inside
scenery_builder/src/fpm/transformations/objects.py
, inside theget_object_instance
function.Locate the
if-elif
blocks at Line ~180, and append a newelif
. Here is an example for the adversarial joint plugin:In this case, we first make sure that the state is of type
ST["Transition"]
, since we rely on itsstart-state
andend-state
is. Also notice that, in order to retrieve thedistance
parameter, we need to accessplugin
, notstate
.Inside the appended dictionary, make sure to keep the “plugin_type” keyword, but other than that you may use any number of unique keywords you need for your plugin.
Afterwards, inside the file
scenery_builder/src/fpm/templates/gazebo/world.sdf.jinja
, you will find afor-loop
used to iterate through all plugins of the current instance around Line 34. Append a newelif
statement at the end. Here is an example for the adversarial joint plugin: