Skip to content

Fix: factory_sim bin picking fails when brackets settle near the workspace boundary#754

Merged
griswaldbrooks merged 1 commit into
mainfrom
fix/20020-factory-sim-unreachable-brackets
Jul 3, 2026
Merged

Fix: factory_sim bin picking fails when brackets settle near the workspace boundary#754
griswaldbrooks merged 1 commit into
mainfrom
fix/20020-factory-sim-unreachable-brackets

Conversation

@griswaldbrooks

Copy link
Copy Markdown

[written by AI]

Fixes PickNikRobotics/moveit_pro#20020

Problem

The left bin in factory_sim deliberately straddles the LR Mate 200iD's reachable workspace (measured boundary ≈0.70–0.75 m planar at pick height, orientation-dependent). Brackets settle with arbitrary yaw aligned to the rotated bin, which swings the hardcoded pick offset toward the bin's far side. Pick and Place Brackets from Left Bin inherits the settled yaw exactly, so depending on where the physics settles each launch, the first pick either has no IK solution (pose IK (0/1) in pick_part) or plans but fails the 55 mm approach push (Cartesian Motion: failed to move full distance). Machine load shifts the settle, which is why the failure reproduces 100% on some machines and intermittently on others.

Approach

A suction grasp on the flat bracket face is yaw-free about the face normal, so:

  • vacuum_pick_bracket_part_subtree.xml — keeps the same pick point but builds 8 approach candidates at 45° yaw increments about the part's settled face normal (respecting settled pitch/roll), and replaces the single-pose SetupMTCPlanToPose with SetupMTCConnectWithProRRT + SetupMTCBatchPoseIK, letting MTC plan through whichever yaw solves. This converts most of the bin's far side from unpickable to pickable (86% of the bin interior is reachable tool-down at some yaw vs. only 10% at every yaw).
  • drop_bracket_part_on_jig_subtree.xml — the jig drop target is re-expressed for the attached part's own frame (ik_frame="{part_name}") instead of tool0. The attached body carries the true part-to-gripper transform (the MuJoCo weld freezes the grasp-time relative orientation), so the alignment holes land on the jig posts regardless of which grasp yaw was chosen. The part-frame pose was derived by composing the nominal grasp transform out of the previous tool0 numbers.
  • pick_and_place_brackets_from_left_bin.xml — if no sampled yaw plans, the objective deactivates the vacuum, logs INFO ("Could not plan a pick … skipping the remaining bracket picks"), and ends cleanly instead of aborting with PLANNING_FAILED. This matches the sim's teaching purpose (reachable vs. unreachable areas). Also migrates the deprecated Repeat decorator to RepeatUnlessFailureWithinTick.

The bins intentionally stay where they are — reachable and unreachable regions are the point of this sim.

Manual verification

  • Stock scene, fresh launch ×2: full 3-cycle objective SUCCEEDED.
  • Staged worst case (bracket at 90° yaw, pick point at r=0.716 — beyond the measured r=0.711 failure pose from the reproduction): pick succeeded at a non-zero sampled yaw and the compensated jig drop was confirmed by the fixed-pose jig re-pick succeeding.
  • Staged unpickable case (pick point r≈0.82, beyond all yaws): INFO logged, remaining picks skipped, objective ended SUCCEEDED.
  • Reproduction evidence, an IK reachability study of the bin (calibrated 3/3 against the live pose_ik behavior), and the full run ledger are attached to the linked issue.

Open question for reviewers

