[rqt_jtc] Use urdf_parser_py#2254
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2254 +/- ##
==========================================
- Coverage 85.13% 85.10% -0.04%
==========================================
Files 154 154
Lines 15423 15417 -6
Branches 1335 1338 +3
==========================================
- Hits 13130 13120 -10
- Misses 1800 1802 +2
- Partials 493 495 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
christophfroehlich
left a comment
There was a problem hiding this comment.
Thank you! I think it is time for adding unittest with #2253 first, then it's easier to check if this PR is not causing any troubles.
|
Hi @christophfroehlich, since issue #2253 is now closed, should I continue working on this PR or close it and create a new one based on the recent changes made to the |
|
Why not continuing here? |
Got it, thanks. |
|
Hi @christophfroehlich, I have rebased onto the current master with the whitelist preprocessing. Standard URDF tags (link, joint, transmission, material) are kept, and everything else is stripped before parsing. 21/22 unit tests pass. The one failure is test_missing_velocity_raises, which asserted on the message "Missing velocity limits" produced by our old application code.
|
There are two ways I am thinking of handling this:
I’m leaning toward the first option since it reflects the new behavior. I just wanted to confirm before changing a test that recently merged. Please let me know what you prefer. |
Replace xml.dom.minidom parsing with urdf_parser_py.urdf.Robot. Non-URDF tags such as <ros2_control> and <gazebo> are stripped before parsing via a whitelist of standard URDF elements (link, joint, transmission, material), addressing review feedback about handling all vendor extensions rather than only ros2_control.
|
Sure, just change the test if it is no behavior change but only a different message. |
|
Hi @christophfroehlich, I’ve updated the changes and successfully tested them locally. PTAL. |
christophfroehlich
left a comment
There was a problem hiding this comment.
Thanks for the follow-up. I have some comments, see below
| # urdf_parser_py defaults lower/upper to 0.0 when the attributes are | ||
| # absent in the URDF. We treat min >= max as "limits missing" and | ||
| # either fall back to -pi..pi for continuous joints or raise for | ||
| # revolute joints where valid bounds are required. | ||
| minval = joint.limit.lower if joint.limit.lower is not None else 0.0 | ||
| maxval = joint.limit.upper if joint.limit.upper is not None else 0.0 |
There was a problem hiding this comment.
if it is 0.0 when absent, when can it be None?
There was a problem hiding this comment.
Yes, you are right, i was doing initially to play safe,
I checked this now and urdf_parser_py returns 0 for missing lower/upper, not None. The conditional was dead code.
Will push the changes soon.
|
Hello @christophfroehlich, updated and addressed the reviews, PTAL. |
saikishor
left a comment
There was a problem hiding this comment.
Just one minor nitpick, rest LGTM
christophfroehlich
left a comment
There was a problem hiding this comment.
please see the open threads (and please don't resolve them by yourself, this should be done by reviewers only)
Hi, apologies for that. I’ve reopened all the threads I had marked as resolved and reviewed the open threads. |
christophfroehlich
left a comment
There was a problem hiding this comment.
Thank you, LGTM! The failing tests are not related, so let's move on
bc28346
into
ros-controls:master


Closes #891
Description
This PR replaces the manual XML DOM parsing in
joint_limits_urdf.pywithurdf_parser_py.urdf.Robot, resolving the long-standing TODO in the code.This is a fresh implementation inspired by the stale PR #1982. It incorporates the review feedback and also fixes an additional bug that was not handled in that earlier attempt.
Why this change?
The previous implementation used
xml.dom.minidomto manually parse URDF XML, extract attributes, and handle missing values using exceptions. This approach was fragile and unnecessarily complex.The code already had a TODO suggesting migration to
urdf_parser_py, but an earlier attempt failed due to:Required attribute not set in XML: upper.This issue has now been resolved in newer versions ofurdf_parser_py, making the migration possible.What changed?
joint_limits_urdf.pyReplaced manual XML parsing (
xml.dom.minidom) withurdf_parser_py(using
Robot.from_xml_string()androbot.joints)Added preprocessing to remove
<ros2_control>tags before parsing(needed because
urdf_parser_pythrows an error on unknown tags)Fixed how missing joint limits are handled
0.0minval >= maxvalRemoved the old TODO comment.
package.xmlHow to reproduce and test
Setup with RRBot example 1
Expected output should show:
joint_trajectory_position_controllerasactivejoint_state_broadcasterasactiveforward_position_controllerasinactiveLaunch the GUI
# Terminal 3 ros2 run rqt_joint_trajectory_controller rqt_joint_trajectory_controllerExpected behavior
After this PR
urdf_parser_py.