From 9e443557d6bf3b757e8e488d518a090c7112334d Mon Sep 17 00:00:00 2001 From: Cutshion Date: Tue, 24 Nov 2026 18:54:46 +0900 Subject: [PATCH] Added sorting task and simulation Co-Authored-By: Claude Opus 5.5 --- docs/sorting/02_TASK_DESIGN.md | 109 +++++++++++++++++++++++++++++++++ docs/sorting/03_SIMULATION.md | 105 +++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 docs/sorting/02_TASK_DESIGN.md create mode 100644 docs/sorting/03_SIMULATION.md diff --git a/docs/sorting/02_TASK_DESIGN.md b/docs/sorting/02_TASK_DESIGN.md new file mode 100644 index 0000000..a2c0209 --- /dev/null +++ b/docs/sorting/02_TASK_DESIGN.md @@ -0,0 +1,109 @@ +# 02 Task design + +What Lumi does when SORT is pressed, which part is learned and which part is plain code. + +--- + +## 1. The scene + +``` + Lumi (column, arm on its side) + │ + ┌────────────────┼────────────────┐ table, top at the proven pick height + │ [ RED box ] ( plate ) [ BLUE box ] + │ o o + │ o o + └─────────────────────────────────┘ +``` + +| Item | Value | Status | +|---|---|---| +| Table | the office table used for the proven picks: top at −403 mm in the arm base frame at lift 75 mm | measured ([01](01_HARDWARE_FACTS.md) §1) | +| Lift, waist, base | lift 75 mm, waist at the front (0°), base parked; nothing but the arm moves in a trial | fixed by this design | +| Plate | white, shallow, centred on the proven pick centre (−100, 580) mm | position to confirm, plate size to measure | +| Balls | golf practice rubber balls (Coupang item 9233082559); 2–4 per trial, 2 colours to start | **diameter, mass, colours to measure** | +| Boxes | open boxes, one per colour, left and right of the plate inside the arm's comfort radius (710 mm) and clear of the head | **size and positions to choose**, then fixed with tape marks | +| Light | normal office light; trials also run with the blinds open and closed | — | + +Box positions are fixed in the arm base frame and written in `data/sort_layout.json` on the Thor. A later version +can find the boxes with the camera; the first one does not. + +### Choosing the balls + +- Two colours with far-apart hues and good saturation: **red and blue** first (the colour rule separates them + with wide margins: red hue < 8 or ≥ 170, blue 85–130). Green or yellow is the third colour. +- Avoid white, grey and black balls at first: the colour rule calls anything with low saturation white, grey or + black, and the plate is white. +- Matte rubber is good for depth (shiny objects jump up to 17 mm). + +--- + +## 2. One SORT run + +``` +SORT pressed + │ + ├─ check: arm enabled, gripper fitted, hand empty, no other skill running, layout loaded + ├─ arm to `look` (existing pose route) + │ + └─ loop: + ├─ look: steady balls on the plate (existing find(): 5 of 8 frames, 20 mm spread) + ├─ none left → arm to rest pose, status done (balls sorted: n) + ├─ pick the nearest steady ball; box = COLOUR_TO_BOX[colour]; unknown colour → skip it, say so + ├─ run the policy episode (below) with goal (ball position, box position) + ├─ check: gripper open, DI_1 / AI_1 show the hand empty, ball gone from the plate + ├─ failure (missed grasp, dropped, timeout) → open, back to `look`, count it, try the next ball + └─ three failures in a row → stop, status failed with the reason +``` + +| Part | Learned or code | Why | +|---|---|---| +| Finding balls, reading colour | existing vision code | already works to ~1 cm; colour is a rule | +| Choosing the box | code (`COLOUR_TO_BOX`) | a lookup; learning it adds nothing | +| Order of balls | code: nearest first | keeps the arm's path short and predictable | +| Reach, grasp, lift, carry, release | **policy** | the motor skill; this is the RL part | +| Moving to `look` and to rest | existing pose route | already checked for head clearance | +| Success and failure checks | code | uses the gripper signals and the camera after the episode | + +--- + +## 3. One policy episode + +The policy starts with the hand above the plate (the `look` pose or a fixed "ready above plate" pose, chosen in +phase 2) and the gripper open. It is given: + +- the ball's position (from the camera, refreshed while the ball is visible); +- the target box's position (from the layout file). + +It outputs, at a fixed rate, a small move of the hand (x, y, z) and open or close. The episode ends when: + +| End | Condition | +|---|---| +| Success | the ball is inside the target box's opening and the gripper has opened, hand above the box | +| Dropped | the ball leaves the hand anywhere but above the target box | +| Wrong box | the ball lands in the other box (counted separately: it means the goal input was misread) | +| Timeout | 15 s (real) / the same number of policy steps in simulation | +| Unsafe | the hand leaves the allowed box (workspace limits) or a safety check refuses a target | + +After every episode, success or not, the arm goes back to the start pose by the existing checked route, not by +the policy. + +--- + +## 4. What the policy does not do + +- It does not choose the ball or the box. +- It does not move the lift, waist, head or base. +- It does not turn the hand: the fingers point down and the yaw is fixed (a ball looks the same from any side). +- It does not handle a ball stuck between two others; a ball the camera does not see steadily is left for the + next look. + +These are deliberate limits for version 1. Each can be lifted later ([04](04_RL.md) §9). + +--- + +## 5. Words the robot says and the app shows + +All in English and Korean, like every other skill: "Sorting the balls.", "Red ball to the red box.", "I couldn't +pick up the blue ball.", "All sorted.". The app's texts live in `src/lib/i18n.tsx` (Lumi app rules); the robot's +lines live with the skill. Exact wording is set in phase 6 ([06](06_INTEGRATION.md)). diff --git a/docs/sorting/03_SIMULATION.md b/docs/sorting/03_SIMULATION.md new file mode 100644 index 0000000..f80c79c --- /dev/null +++ b/docs/sorting/03_SIMULATION.md @@ -0,0 +1,105 @@ +# 03 Simulation + +Two simulators, one scene. Isaac Lab trains the policy; MuJoCo replays the same policy to check it does not depend +on one engine's quirks. Both are built from the same robot description and the same numbers ([01](01_HARDWARE_FACTS.md)). + +--- + +## 1. Engines + +| | Isaac Lab | MuJoCo | +|---|---|---| +| Role | training (PPO, thousands of parallel scenes) | sim-to-sim check, debugging, quick visual runs on the Mac | +| Version | Isaac Lab 3.0, Newton physics on NVIDIA Warp (default install, Isaac Sim not required for headless training) | MuJoCo ≥ 3.14 (`sim/requirements.txt`) | +| Runs on | NVIDIA GPU, Linux: cloud x86 RTX machine, or the Thor if the phase 3 spike works | Mac (CPU) and the Thor | +| Robot from | URDF `sim/lumi_description/jaka_lumi.urdf` (arm chain only) + gripper model | `sim/lumi.xml` (already built from the same URDF) | +| Code | `rl/sorting/` | `sim/sorting/` | + +Only the arm, the gripper and the scene are simulated. The column below the arm base, lift, waist and head are +fixed collision bodies at the trial pose (lift 75 mm, waist 0°, head straight), because they must be avoided but +do not move. + +--- + +## 2. Robot model + +| Part | How | Check | +|---|---|---| +| Arm links and joints | URDF geometry and masses; joint limits with the code's 5° margin | joint angles from the fitted kinematics (`data/arm_kinematics.json`) give the same hand pose in sim within 1 mm at 20 random poses | +| Arm control | joint position targets with stiff gains: the policy's hand move goes through IK to joint targets, like on the robot | step responses match the measured ones (phase 1 data): lag and overshoot | +| Speed limits | 60 °/s per joint cap, linear speed cap of the trial speed; acceleration as measured | same cap numbers as `robot/motion.py` | +| Gripper body | box with the Zimmer's outer size and 0.54 kg + fingers | from 10_GRIPPER.md | +| Fingers | two straight boxes, the new fingers' length and width, friction from the material | open and closed tip gap equal the measured ones within 0.5 mm | +| Gripper motion | **binary**: a close or open command starts a full stroke of ~1 s that cannot be stopped; a new command during a stroke waits for it to end | stroke time from 20 measured strokes; randomised ±20 % | +| Grip | finger force from the switch level (~90 N, capped low in sim to keep contacts stable) | a held ball survives a 0.5 g shake in sim, as on the robot | +| Gripper signals | AI_1 modelled from the finger gap (linear between ~140 open and ~4160 shut, ball gives a value in between) | readings on a held ball match the measured AI_1 | + +### Robot description work + +The URDF in `sim/lumi_description/` has the arm; the current MuJoCo model hangs a Robotiq 2F-85 on it as a stand-in. +Both simulators need the Zimmer with the new fingers instead. Steps: + +1. Measure the new fingers ([01](01_HARDWARE_FACTS.md) §2). +2. Write the gripper as its own small URDF / MJCF (`zimmer_gep2013_straight`), attached at the flange with the + measured offset. +3. Isaac Lab imports URDF through its asset importer; check in the phase 2 spike whether the Newton-only install + imports URDF directly or needs a USD made once on a machine with Isaac Sim. Keep the generated file in the repo. + +--- + +## 3. Scene + +| Item | Simulated as | Randomised (training) | +|---|---|---| +| Table | box, top at the measured height | height ±10 mm, friction 0.4–1.0 | +| Plate | shallow dish mesh or a flat disc with a low rim | position ±30 mm, rim height ±3 mm | +| Ball | sphere, measured diameter and mass, rubber-like contact | diameter ±1.5 mm, mass ±20 %, friction 0.6–1.2, restitution 0.1–0.5, start position anywhere on the plate | +| Boxes | thin-walled open boxes at the layout positions | position ±15 mm, wall height ±5 mm | +| Obstacles | column, head, lift link as fixed bodies | none | + +One ball is "the" ball of the episode; 0–3 other balls lie on the plate as obstacles so the policy learns not to +knock them off. + +--- + +## 4. Sensors + +The policy never sees simulator truth directly in the student version ([04](04_RL.md) §8). The sensor model copies +what the robot's vision gives: + +| Signal | Model | +|---|---| +| Ball position | true position + fixed bias per episode (up to 10 mm, from the measured error) + noise per reading (σ 3–5 mm) | +| Update rate | new reading every 0.5 s (the skills' depth rate), with 0.1–0.3 s delay | +| Occlusion | no new reading while the hand is above the ball or the ball is in the hand: the last reading is held and a "fresh" flag goes to 0 | +| Dropouts | 5 % of readings missing | +| Hand position | from joint angles through the fitted kinematics: small noise (σ 1 mm) | +| Gripper | state open / closing / closed / opening and the AI_1 value with noise | + +A rendered camera image is not needed for version 1. It comes in only with the vision extension ([04](04_RL.md) §9). + +--- + +## 5. Physics settings + +| Setting | Start value | Note | +|---|---|---| +| Physics step | 2 ms (MuJoCo now uses 2 ms) | small balls need small steps; check that a held ball does not jitter | +| Policy step | matches the real control rate chosen in phase 1 (mode A 10–20 Hz, mode B 2–4 Hz) | [04](04_RL.md) §3 | +| Contacts | elliptic friction cones, soft contact on the ball | tune until grasp, roll and drop look like the real ball in a filmed test | +| Gravity compensation | on for the arm (as in `sim/lumi.xml`) | the real controller compensates | + +--- + +## 6. Matching the real robot + +These numbers in the simulation are replaced by measured ones in phase 1, and the measurement goes into +[08_EXPERIMENT_LOG.md](08_EXPERIMENT_LOG.md): + +- arm step response (lag, overshoot, settle time) at the trial speed, for each control mode; +- gripper stroke time and AI_1 on a held ball; +- ball diameter, mass, bounce (drop from 10 cm on the table, film it), roll friction (roll down a known slope); +- camera position error on the ball and its delay. + +Known differences that stay ([../SIMULATION.md](../SIMULATION.md) §known differences) are written down with their +expected effect, not hidden.