-
Notifications
You must be signed in to change notification settings - Fork 33
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
SDF files should be automatically checked for formatting #38
Comments
@dagar - P.S. - after a closer look at generated XSD files, it looks like "include noise.sdf" statements, for example, are ignored, and the resulting imu.xsd file, for example, does not contain noise elements. Basically, generated XSDs are incomplete. gazebosim/sdformat#633 - open issue, last mention 2021 It is a long rabbit hole... |
Just a note: the command that builds specific XSD file (imu.xsd in this case):
segment in imu.sdf:
the resulting segment in imu.xsd ("include noise.sdf" ignored):
|
At the moment model and world SDF files are not validated when they are checked in, and there is no single convenient tool to format these files. Linux has xmllint command line utility that allows formatting (pretty-printing) such files.
Here are suggested shell scripts that could help with simple checks and formatting (the same way astyle is used for C++ files):
format-sdf.sh <file>
if [ check-sdf.sh <file> ] ...
The
tail -n +2
is needed to remove standard XML header (if it is not desirable)In verifier the first operand produces visible output, while the second line allows $? variable to be returned from diff
Verifier basically formats the file and compares the result with original
A more elaborated check could be done - validating SDF files against their XML schema.
Format of Gazebo SDF files is described here: http://sdformat.org/spec?ver=1.11&elem=sdf
There is a git repository for a C++ code-generating tool https://github.com/gazebosim/sdformat
Schema is available as part of that repository: https://github.com/gazebosim/sdformat/blob/sdf14/sdf/1.9
xmllint --schema <>
would perform such validation, if all schema files are pulled locally from the repository.Pulling a collection of usable XSDs from that repository is a bit complicated - there is an additional step, using an SDF->XSD converter (as part of the sdformat build process):
https://github.com/gazebosim/sdformat/blob/sdf14/tools/xmlschema.py
A full clone / cmake / make process is required to produce a directory with actual XSDs usable by xmllint (under build/sdf/1.9)
Then this validation works (slowly):
I could look into it further, although implementing full schema validation would require having that XSD tree checked in, and validator is a bit slow. I also expect a lot of validation errors in the existing files, and some cleanup to follow.
@dagar - per our recent conversation
The text was updated successfully, but these errors were encountered: