-
Notifications
You must be signed in to change notification settings - Fork 363
Add XML schema validation for ros2_control tag and test assets #2466
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
base: master
Are you sure you want to change the base?
Add XML schema validation for ros2_control tag and test assets #2466
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for such a nice addition👏🏽👏🏽
Isn't the hardware_interface the best place to have the XML schema? As that is where the component parsing and validation happen.
Moreover, the current place is only to store the assets for tests.
What do you think? @bmagyar @christophfroehlich @destogl
I agree, the tests assets are not the best place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 what @saikishor already said.
how does xsd work actually? is there a way to have different versions? or is this specified only by the url where we put it? I'm thinking of how we handle this in future, when the schema evolves with a new ROS distro for example.
Thanks, I will move these XML Schema to the
I'm thinking of how we handle this in future, when the schema evolves with a new ROS distro for example. |
Repository-wise this is fine. But hopefully people will adopt this and have the schema in their xml files. How do they reference to the right version? how does the parser of a specific ros2_control version handle xml files with different xsd specifications? Will we just have a specific xsd file pero ros2_control release hosted on control.ros.org (versioning done by filename), and the parser throws an error if the xml has the wrong version? This might not be directly related to this specific PR, I'm just wondering how this will work in future. |
I think its good idea to have specific xsd file per ros2_control hosted on control.ros.org and then parser throws an error if xml has wrong version. |
0bce468
to
526b714
Compare
I also wanted to ask where should I add the URDF file to validate the xml schema, for example, should I use the same URDF folder from ros2_control_test_assets, and also which ros2 control pkg is good to add |
- urdf files added for validation and unvalidation - schema xsd file added
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2466 +/- ##
==========================================
- Coverage 89.21% 89.15% -0.07%
==========================================
Files 144 145 +1
Lines 16334 16372 +38
Branches 1393 1400 +7
==========================================
+ Hits 14573 14597 +24
- Misses 1225 1231 +6
- Partials 536 544 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
We have all the assets in ros2_control_test_assets, let's put the URDF in there. the xsd is good in the hardware_interface: In this PR, or in a subsequent, we will replace the Once this is merged, I'll have a look how to publish the xsd for the different versions on control.ros.org, so that we can update all URDFs in our repositories. |
reformatting and sort ascending Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
package path updated to find urdf and xsd file
Thanks for your suggestions. Updated the code. Please LMK, if there are some other suggestions. :) |
Pull Request: Add XML schema validation for ros2_control tag and test assets
Description
This pull request introduces XML schema validation for the
<ros2_control>
tag in URDF files, addressing Issue 2173. The changes include:ros2_control.xsd
) to formalize and validate the structure of the<ros2_control>
tag.validate_xml_schema.cpp
) using libxml2 to validate URDF files against the schema.CMakeLists.txt
to install the schema and URDF directories, and to build and link the new test.ament_index_cpp
for test support.Motivation
The format of the
<ros2_control>
tag was previously unclear and often copied from demos or parser code. This PR provides a clear, machine-validated format, making it easier to create and debug hardware interface descriptions.Checklist
colcon test
andpre-commit run
).How to Test
Run the following commands to validate the schema and run the tests:
xmllint --noout --schema src/ros2_control/hardware_interface/schema/ros2_control.xsd src/ros2_control/hardware_interface/urdf/test_hardware_components.urdf colcon test --packages-select hardware_interface --ctest-args -R test_validate_xml_schema --event-handlers console_direct+
Additional Context
See the attached issue and the updated test assets for more details. Please review and let me know if further changes are needed.