ROS2 Launch File Validation

Introducing an XML launch file scheme

XSD schema for validating ROS2 XML launch files.
Catch syntax errors before runtime and get IDE support.

Why

For the package.xml we have had it for years, a scheme.

But we found my muscle memory often typing type= instead of exec=.
Or $(find my_pkg) instead of $(find-pkg-share my_pkg).

And we could unit-test the node all we wanted, these errors only popped up in integration tests or even on the robot itself.
Would it not be nice if your editor already warned about you it?

How

Embed in launch file

Start your launchfile like this:

<?xml version="1.0"?>
<?xml-model href="https://nobleo.github.io/ros2_launch_validation/ros2_launch.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>

<launch>

Command-line validation

Quickstart! Validate all your launch xml files in your workspace right now!

xmllint --noout --schema <(curl -s https://nobleo.github.io/ros2_launch_validation/ros2_launch.xsd) **/*.launch.xml

This was verified internally and on some larger public repositories like autoware. Even found an issue :slight_smile:

7 Likes

Oh, wow!!!

Thanks a lot, I’m gonna give a run!

Do you know about Provide roslaunch xml schema definition downloadable · Issue #392 · ros2/launch · GitHub ? I think it would make sense to offer your development directly to the launch/launch_ros repos, wouldn’t it?

There’s still the unsolved problem of custom actions and what to do with them. I don’t know if there is a proper technical solution.

How did you actually create the schema? Is it hand-made?

Found and reported a few issues. But otherwise it works great!

For those using IntelliJ IDEs like PyCharm which do not support xml-model, use this (it should be more universal than xml-model, but it would be great if someone with VSCode confirms it works too).

<?xml version="1.0" encoding="UTF-8"?>
<launch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://nobleo.github.io/ros2_launch_validation/ros2_launch.xsd">
</launch>

I can’t imagine I didn’t pass over it in the last 6 years :slight_smile: . I’ve been meaning to join the ROSGraph working group but didn’t get to that yet :confused:.

I do like last suggestion of Emerson to parse it from the implementation. That prevents issues like running out-of-sync.

Probably yes, but ideally I’d like to get some miles on it first. And if the launch_ros implementation would lean towards parsing it out of the implementation that would be better and this would be redundant.

“Een beetje van mezelf en een beetje van maggie”
It’s a hand-made implementation based on all launchfiles I had available. Then I had copilot help me find some niches in the implementation.

Well thank you for your enthousiasm!

Personally I didn’t like the noNamespaceSchemaLocation implementation as it leads to even more verbose template code. And it’s deviating from what we do in package.xml files.
How does your editor cope with the package.xml syntax?
PS your encoding is deprecated.

1 Like

I think it’s just a problem of IntelliJ IDEs. xml-model also doesn’t do anything in package.xml .