Skip to content

[RQT_JTC] add unit tests for parse_joint_limits#2281

Merged
christophfroehlich merged 3 commits intoros-controls:masterfrom
lakhmanisahil:feat/rqt-jtc-unit-tests
Apr 12, 2026
Merged

[RQT_JTC] add unit tests for parse_joint_limits#2281
christophfroehlich merged 3 commits intoros-controls:masterfrom
lakhmanisahil:feat/rqt-jtc-unit-tests

Conversation

@lakhmanisahil
Copy link
Copy Markdown
Contributor

Closes #2253

What this PR does

get_joint_limits() read from a global description variable set only by a ROS topic subscription — impossible to unit test without a live node.

This PR extracts all parsing logic into a new pure function parse_joint_limits(urdf_string, ...) that takes the URDF directly as a string with no ROS dependency. get_joint_limits() becomes a thin wrapper that reads the global and delegates to it. The minidom parsing logic itself is unchanged.

Files changed

File Change
joint_limits_urdf.py Extract parse_joint_limits() from get_joint_limits()
test/test_joint_limits_urdf.py 23 pytest tests, fully ROS-free
test/__init__.py New (marks test dir as Python package)
package.xml Add python3-pytest test dependency

Tests (23 total, all passing)

  • Revolute joint — correct min/max position, velocity, limit flag
  • Continuous joint — defaults to ±π when no bounds given
  • Fixed joints — silently ignored
  • Multiple mixed joints — all handled correctly
  • safety_controller soft limits — narrowed when flag is True, ignored when False
  • Mimic joints — excluded from free_joints
  • Missing <limit> for a required joint → raises with clear message
  • Missing lower/upper on revolute → raises (minidom returns "", our code raises)
  • Missing velocity → raises (same reason — our logic, not minidom's)
Screenshot from 2026-04-04 00-14-26

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 91.89189% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.19%. Comparing base (6c1299f) to head (68fda72).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...t_joint_trajectory_controller/joint_limits_urdf.py 78.18% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2281      +/-   ##
==========================================
+ Coverage   84.72%   85.19%   +0.46%     
==========================================
  Files         153      154       +1     
  Lines       15362    15457      +95     
  Branches     1332     1334       +2     
==========================================
+ Hits        13016    13169     +153     
+ Misses       1858     1797      -61     
- Partials      488      491       +3     
Flag Coverage Δ
unittests 85.19% <91.89%> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ajectory_controller/test/test_joint_limits_urdf.py 100.00% <100.00%> (ø)
...t_joint_trajectory_controller/joint_limits_urdf.py 77.33% <78.18%> (+77.33%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good, I only have some questions..

Comment thread rqt_joint_trajectory_controller/test/test_joint_limits_urdf.py Outdated
Comment thread rqt_joint_trajectory_controller/test/test_joint_limits_urdf.py Outdated
@lakhmanisahil
Copy link
Copy Markdown
Contributor Author

Hello @christophfroehlich, I’ve responded to the suggested changes. PTAL and let me know if anything else is needed.
I’ll update the PR accordingly.

@lakhmanisahil
Copy link
Copy Markdown
Contributor Author

Hey @christophfroehlich, i have addressed the suggested changes, PTAL.
Thank You

Copy link
Copy Markdown
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, now it looks perfect!

@christophfroehlich christophfroehlich added backport-humble Triggers PR backport to ROS 2 humble. backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted. labels Apr 12, 2026
@christophfroehlich christophfroehlich merged commit 4ccff70 into ros-controls:master Apr 12, 2026
18 checks passed
mergify bot pushed a commit that referenced this pull request Apr 12, 2026
mergify bot pushed a commit that referenced this pull request Apr 12, 2026
mergify bot pushed a commit that referenced this pull request Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-humble Triggers PR backport to ROS 2 humble. backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rqt_joint_trajectory_controller: Add unit tests

2 participants