Skip to content

Adjust moveit_servo clock to work with fake_hardware - #3529

Merged
AndyZe merged 4 commits into
moveit:mainfrom
Zarnack:main
Oct 31, 2025
Merged

AndyZe merged 4 commits into
moveit:mainfrom
Zarnack:main

Conversation

@Zarnack

@Zarnack Zarnack commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

This PR resolves an initialization issue in moveit_servo when used with ros2_control mock hardware components. The robot must be manually moved at startup to trigger joint state updates, otherwise moveit_servo fails to initialize due to a mismatch in clock types between the PlanningSceneMonitor and the ServoNode.

This fixes issue #3040

Description

At startup, servo_node checks whether a recent robot_state has been received by comparing the current time with the timestamp of the latest update (last_update_time_). However, when using a ros2_control mock component, it may wait indefinitely—even if joint states are being published regularly. This issue stems from a mismatch in clock types between the PlanningSceneMonitor and the moveit_servo node.

Mock components typically publish ideal, noise-free joint states, which results in the robot appearing idle.
Consequently:

  • The joint state doesn't change.
  • PlanningSceneMonitor does not update last_update_time_ using RCL_ROS_TIME. (it only updates when the joint states change)
    • Instead, last_update_time_ is updated with RCL_SYSTEM_TIME.
  • moveit_servo, however, performs its time comparisons using RCL_ROS_TIME.
  • This discrepancy causes the freshness check to fail, preventing initialization.

Solution:

This PR introduces a clock type conversion to ensure that time comparisons between moveit_servo and PlanningSceneMonitor are consistent, regardless of the underlying clock type.
This resolves the startup issue when using mock components that produce static, noise-free joint states and therefore do not trigger joint state updates.

There are no relevant API changes.

Checklist

@codecov

codecov Bot commented Jul 22, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.19%. Comparing base (4cbeb9b) to head (faa0d99).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3529      +/-   ##
==========================================
- Coverage   46.21%   46.19%   -0.02%     
==========================================
  Files         720      720              
  Lines       62742    59180    -3562     
  Branches     7594     7595       +1     
==========================================
- Hits        28991    27330    -1661     
+ Misses      33584    31683    -1901     
  Partials      167      167              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@Zarnack
Zarnack force-pushed the main branch 2 times, most recently from 79586bd to e35a295 Compare July 24, 2025 17:54

@AndyZe AndyZe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. I'm good to merge this if CI passes

@AndyZe AndyZe changed the title fixed moveit_servo to work with fake_hardware (fixes issue #3040) Adjust moveit_servo clock to work with fake_hardware Jul 24, 2025
@AndyZe
AndyZe enabled auto-merge (squash) July 24, 2025 19:10
@AndyZe

AndyZe commented Jul 24, 2025

Copy link
Copy Markdown
Member

Maybe @nbbrooks will push this across the finish line

@AndyZe
AndyZe requested review from MarqRazz and nbbrooks August 1, 2025 15:19

@MarqRazz MarqRazz left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PlanningSceneMonitor does not update last_update_time_ using RCL_ROS_TIME. (it only updates when the joint states change)
Instead, last_update_time_ is updated with RCL_SYSTEM_TIME.

This sounds like the actual issue. Have we dug into why it is hard coded to SYSTEM_TIME?

@AndyZe

AndyZe commented Aug 9, 2025

Copy link
Copy Markdown
Member

This sounds like the actual issue. Have we dug into why it is hard coded to SYSTEM_TIME?

I don't think anybody has the appetite to make changes in planning_scene_monitor right now. I'll make the anonymous namespace change, though

auto-merge was automatically disabled August 11, 2025 12:48

Head branch was pushed to by a user without write access

@MarqRazz

Copy link
Copy Markdown
Contributor

Add a note of why we needed to add the function and I think it's good.

@AndyZe
AndyZe enabled auto-merge (squash) August 11, 2025 16:47
@Zarnack

Zarnack commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

@AndyZe @nbbrooks any update on this?

@AndyZe

AndyZe commented Sep 3, 2025

Copy link
Copy Markdown
Member

I would merge it if I were able to...

@nbbrooks
nbbrooks disabled auto-merge September 3, 2025 18:46
@nbbrooks

nbbrooks commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

Are the 3 failing checks something new? That is why it has not already been auto-merged.

I can bypass the checks but it'd be good to know what is going on there.

@nbbrooks

nbbrooks commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

The checks are also failing on this PR we have been wanting to merge in for a while #2994 and I have re-run them a couple times. So if something is flaky, it must be fairly reliably flaky at this point?

@nbbrooks

nbbrooks commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

@moveit moveit deleted a comment from github-actions Bot Oct 31, 2025
@AndyZe

AndyZe commented Oct 31, 2025

Copy link
Copy Markdown
Member

I'm going to attempt to rebase and merge 👍

sebastian zarnack and others added 4 commits October 31, 2025 14:35
The planning scene monitor may use a different clock type (e.g., system clock)
than the servo node (ROS clock), causing timestamp comparison failures that
prevented servo from starting properly with fake_hardware controllers.
--> Add convert_clock_type() helper function to handle clock type conversions
@AndyZe
AndyZe enabled auto-merge (squash) October 31, 2025 19:36
@AndyZe
AndyZe merged commit 0dd551d into moveit:main Oct 31, 2025
@github-project-automation github-project-automation Bot moved this to ✅ Done in MoveIt Oct 31, 2025
@watanabeyyy

Copy link
Copy Markdown

Hi MoveIt maintainers,

Could you please backport PR #3529 (commit 0dd551d) to the jazzy branch?

Reason:

  • The fix is merged in main, but appears missing in Jazzy binary releases.
  • On ROS 2 Jazzy (binary), Servo can keep waiting at startup with fake/sim hardware:
    "Waiting to receive robot state update."

Environment:

  • ROS distro: Jazzy
  • Binary package: ros-jazzy-moveit-servo 2.12.4-1noble.20260125.051944
  • Observed in a sim_hardware setup without Gazebo /clock.

Expected:

  • Servo should initialize without indefinite waiting even when clock types differ.

No public API changes are required; this is an internal clock-type comparison fix.

Thank you.

helen9975 pushed a commit to personalrobotics/moveit2 that referenced this pull request Feb 17, 2026
* fixed moveit_servo to work with fake_hardware (fixes issue moveit#3040)

The planning scene monitor may use a different clock type (e.g., system clock)
than the servo node (ROS clock), causing timestamp comparison failures that
prevented servo from starting properly with fake_hardware controllers.
--> Add convert_clock_type() helper function to handle clock type conversions

* Function naming

* Anonymous namespace

* Better comments

---------

Co-authored-by: sebastian zarnack <[email protected]>
Co-authored-by: AndyZe <[email protected]>
@130s 130s added backport-humble Mergify label that triggers a PR backport to Humble backport-jazzy Mergify label that triggers a PR backport to Jazzy labels Sep 25, 2026
@130s

130s commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Could you please backport PR #3529 (commit 0dd551d) to the jazzy branch?

I've just attempted to trigger (by adding backport labels backport-{humble, jazzy} (humble too as the issue ticket #3040 was reported for it). Wait for mergify to create backport PRs.

@130s

130s commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Jazzy backport is made #3876

A backport PR for humble is not applicable because the bug does not exist on humble:

alexyou-fv pushed a commit to fingervision-biz/moveit2 that referenced this pull request Oct 26, 2026
* fixed moveit_servo to work with fake_hardware (fixes issue moveit#3040)

The planning scene monitor may use a different clock type (e.g., system clock)
than the servo node (ROS clock), causing timestamp comparison failures that
prevented servo from starting properly with fake_hardware controllers.
--> Add convert_clock_type() helper function to handle clock type conversions

* Function naming

* Anonymous namespace

* Better comments

---------

Co-authored-by: sebastian zarnack <[email protected]>
Co-authored-by: AndyZe <[email protected]>
(cherry picked from commit 0dd551d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-humble Mergify label that triggers a PR backport to Humble backport-jazzy Mergify label that triggers a PR backport to Jazzy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants