Minimal replication of the GenCHiP paper's core mechanism: force-based compliant control for contact-rich manipulation.
Paper: GenCHiP: Generating Robot Policy Code for High-Precision and Contact-Rich Manipulation Tasks
# 1. Activate environment
cd /Users/Smada/my_ros2_project
source mujoco_env/bin/activate
# 2. Run MuJoCo-based simulation (real physics + force sensors)
python genchip_replication/scripts/run_mujoco_genchip.py --headless
# 3. Interactive 3D viewer (macOS)
mjpython genchip_replication/scripts/run_mujoco_genchip.py# Simplified physics model for understanding the concept
python genchip_replication/scripts/peg_in_hole_sim.pygenchip_replication/
├── README.md # This file
├── requirements.txt # Python dependencies
│
├── envs/ # MuJoCo environments
│ └── simple_cartesian_robot.xml # 3-DOF robot with force sensor
│
├── scripts/ # Executable demos
│ ├── check_mujoco.py # Installation verification
│ ├── run_mujoco_genchip.py # ⭐ NEW: Real MuJoCo simulation
│ ├── mujoco_genchip_controller.py # ⭐ NEW: Force-based controller
│ ├── peg_in_hole_sim.py # Original: Toy physics demo
│ └── interactive_viewer.py # Original: 3D viewer demo
│
├── docs/ # Documentation
│ ├── GUIDE.md # Complete guide (start here!)
│ ├── EXAMPLES.md # Real LLM-generated code examples
│ └── ASSESSMENT.md # What we replicate vs. full GenCHiP
│
└── outputs/ # Generated results
├── mujoco_genchip_comparison.png # ⭐ NEW: Real physics comparison
├── force_plot_success.png # Original: Toy model plots
└── viewer_demo.png # Original: 3D visualization frames
We've upgraded from a toy physics model to a proper MuJoCo simulation with:
- ✓ Actual contact dynamics (not
fz = 8.0 * penetration) - ✓ Real force/torque sensor (
data.sensordata) - ✓ Impedance control via actuator parameters
- ✓ 3D peg/hole collision geometry
- ✓ GenCHiP policy: Successfully detects contact, finds hole via force feedback
- ✓ Non-compliant policy: Jams immediately (lateral force 31 N)
- ✓ Force plots: Match paper's Figure 5 pattern (3 distinct phases)
- Phase 1: Descend until force > 2.0 N (contact detected)
- Phase 2: Search laterally until force < 0.5 N (hole found)
- Phase 3: Insert downward (compliant motion prevents jamming)
This is the best possible replication without real hardware.
Traditional (fails):
move(translation=[0, 0, -0.01]) # Blind position command
# → Jams if misalignedGenCHiP (succeeds):
move(
translation=[0, 0, -0.01],
constraint="force.z > 5" # Stop when force threshold reached
)
# → Adapts to contact, prevents jamming- Compliance: Motion scales inversely with force (gentle contact)
- Force constraints: Actions terminate based on sensor readings
- Search behavior: Emerges from force feedback, not explicit planning
| File | Purpose |
|---|---|
docs/GUIDE.md |
Start here - Complete explanation |
docs/EXAMPLES.md |
Real LLM-generated code from paper |
scripts/peg_in_hole_sim.py |
Main simulation code |
scripts/interactive_viewer.py |
3D visualization |
- Force sensors vs vision - Why force is primary
- Action space design - Compliant moves with constraints
- Real workflow - From LLM generation to execution
- Hardware setup - UR5e + ATI force sensor
- Benchmarks - FMB and NIST tasks
# Create virtual environment
python3.12 -m venv mujoco_env
source mujoco_env/bin/activate
# Install dependencies
pip install -r genchip_replication/requirements.txtpython genchip_replication/scripts/check_mujoco.pyYou should see a falling box in a 3D window.
python genchip_replication/scripts/peg_in_hole_sim.pyOutput:
- Terminal: Insertion progress and success/failure
- File:
outputs/force_plot_success.png
What it shows:
- Contact phase (force rises)
- Search phase (lateral motion)
- Insertion phase (force increases)
On macOS:
mjpython genchip_replication/scripts/interactive_viewer.pyWhat you'll see:
- Orange peg falling into circular hole
- Real-time physics simulation
- Force sensor readouts in terminal
Controls:
- Left mouse: Rotate
- Right mouse: Pan
- Scroll: Zoom
- ESC: Exit
Shows three phases matching the paper's Figure 5:
- Contact - Force rises to ~0.5N
- Search - Force plateaus during lateral motion
- Insertion - Force rises to ~1.5N (fully inserted)
✓ Peg position within hole radius
✓ Peg depth below surface (z < 0)
✓ No force spikes (compliant control working)
- Force-based control for contact-rich tasks
- Robust to misalignment (peg starts 12mm off-center)
- No vision needed during insertion
- Compliant behavior prevents damage
- Add MuJoCo XML environment (replace toy physics)
- Implement admittance controller (real impedance control)
- Integrate LLM code generation (GPT-4 policy synthesis)
- Test on FMB benchmark (multiple peg shapes)
- Deploy to real UR5e (with ROS bridge)
- Robot: Universal Robots UR5e
- Force sensor: ATI Axia80 (6-axis F/T at wrist)
- Vision: Faster-RCNN (object detection + pose estimation)
- Simulation: MuJoCo 3.4.0
- Control: Impedance/admittance control
- LLM: GPT-4 (code generation)
- Language: Python 3.12
cartesian_admittance_move(
target_pose=pose,
max_cartesian_stiffness=[1000, 1000, 1000, 300, 300, 300],
target_impedance=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
termination_condition=force_threshold
)Q: Do I need ROS?
A: No, not for this replication. ROS is only needed for real robot deployment.
Q: What UI do I get?
A: MuJoCo provides an interactive 3D viewer. Use mjpython on macOS.
Q: Is vision used?
A: Vision provides initial object poses. Force sensors guide the insertion.
Q: How does this relate to my ROS2 project?
A: This is separate. It's pure MuJoCo/Python with no ROS dependencies.
- Paper: GenCHiP Project Page
- IEEE: IROS 2024 Paper
- MuJoCo: Documentation
- FMB: Functional Manipulation Benchmark
This is a research replication for educational purposes.
For questions about the Intrinsic competition application.
