-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parametrize the YAML ? #235
Comments
Totally agree, but I am not sure if cmake is the right tool for this. I have an idea, I will write it as soon I am at the laptop. |
Ok, I looked into how If instead for any reason we want to go for templating the .json files, I would look for regular template engine such as jinja2 (for C++ or Python) or mustache, instead of using CMake as a template engine. |
Today I start looking this option, in paricular I found this interesting utility for merging/managing yaml files: I started playing around with it, I created to "addons" yaml, the These two yaml contains ONLY the And with this command:
I obtained this file: The idea is that for obtaining the ERGOCUB_all_options_minContacts we should:
for obtaining this other file: In this way the information should not be duplicated In this way, we concatenate both the "addons". I have also struggled a little bit to add custom commands in the CMakeLists in order to generate all the yaml files when generating, my idea was to create a macro that functions of the version of the robot ( |
I am probably missing why we need to use CMake for the generation of the model. If I am not wrong, the invocation of |
I can confirm that yq is a quite good tool. I've already used it in the past for https://github.com/icub-tech-iit/gh-action-repo-selective-sync/. |
My idea is to still keep the possibility to generate the ergocub-software urdf launching creo2urdf with the GUI, then I was thinking about adding a custom command in cmake for generating the all the yamls that can be used, alternatively I could create a ps script for just generate the yaml needed by creo2urdf |
Can't we generate the .yaml as part of the creo2urdf generation process? I imagine that anyone touching those file is interested in testing them by generating the URDF via creo2urdf, so I am not sure if there is any benefit in splitting the generation process in different manual steps. |
After a T2T chat, we agreed that passing multiple yamls to creo2urdf can make the process cumbersome while using it via GUI, we thought that it would be nice that the entry point remains one yaml, that yaml can be "complete" as they are now or it can include more "sub-yamls". |
I managed to load multiple yaml files and merge them all, now the yaml are: ERGOCUB_all_options.yaml includes:[base.yaml] ERGOCUB_all_options_gazebo.yaml includes:[base.yaml, gazebo_addon.yaml] ERGOCUB_all_options_minContacts.yaml includes:[base.yaml, gazebo_addon.yaml, minContacts_addon.yaml] I wrote on a file the result of merging it the resulting yaml contains all the information, the only problem is that when in the included yaml some parameters are repeated, i.e. We need to think about how to manage when a parameter is defined multiple times |
ChatGPT says that an yaml like this
If parsed with yaml-cpp result as follows:
But from what I am experiencing in creo2urdf I am getting instead this behavior:
|
Are you sure that the behaviour in presence of duplicate keys is described in the yaml spec and not implementation defined? If it is the latter, then this may be an implementation detail of yaml-cpp. For dealing with duplicate keys, probably we can just iterate on the keys and merge them if duplicate? Is that enough or we need also to ensure that yaml elements that are grandchild of the root need to be merged? |
It seems this behaviour is a yaml-cpp issue: jbeder/yaml-cpp#60 . |
I am pretty sure that ChatGPT is guessing but it is completely wrong :D And yes it seems that duplication of keys is allowed by yaml-cpp but not by the standard.
I found several snippets that claimed to merge yamls but none is doing what we need, for now, just |
In: I added the possibility to specify yamls to be included, it works both with "old-style" yamls and "composite" yamls, I tested it converting the ergocub urdfs and there were no difference with the ones generated with the "old-style" ones. We should agree on how using this functionality, is it ok this structure? |
Here my first proposal of refactoring: |
Task description
In
icub-models-generator
theyaml
are actuallyyaml.in
that via cmake fill some placeholders in order to create the configuration files for more versions of iCub.Now that the generation of the urdf may be automatize via
creo2urdf
:URDF
generation from the terminal creo2urdf#53Maybe it makes sense to start use also here the
yaml.in
?This would help for example in:
Since the only difference will be in the weight of the head and its inertia.
Definition of Done
We built the cmake infrastructure for handling the
yaml.in
and the repo has been refactoredcc @xela-95 @traversaro @pattacini
The text was updated successfully, but these errors were encountered: