Skip to content

Use use_count in LockedRobotState - #3792

Open
Tobias-Fischer wants to merge 3 commits into
moveit:mainfrom
Tobias-Fischer:codex/robostack-moveit-robot-interaction-use-count
Open

Tobias-Fischer wants to merge 3 commits into
moveit:mainfrom
Tobias-Fischer:codex/robostack-moveit-robot-interaction-use-count

Conversation

@Tobias-Fischer

@Tobias-Fischer Tobias-Fischer commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

This is part of an effort to contribute RoboStack downstream patches back upstream.

Origin: patch/ros-rolling-moveit-ros-robot-interaction.patch, authored by Daisuke Nishimatsu.

LockedRobotState currently uses std::shared_ptr::unique() to decide whether it can modify the stored state in place. That API was removed in C++20. Comparing use_count() with one preserves the existing copy-on-write behavior while keeping this code compatible with toolchains that build MoveIt with newer C++ standards.

Summary by CodeRabbit

  • Refactor
    • Updated how shared state ownership is checked when setting or modifying robot state; behavior remains unchanged.

This upstreams the C++20-compatible part of the RoboStack moveit_ros_robot_interaction build fix.

std::shared_ptr::unique() was removed in C++20. Comparing use_count() with one keeps the existing copy-on-write behavior while avoiding the removed API in toolchains that build MoveIt with newer C++ standards.

Origin: patch/ros-rolling-moveit-ros-robot-interaction.patch, authored by Daisuke Nishimatsu.
Signed-off-by: Tobias Fischer <[email protected]>
@Tobias-Fischer

Copy link
Copy Markdown
Contributor Author

FYI @wep21 and @traversaro: I opened this while upstreaming RoboStack patches tracked in RoboStack/robostack#124. This one comes from patch/ros-rolling-moveit-ros-robot-interaction.patch.

@codecov

codecov Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.95%. Comparing base (8c99e52) to head (534ebc3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3792      +/-   ##
==========================================
+ Coverage   48.92%   48.95%   +0.04%     
==========================================
  Files         735      735              
  Lines       62699    62744      +45     
  Branches     7629     7638       +9     
==========================================
+ Hits        30669    30711      +42     
- Misses      32030    32033       +3     

☔ View full report in Codecov by Harness.
📢 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.

@mergify

mergify Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2b24033 and 534ebc3.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The ownership checks in LockedRobotState::setState and modifyState now use state_.use_count() instead of state_.unique(). The copy-on-write conditions remain unchanged.

Changes: Locked robot state

Layer / File(s) Summary
Copy-on-write ownership checks
moveit_ros/robot_interaction/src/locked_robot_state.cpp
setState checks whether state_ has one owner. modifyState checks whether it has more than one owner. Both checks now use use_count(). The copy-on-write conditions are unchanged.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Refactor

Merge Risk: Minimal · previous review 2b240

This change replaces an API removed in C++20 with an equivalent ownership check. Copy-on-write behavior is unchanged, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Use use_count in LockedRobotState" names the primary change. The PR replaces std::shared_ptr::unique() with a use_count() comparison in LockedRobotState::setState and modifyState, so the ti…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Use use_count in LockedRobotState" names the primary change. The PR replaces std::shared_ptr::unique() with a use_count() comparison in LockedRobotState::setState and modifyState, so the title matches the changeset. It is short and specific. It does not state the reason (C++20 removal of unique()), but that detail is not required for a pass.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8c99e52 and 2b24033.

Files selected for processing: 1

  • moveit_ros/robot_interaction/src/locked_robot_state.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@mergify

mergify Bot commented Nov 24, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@130s
130s enabled auto-merge (squash) November 25, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants