Repository navigation
feat(r2): add the Robbyant R2 real-robot extension - #325
Draft
andylin-hao wants to merge 3 commits into
Draft
andylin-hao wants to merge 3 commits into
andylin-hao wants to merge 3 commits into
Conversation
Let an LLM planner operate an R2 without a VLA. An env server on the robot runs RLinf's R2Env and checks every planner command against a site config (per-arm workspace box, per-call distance and rotation, joint speed) before the robot moves. The planner gets Cartesian arm moves, grippers, the head, an opt-in chassis, state views, and back_project, which turns pixels into base_link points from depth, configured intrinsics and distortion, and camera poses computed from the robot's URDF and measured joints. Add robots.r2.diagnostics for a no-motion server check, offline tests including an HTTP loopback through the real facade and client, and English and Chinese deployment docs. R2 support in RLinf is in RLinf/RLinf#1745. Signed-off-by: Hao Lin <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Let the planner find an object by a short name or a pixel on it. The segment tool sends a recorded camera image to RPent's SAM3 service and returns the mask's pixel box and centre, an overlay to check the selection, and, when the camera has depth and calibration, the object's median base_link point and extent. RPent attaches to --sam3-endpoint, or starts a local server when SAM3_CHECKPOINT_PATH is set, and waits for it before connecting to the robot, because connecting resets the arms. The tool is offered only when SAM3 is configured. Also apply the formatting diagnostics.py missed in the previous commit. Signed-off-by: Hao Lin <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Let the operator judge the result: request_operator_verdict asks on RPent's terminal, finish takes its status from the answer, a motion after a verdict discards it, and an abort refuses further motion. Interrupting RPent now stops the robot: the toolkit sends env.request_stop, which skips the server's write lock and calls RLinf's R2Connection.hold(), so the arms brake within their limits. env_server --mock drives RLinf's simulated R2 controller, and tests/e2e_tests/r2 runs the env component and the scripted CLI chain against it. The shared chain helper accepts calls before finish and no longer gives the child a terminal. Mark R2's env server as external so the Dashboard accepts it. Signed-off-by: Hao Lin <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
robots/r2/, an RPent extension that lets an LLM planner operate a Robbyant R2 (two 7-DoF arms, parallel grippers, a pan-tilt head RGB-D camera, and two wrist RGB-D cameras) without a VLA.The R2 support itself lives in RLinf and is in review in RLinf/RLinf#1745 (
feat/r2-robot), which this PR also needs forR2Connection.hold(). RPent'srlinfextra pinsrelease/v0.4, which has no R2, so the docs install RLinf from that branch until it is released.How it fits together
robots.r2.env_serverruns on the robot. It builds RLinf'sR2Envlocally (no Ray), which owns the controller connection, fault recovery, the rest pose, IK, and the fixed-rate setpoint stream.R2AgentEnv(rlinf_env.py) is a thin adapter that checks every planner command against a site config before the robot moves: a per-arm workspace box inbase_link, maximum translation and rotation per call, and a joint-speed cap. Refusals returnok: falsewith the reason; incomplete moves also return the controller's health.--env-endpoint). RPent never starts the server, because it owns hardware and runs under the operator's control on the robot. No new extra is needed on the workstation.move_to,move_delta,rotate_delta,set_gripper,look,go_home, andmove_base(registered only when the site allows chassis motion; off by default). The readers areview_env_state,view_camera_meta,back_project, andsegment(registered only when SAM3 is configured).back_projectturns pixels intobase_linkpoints from the step's depth, configured intrinsics and OpenCV distortion, and a camera pose. The pose is computed from the robot's own URDF (which carries its hand-eye calibration) and the measured waist, neck, and arm joints, so it stays correct as the head and arms move.segmentuses RPent's shared SAM3 service to find an object by a short name or a pixel on it. It returns the mask's[row, col]box and centre and an overlay image for the planner to check. When the camera has depth and calibration, it also returns the object's medianbase_linkpoint and 5th-95th percentile extent. RPent attaches to--sam3-endpoint, or starts a local server whenSAM3_CHECKPOINT_PATHis set, and waits for SAM3 before connecting the env client, because connecting resets the arms.request_operator_verdictasks the operator on RPent's terminal (success, failure, continue, or abort, with optional notes).finishis refused until the operator answers, and its status is the operator's verdict, not the planner's claim. A motion after a verdict discards it, an abort refuses further motion, and every answer is saved inoperator_events.json. Without a terminal, the run finishes as an unverified failure.env.request_stop, which bypasses the server's write lock and calls RLinf'sR2Connection.hold(): the arms, head, and chassis brake within their acceleration limits, and the interrupted tool reportsstopped: true.env_server --mockdrives RLinf's simulated R2 controller (it ships with RLinf's tests, so it needs an RLinf source checkout).tests/e2e_tests/r2uses it for an env component test and the scripted CLI policy chain.python -m robots.r2.diagnosticschecks a running server without moving the robot.0primitive smoke test,1tabletop pick and place.--task-languagereplaces the instruction.Reuse and divergence. Env lifecycle, kinematics, motion streaming, and fault handling are RLinf's. Two things RLinf does not provide live in RPent:
Shared changes
run_scripted_policy_chain(tests/e2e_tests/common.py) accepts calls between the action andfinish, and starts the CLI with stdin from/dev/nullso a scripted session never waits for terminal input. Existing callers are unchanged.external_env, because its env server always runs on the robot. Without it the Dashboard rejected R2, and the CLI required a TTY even when no operator is attached.Known limitations
back_projectnames what is missing, and the planner can only make small moves checked against images. The head lens is wide-angle, so its distortion coefficients are needed too.config/example.yamlare starting values around the measured rest pose and must be reviewed per site.An AI assistant (Claude Code) was used to write this change.
Testing
pytest tests/unit_tests/robots/r2 -v: 38 passed. Covers:back_project, including inverting the distortion model;segmentagainst a fake SAM3 client: 3D location, overlay, missing calibration, misses, and exactly one of prompt or point;pytest tests/unit_tests: 1496 passed, 14 skipped, 10 errors. The errors aretest_pi05_vla_server_contracts.pyand the RoboDojo env/flash contract tests, which importtorch;torchis not installed by the[test]extra in my environment. They are unrelated to this change.pytest tests/e2e_tests/r2 -v: 2 passed, against RLinf's simulated controller (RLinf atb72e9c3d, CPU only). The component test observes, moves an arm (final error 0.9 mm in simulation), turns the head, sets a gripper, stops amove_tohalfway through a stop request from a second connection, and returns home. The policy chain runs the public CLI with the offline planner:move_delta,request_operator_verdict(no terminal, so unavailable), thenfinish, recorded asfailure. I ran these in a scratch environment that combines RPent with RLinf's dependencies; with RLinf absent, the fixture skips them.pre-commit run --all-files: passed.sphinx-build -W --keep-goingforsource-enandsource-zh: no warnings.Manual verification
On an R2 (21-DoF body, grippers; Ubuntu 24.04 aarch64,
/opt/py310), with no motion commanded:--system-site-packagesvenv, with its site-packages first onPYTHONPATHafterentry_env.sh.robots.r2.env_serverwithconfig/example.yamland connectedR2EnvClient(reset_on_connect=False).Not yet verified: any motion through RPent (task
0) and stopping a motion on the robot;back_projectandsegment3D accuracy on hardware, which need intrinsics; andsegmentwith a real SAM3 checkpoint on R2 images. I'll run task0with an operator at the emergency stop before marking this ready.Checklist
torch.)🤖 Generated with Claude Code