Skip to content

Add OpenArm-Handover bimanual task - #30

Open
bupeshr wants to merge 2 commits into
enactic:mainfrom
bupeshr:robot-handover
Open

bupeshr wants to merge 2 commits into
enactic:mainfrom
bupeshr:robot-handover

Conversation

@bupeshr

@bupeshr bupeshr commented Nov 4, 2026

Copy link
Copy Markdown

This PR introduces the OpenArm-Handover task, a new bimanual RL environment where the left arm (giver) must safely transfer a free object to the right arm (receiver).

Key Implementations

  • Physics Configuration: Leverages the existing bimanual lift setup for robot instantiation. Introduces a 50 mm free block with tuned solref (0.005, 1.0) and increased simulation nconmax to 200 to ensure stable contact physics when both grippers manipulate the object.
  • Transfer State Machine: Implements a strict overlap streak buffer to prevent false positives from accidental collisions. The internal _transferred state latches only after both arms maintain a simultaneous grip for 10 consecutive steps.
  • Phased Reward Shaping: Gates dense rewards based on the current transfer state. The giver_lift reward pays only before the transfer, while giver_release and carry_to_target activate only after the overlap latch triggers.
  • Curriculum Learning: Adds the reset_giver_held_high initialization event. This starts 50% of the training episodes with the left arm already holding the block in a raised position, accelerating the right arm's learning process.
  • Testing Suite: Includes test_handover_env.py to verify observation spaces, action dimensions, latch logic, and geometry constants.

Reproduce

The policy converges with a 100% success rate on the evaluation batch.

Training:

uv run openarm-mjlab-train OpenArm-Handover \
  --env.scene.num-envs 4096 \
  --env.viewer.height 480 \
  --env.viewer.max-extra-envs 0 \
  --env.viewer.width 640 \
  --video True

Play trained checkpoint:

uv run openarm-mjlab-play OpenArm-Handover --checkpoint-file <./checkpoint/path/latest.pt>

Run Eval:

uv run openarm-mjlab-eval OpenArm-Handover --success-term handed_over --checkpoint <./checkpoint/path/latest.pt>

Evaluation Output:

task             OpenArm-Handover
checkpoint       logs/rsl_rl/openarm_handover/latest.pt
episodes         256
episode budget   500 steps (10.0s at dt=0.02)
success term     handed_over   (of: time_out, handed_over, block_fell)

--- results ------------------------------------------------
success rate (handed_over): 1.000
  time_out: 0.000
  block_fell: 0.000
episode length steps: mean 30.7, median 30.0, budget 500
openARM-handover

@kou

kou commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Thanks. I tried this with Claude Code and Claude Code says the following. Could you check it?


I checked out the branch and reproduced it locally. The success rate reproduces, but every success still has the giver touching the block (item 1 below), so I think the success condition needs fixing before merge.

Reproduction (RTX 4060 8GB)

  • 4096 envs ran out of GPU memory on this card, so I trained with --env.scene.num-envs 2048 for 3000 iterations. Success started appearing around iteration 2000.

  • openarm-mjlab-eval, 1024 episodes, with the reset_giver_held_high probability overridden:

    held-high probability success (handed_over) episode length (mean / median)
    0.5 (as configured) 99.7% 26.8 / 26
    0.0 (always from the table) 99.8% 30.0 / 28
    1.0 (always held high) 100% 22.2 / 22

    So the reported rate doesn't depend on the held-high curriculum, which also stays active during eval because eval.py loads the training config.

  • I traced a rollout to check that the ~30-step episodes aren't a shortcut. The sequence is right:

    • the giver grips at step ~7 and the receiver at ~12;
    • the latch fires at ~21;
    • the giver drops to one pad at ~24 (see item 1);
    • the episode ends at ~27.

    The receiver never gripped before the giver (63/63 episodes). Scripted zero, open-gripper and random actions never trigger handed_over.

Requests

  1. The giver never actually releases. handed_over requires ~both_pads_on_block(giver), and that holds while one giver pad is still on the block. I wrapped the termination to record giver contact at the step it fires (trained checkpoint, 1024 episodes each):

    held-high prob successes giver pads touching at success: 0 / 1 / 2
    0.0 1024/1024 0 / 1024 / 0
    0.5 1023/1024 0 / 1023 / 0

    The remaining pad presses with a median of ~53 N (max ~155 N) against a 50 g block, so the giver is still squeezing the block, not just touching it. The policy learned to lift one finger off instead of letting go. I suggest requiring no giver contact, e.g. ~_pads_touching(env, sensor_giver).any(dim=1), ideally sustained for a few steps. giver_release_reward uses the same ~both_pads_on_block gate and should probably change the same way. The success rate then needs to be re-measured.

  2. Block speed. In the traced rollout the giver swings the block toward the receiver at more than 2 m/s (~4.6 cm per 20 ms step). That works in sim but looks more like throwing than handing over. Only joint velocity is penalized. If sim-to-real is a goal, consider a block-velocity penalty or cap.

  3. Lint. pre-commit will fail:

    • ruff check: D100 (missing module docstring) in handover_env_cfg.py, mdp.py and rl_cfg.py;
    • ruff format: 5 files would be reformatted;
    • several files are missing a trailing newline.
  4. License headers. Please add the Apache-2.0 header used in the other source files to all new files.

  5. Success weight. Could you add a short derivation comment for weight=6200.0, like the one in bimanual_lift_env_cfg.py?

    • By my count, a policy that never succeeds can collect about 7.8/s. That is reach (1.7) + pinch (1.0) + partial pinch (0.6) + capped overlap streak (1.5) + carry (3.0), while both arms hold the block near the target.
    • Over 10 s that's ~78, against the one-shot bonus of 6200 × 0.02 = 124, a ratio of ~1.6×.
    • The comment in bimanual_lift_env_cfg.py notes that 1.42× destabilized training there, so this deserves a sentence.
  6. Minor cleanup.

    • Remove the unused GIVER_SIDE and TABLE_TOP_Z, and the commented-out TARGET_POS.
    • Remove the stray blank lines in events and the leading blank line in rl_cfg.py.
    • Keep tasks/__init__.py imports alphabetical (handover after drawer).
    • Rename the GIF to assets/OpenArm-Handover.gif to match the other assets, and add a row for it to the README task table.
  7. Test (optional). The held-high test only checks the joint and block state that gets written. Consider a test that steps the env a few times after reset_giver_held_high and asserts that the giver still grips and the block hasn't dropped.

@kou

kou commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@Manas-arumalla Could you review this?

@Manas-arumalla

Manas-arumalla commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

I agree with all of @kou points, especially item 1 (the giver never releases). Reading the code, I found a few more:

The receiver starts almost at the target. The task inherits BIMANUAL_LIFT_HOME, which is bimanual lift's held-high pose for both arms, including the right fingers at the squeeze width.

So at every reset, the right gripper's jaws are already closed to the block width, centred where bimanual lift's bar end sits: (0.30, -0.16, 0.51).
TARGET_POS is (0.30, -0.16, 0.55): 4 cm straight above that point, with a 3 cm success radius.
The receiver barely has to move. The task becomes "the giver swings the block into the receiver's waiting jaws", which would explain the ~30-step episodes and the >2 m/s block speed kou measured. Could the target be somewhere the receiver has to carry the block to, and/or could the target or the receiver's start be randomised? Then carry_to_target actually has to be learned.

The transferred latch is set inside a reward term. handover_overlap_streak returns a reward and also sets the latch that handed_over reads. This has two side effects in mjlab 1.6:

RewardManager.compute skips terms with weight 0. Setting overlap_streak to 0 (e.g. in an ablation) would silently make success impossible.
step() computes terminations before rewards, so handed_over reads the previous step's latch. That lag is harmless, but the coupling is fragile.
Could the streaks and the latch be updated in one helper called at the top of handed_over, with the reward terms only reading them? Terminations run first each step, so this also removes the need for the dict-order note and its test.

The held-high start has no variation. reset_giver_held_high writes an exact left-arm pose, finger width and block pose, overriding the joint jitter and the block's xy jitter. Half of all episodes therefore start from the same giver state, in training and in eval, since eval loads the training config. Could you add a little jitter here, and quote the headline success rate with probability=0?

The test CI failure is not caused by this PR. uv sync picks Python 3.15, mujoco 3.11.0 has no wheel for it, and the source build fails with MUJOCO_PATH environment variable is not set. main has failed the same way since Nov 1 (e6fc666). Only pre-commit (kou's item 3) needs fixing here.

(Minor) The viewer uses an ASSET_BODY camera. A tracking camera follows the arm's subtree centre of mass, so recorded videos sway with the arm. The single-arm tasks use a fixed WORLD camera. bimanual_lift also uses ASSET_BODY, so this is consistent with it.

@bupeshr check it

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