On an unpickable part this gives up on all remaining picks rather than re-detecting, because registration would find the same far bracket again (the ICP guess pose biases to the bin's far side). If retry-per-remaining-part is preferred, it is a small policy change in the top-level tree.

Release notes

  • Bug Fix: Fixed factory_sim's Pick and Place Brackets from Left Bin objective intermittently failing with a planning failure by sampling vacuum-grasp yaws at the pick point, compensating the jig placement for the chosen grasp, and skipping parts that settle outside the robot's reachable workspace with an informative log message instead of aborting.

🤖 Generated with Claude Code

@griswaldbrooks griswaldbrooks added this to the 10.0.0 milestone Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 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: d934e0e6-020f-4ccb-9586-d0f9b0f3f16f

📥 Commits

Reviewing files that changed from the base of the PR and between a5c691e and 6a5d8b2.

📒 Files selected for processing (3)
  • src/factory_sim/objectives/drop_bracket_part_on_jig_subtree.xml
  • src/factory_sim/objectives/pick_and_place_brackets_from_left_bin.xml
  • src/factory_sim/objectives/vacuum_pick_bracket_part_subtree.xml
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/factory_sim/objectives/drop_bracket_part_on_jig_subtree.xml
  • src/factory_sim/objectives/vacuum_pick_bracket_part_subtree.xml
  • src/factory_sim/objectives/pick_and_place_brackets_from_left_bin.xml

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Improved bracket pick-and-place flow with early stopping when a bracket can’t be picked, avoiding unnecessary additional attempts.
    • Enhanced bracket-part pickup by generating multiple approach options, increasing the chances of finding valid pickup motions.
  • Bug Fixes

    • Fixed bracket part drop targeting so placement uses the correct local pose frame and orientation for more accurate jig placement.
    • Improved motion planning reliability for approaching bracket parts by evaluating multiple candidate approaches rather than a single target.

Walkthrough

This PR updates three factory_sim behavior tree XML objectives: it changes drop-pose framing for the jig drop step, expands vacuum-pick planning to multiple rotated approach candidates, and adds early-stop control plus an unpickable branch to the left-bin pick-and-place loop.

Changes

Pick and place planning fixes

Layer / File(s) Summary
Approach pose candidate generation and batch IK planning
src/factory_sim/objectives/vacuum_pick_bracket_part_subtree.xml
Replaces single approach pose generation with a vector of rotated {approach_candidates}, then switches planning from SetupMTCPlanToPose to SetupMTCConnectWithProRRT plus SetupMTCBatchPoseIK.
Drop pose orientation and ik_frame update
src/factory_sim/objectives/drop_bracket_part_on_jig_subtree.xml
Updates the {drop_pose} pose stamp orientation and position, and changes the target pose ik_frame from tool0 to {part_name}.
Halt-picking loop control and unpickable branch
src/factory_sim/objectives/pick_and_place_brackets_from_left_bin.xml
Adds halt_picking, replaces the fixed repeat loop with RepeatUnlessFailureWithinTick plus Precondition, restructures the cycle into pickable/unpickable branches, and stops later cycles after a failed pick-planning attempt.

Possibly related issues

  • PickNikRobotics/moveit_pro#20020: This PR changes the same pick_and_place_brackets_from_left_bin objective and its pick/planning flow described in the issue.

Suggested reviewers: bkanator, marioprats

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly matches the changed pick, drop, and loop-handling logic in factory_sim.
Linked Issues check ✅ Passed The changes address the reported left-bin planning failure with yaw sampling, frame-correct jig placement, and graceful loop exit.
Out of Scope Changes check ✅ Passed No unrelated changes stand out; all edits support the left-bin pick-and-place fix described in the issue.
Human Review Check ✅ Passed Changes are confined to 3 factory_sim objective XMLs; no auth/infra/public API/core behavior/launch-script files are touched.

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

@griswaldbrooks griswaldbrooks marked this pull request as ready for review July 3, 2026 00:57

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/factory_sim/objectives/pick_and_place_brackets_from_left_bin.xml`:
- Around line 122-126: The LogMessage in the detect-and-pick fallback is too
specific for a branch that can be reached by multiple failures, not just
grasp-yaw planning. Update the message in
pick_and_place_brackets_from_left_bin.xml near the else path so it reflects the
actual failure scope from the surrounding DetectAndPick sequence, and avoid
attributing the cause to “any sampled grasp yaw” unless that node is the only
possible failure. Keep the wording generic enough to help identify the failing
node from logs, or make it conditional on the specific child node that failed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4620e185-d1b4-4a4e-a2d4-10ae2844252e

📥 Commits

Reviewing files that changed from the base of the PR and between b61712c and a5c691e.

📒 Files selected for processing (3)
  • src/factory_sim/objectives/drop_bracket_part_on_jig_subtree.xml
  • src/factory_sim/objectives/pick_and_place_brackets_from_left_bin.xml
  • src/factory_sim/objectives/vacuum_pick_bracket_part_subtree.xml

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

…in picking

The left bin deliberately straddles the LR Mate 200iD's reachable
workspace, and brackets settle with arbitrary yaw, so the single
hardcoded pick orientation intermittently has no IK solution
(pose IK 0/1) or fails the 55mm approach push. A suction grasp on the
flat bracket face is yaw-free, so the pick now batches 8 approach
candidates at 45-degree yaw increments about the part face normal via
SetupMTCBatchPoseIK. The jig drop targets the attached part frame
instead of tool0, so any grasp yaw still lands the alignment holes on
the jig posts. If no sampled yaw plans, the objective logs INFO and
ends cleanly instead of aborting with PLANNING_FAILED. Also migrates
the deprecated Repeat decorator to RepeatUnlessFailureWithinTick.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@griswaldbrooks griswaldbrooks force-pushed the fix/20020-factory-sim-unreachable-brackets branch from a5c691e to 6a5d8b2 Compare July 3, 2026 01:06
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

MoveIt Pro Example WS - Objectives Integration Test Report

@griswaldbrooks griswaldbrooks merged commit 53a5286 into main Jul 3, 2026
16 checks passed
@griswaldbrooks griswaldbrooks deleted the fix/20020-factory-sim-unreachable-brackets branch July 3, 2026 01:56
@JWhitleyWork

Copy link
Copy Markdown
Member

/backport v9.4

@backport-pr-creator

Copy link
Copy Markdown

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.

2 participants