Open BenBlumer opened 1 month ago
Yes, PRs for this would definitely be accepted. Probably best to also add a test with example borked URDFs so we continue to handle that in the future if things get updated at any point.
For the extra spaces, I imagine it might also be possible to drop elements from the xyz_pieces vector if they are empty strings? Might save some people time by not having an exception to track down.
If I recall correctly, the reason we didn't use urdfdom when originally implementing this was that certain un-parsed elements would get dropped (this was especially true of things like gazebo add-ons that aren't part of the "official" spec of URDF, but widely used). This was initially implemented a decade ago though, so it's possible that has improved.
There's a few sneaky URDF parsing issues that caught me:
1) in offsets.cpp:
boost::split(rpy_pieces, rpy_str, boost::is_any_of(" "));
If the model doesn't contain an explicit RPY, this segfaults.2) This is the real killer: the way the XYZ and RPY strings are parsed, if there's two spaces between elements,
rpy_pieces.size()
and/orxyz_pieces.size()
equal 4. That silently refuses to apply transformations, but outputs a URDF as if everything is hunky dory. These are the relevant lines in offsets.cpp:These are examples of problematic URDFs: I'm not sure if these are to URDF "spec" or not, but they do pass
check_urdf
without complaint.I'm happy to submit a PR to fix (1) and throw an exception on (2). Before doing so, I'd like to get your thoughts: is it better to address these things as they are, or implement one of the URDF parsing libraries like [urdfdom(http://wiki.ros.org/urdfdom_py)?