Skip to content

Migrate the SAM2 segmentation example Behavior to the SAM2Segment API - #832

Draft
griswaldbrooks wants to merge 1 commit into
mainfrom
fm/moveitpro-ml10-e3-sam2-example
Draft

Migrate the SAM2 segmentation example Behavior to the SAM2Segment API#832
griswaldbrooks wants to merge 1 commit into
mainfrom
fm/moveitpro-ml10-e3-sam2-example

Conversation

@griswaldbrooks

@griswaldbrooks griswaldbrooks commented Aug 5, 2026

Copy link
Copy Markdown

[written by AI]

needs: moveit_pro/#21152

Motivation

moveit_pro#21152 adds moveit_pro_ml::SAM2Segment, the runtime-neutral SAM2 facade over the shared model pool. ExampleSAM2Segmentation is the last consumer of the legacy moveit_pro_ml::SAM2 outside moveit_pro, so this migration hard-blocks the deletion of SAM2 / ONNXImage / PointPrompt in moveit_pro#21162.

Brief description

ExampleSAM2Segmentation now loads SAM2Segment from a bundle manifest and speaks typed tensors.

  • Ports. Adds model_package (moveit_pro_sam2), model_bundle_manifest (models/model.yaml), runtime_id (onnxruntime), matching the shape the in-repo SAM3 and SAM2 automasking Objectives already use (Switch SAM3 Objectives to the model bundle manifest #802, Add SAM2 automasking ModelPool bundle manifest for factory_sim #831). All three default to today's behavior.
  • Typed API. ONNXImage in/out becomes data::Tensor<float, data::format::NHWC> in and data::Tensor<float, data::format::HW> out; PointPrompt becomes data::Point. Errors arrive as tl::expected with InferenceError instead of a thrown std::invalid_argument.
  • Load moves out of the constructor. The legacy code loaded ~900 MB of graphs during tree construction. Loading now happens on first tick through the shared pool, so an unticked tree pays nothing and two Objectives on one bundle share a copy. The model latches to the bundle it first loaded and fails rather than silently serving a stale model on a port change — the pipeline has no hot reload.
  • RGBA conversion bug fix. set_onnx_image_from_ros_image picked its stride from an inverted test (encoding != "rgb8" ? 3 : 4), then advanced the destination index by that stride while reading three consecutive source bytes, so neither rgb8 nor rgba8 converted correctly. The replacement walks pixels with separate source and destination offsets and validates the buffer against its declared dimensions.

Paired: moveit_pro_sam2#3 adds the manifest this loads; the src/moveit_pro_sam2 submodule is bumped to that branch.

How it was tested

  • Migrated translation unit compiles clean (g++ -std=c++20 -fsyntax-only) against moveit_pro#21152's installed moveit_pro_ml headers and the workspace behavior-interface headers.
  • Grep-verified: no SAM2 / ONNXImage / PointPrompt / onnx_ references remain in this workspace.
  • Not run end-to-end: this Behavior has no Objective here, so there is no runnable tree. Full-stack validation is this PR's CI, building against moveit_pro#21152's image via the needs: token.

Release notes

None

…egment

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cd4871ae-4181-4b89-a3b9-0e8de6e77fe3

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

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

  • lab_sim
    • jazzy: no report produced — see run logs
  • hangar_sim
    • jazzy: no report produced — see run logs

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