Skip to content

Migrate Behaviors from shared_resources_ to getBehaviorContext()#773

Merged
JWhitleyWork merged 1 commit into
mainfrom
refactor/migrate-shared-resources-to-get-behavior-context
Jul 15, 2026
Merged

Migrate Behaviors from shared_resources_ to getBehaviorContext()#773
JWhitleyWork merged 1 commit into
mainfrom
refactor/migrate-shared-resources-to-get-behavior-context

Conversation

@JWhitleyWork

Copy link
Copy Markdown
Member

[written by AI]

Problem

MoveIt Pro 10.0 (PickNikRobotics/moveit_pro#20288) removes protected across the C++ API and privatizes SharedResourcesNode::shared_resources_ behind the public getBehaviorContext() accessor. Behaviors in this workspace that dereference shared_resources_-> no longer compile against the 10.0 base image — lab_sim_behaviors fails first (compute_tray_place_positions_using_apriltags.cpp:109: 'shared_resources_' was not declared in this scope).

Change

Mechanical migration of every shared_resources_ member reference to the getBehaviorContext() accessor across example_behaviors and lab_sim_behaviors (7 files, 16 call sites). #include <.../shared_resources_node.hpp> lines are unchanged — the base class and header keep their names; only the member access moved behind an accessor. This is the migration documented in the moveit_pro 10.0 user-workspace migration guide.

Validation rides on the paired moveit_pro PR: the needs: token below pins example_ws / integration to that PR's backend image (which defines getBehaviorContext()), not the released main image. Merge order is moveit_pro first, then this PR.

needs: moveit_pro/#20288

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b1b262c-df61-4c28-8111-2b177f3c7f30

📥 Commits

Reviewing files that changed from the base of the PR and between 35f72ae and ef9d6b5.

📒 Files selected for processing (7)
  • src/example_behaviors/src/example_convert_mtc_solution_to_joint_trajectory.cpp
  • src/example_behaviors/src/example_create_string_msg.cpp
  • src/example_behaviors/src/example_delayed_message.cpp
  • src/example_behaviors/src/example_fibonacci_action_client.cpp
  • src/example_behaviors/src/example_hello_world.cpp
  • src/example_behaviors/src/example_publish_color_rgba.cpp
  • src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/example_behaviors/src/example_hello_world.cpp
  • src/example_behaviors/src/example_create_string_msg.cpp
  • src/example_behaviors/src/example_delayed_message.cpp
  • src/example_behaviors/src/example_convert_mtc_solution_to_joint_trajectory.cpp
  • src/example_behaviors/src/example_fibonacci_action_client.cpp
  • src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved logging behavior to consistently use the node’s behavior context across multiple example behaviors, including success/failure and feedback/result messages.
    • Fixed robot model loading and publisher initialization to use the correct behavior context node.
    • Corrected transform and visualization handling in the tray placement computation to reliably use the behavior context, while preserving existing trajectory and output behavior.

Walkthrough

The changes replace shared_resources_ access with getBehaviorContext() for nodes, loggers, transform buffers, and visualization initialization across example and lab simulation behaviors. Existing control flow, messages, topics, and outputs remain unchanged.

Changes

Behavior context migration

Layer / File(s) Summary
Example behavior context access
src/example_behaviors/src/*
Example behaviors now use the behavior context for robot model loading, logging, and color publisher creation.
AprilTag behavior context access
src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp
The AprilTag behavior now uses the behavior context for logging, transform lookup, and visualization publisher initialization.

Possibly related issues

  • PickNikRobotics/moveit_pro issue 20370: Directly concerns migrating behavior implementations from shared_resources_ to getBehaviorContext().
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately matches the migration from shared_resources_ access to getBehaviorContext() across the touched behavior files.
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.
Human Review Check ✅ Passed Only internal implementation calls were switched to getBehaviorContext(); no public API, launch, infra, or core behavior changes.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

@github-actions

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

@github-actions

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

@JWhitleyWork
JWhitleyWork force-pushed the refactor/migrate-shared-resources-to-get-behavior-context branch from 19e5921 to 35f72ae Compare July 14, 2026 22:49
@JWhitleyWork JWhitleyWork self-assigned this Jul 14, 2026
@JWhitleyWork JWhitleyWork added this to the 10.0.0 milestone Jul 14, 2026
@JWhitleyWork
JWhitleyWork marked this pull request as ready for review July 14, 2026 22:50
…rces_

MoveIt Pro 10.0 (PickNikRobotics/moveit_pro#20288) privatizes
SharedResourcesNode::shared_resources_ behind the public getBehaviorContext()
accessor. Update the example and lab_sim Behaviors to the new API so they
compile against the 10.0 base image.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JWhitleyWork
JWhitleyWork force-pushed the refactor/migrate-shared-resources-to-get-behavior-context branch from 35f72ae to ef9d6b5 Compare July 14, 2026 22:52

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp (1)

171-178: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: cache getBehaviorContext() locally.

getBehaviorContext() is invoked twice back-to-back here (and multiple more times later in tick()). If the accessor is cheap (e.g., returns a member pointer), this is purely cosmetic; consider caching it in a local variable at the top of tick() for readability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp`
around lines 171 - 178, Optionally cache the result of getBehaviorContext() in a
local variable at the start of tick(), then reuse that variable throughout the
method, including the transform_buffer_ptr and logger accesses, without changing
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp`:
- Around line 171-178: Optionally cache the result of getBehaviorContext() in a
local variable at the start of tick(), then reuse that variable throughout the
method, including the transform_buffer_ptr and logger accesses, without changing
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8a912001-1ba4-45b1-b0c7-395b5b30994d

📥 Commits

Reviewing files that changed from the base of the PR and between 7e20f67 and 35f72ae.

📒 Files selected for processing (7)
  • src/example_behaviors/src/example_convert_mtc_solution_to_joint_trajectory.cpp
  • src/example_behaviors/src/example_create_string_msg.cpp
  • src/example_behaviors/src/example_delayed_message.cpp
  • src/example_behaviors/src/example_fibonacci_action_client.cpp
  • src/example_behaviors/src/example_hello_world.cpp
  • src/example_behaviors/src/example_publish_color_rgba.cpp
  • src/lab_sim_behaviors/src/compute_tray_place_positions_using_apriltags.cpp

@github-actions

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

@github-actions

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

@JWhitleyWork
JWhitleyWork merged commit 9c894f4 into main Jul 15, 2026
16 checks passed
@JWhitleyWork
JWhitleyWork deleted the refactor/migrate-shared-resources-to-get-behavior-context branch July 15, 2026 15:36
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.

1 participant