icub-tech-iit / ergocub-software

Main collector of ergoCub specific SW
https://icub-tech-iit.github.io/ergocub-software/
BSD 3-Clause "New" or "Revised" License
13 stars 18 forks source link

Automatic indent urdf file after generation #170

Closed GiulioRomualdi closed 1 year ago

GiulioRomualdi commented 1 year ago

Task description

It would be nice to automatically indent the urdf file at the end of the generation. This will simplify the manual inspection of the model of the robot from file.

Definition of Done

A procedure to automatically indent the file once generated (or at the end of the generation)

cc @traversaro

traversaro commented 1 year ago

Probably we can just run one of the following command as part of the generation process: https://stackoverflow.com/questions/16090869/how-to-pretty-print-xml-from-the-command-line .

traversaro commented 1 year ago

If we want to do that as part of creo2urdf/idyntree, the function used by xmllint --format is xmlSaveFormatFileEnc, see https://github.com/GNOME/libxml2/blob/99cba4b37b1a39d477f1b5acf782c6bd2d16d0ee/xmllint.c#L2619C10-L2619C30 .

GiulioRomualdi commented 1 year ago

Checking the urdf what is missing the indentation are the tags related to the gazebo plugins

Nicogene commented 1 year ago

Looking at the libxml2 doc I found this solution.

See the resulting urdfs: