Skip to content

Repository files navigation

GenCHiP Replication for Intrinsic Competition

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


Quick Start

NEW: Real MuJoCo Physics Simulation (Recommended)

# 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

Original: Conceptual Demo (Toy Physics)

# Simplified physics model for understanding the concept
python genchip_replication/scripts/peg_in_hole_sim.py

Project Structure

genchip_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

⭐ What's New: Real MuJoCo Physics Simulation

We've upgraded from a toy physics model to a proper MuJoCo simulation with:

Real Physics

  • ✓ Actual contact dynamics (not fz = 8.0 * penetration)
  • ✓ Real force/torque sensor (data.sensordata)
  • ✓ Impedance control via actuator parameters
  • ✓ 3D peg/hole collision geometry

Validation Results

  • 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)

How It Works

  1. Phase 1: Descend until force > 2.0 N (contact detected)
  2. Phase 2: Search laterally until force < 0.5 N (hole found)
  3. Phase 3: Insert downward (compliant motion prevents jamming)

This is the best possible replication without real hardware.


What This Demonstrates

Core Mechanism: Force-Based Termination

Traditional (fails):

move(translation=[0, 0, -0.01])  # Blind position command
# → Jams if misaligned

GenCHiP (succeeds):

move(
    translation=[0, 0, -0.01],
    constraint="force.z > 5"  # Stop when force threshold reached
)
# → Adapts to contact, prevents jamming

Key Concepts

  1. Compliance: Motion scales inversely with force (gentle contact)
  2. Force constraints: Actions terminate based on sensor readings
  3. Search behavior: Emerges from force feedback, not explicit planning

Documentation

Quick Reference

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

Key Topics Covered

  • 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

Installation

Environment Setup

# Create virtual environment
python3.12 -m venv mujoco_env
source mujoco_env/bin/activate

# Install dependencies
pip install -r genchip_replication/requirements.txt

Verify Installation

python genchip_replication/scripts/check_mujoco.py

You should see a falling box in a 3D window.


Usage

1. Main Simulation (Force Plots)

python genchip_replication/scripts/peg_in_hole_sim.py

Output:

  • 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)

2. Interactive 3D Viewer

On macOS:

mjpython genchip_replication/scripts/interactive_viewer.py

What 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

Key Results

Force Plot

Force Plot

Shows three phases matching the paper's Figure 5:

  1. Contact - Force rises to ~0.5N
  2. Search - Force plateaus during lateral motion
  3. Insertion - Force rises to ~1.5N (fully inserted)

Success Criteria

✓ Peg position within hole radius
✓ Peg depth below surface (z < 0)
✓ No force spikes (compliant control working)


For Intrinsic Competition

What This Demonstrates

  • Force-based control for contact-rich tasks
  • Robust to misalignment (peg starts 12mm off-center)
  • No vision needed during insertion
  • Compliant behavior prevents damage

Next Steps

  1. Add MuJoCo XML environment (replace toy physics)
  2. Implement admittance controller (real impedance control)
  3. Integrate LLM code generation (GPT-4 policy synthesis)
  4. Test on FMB benchmark (multiple peg shapes)
  5. Deploy to real UR5e (with ROS bridge)

Technical Details

Hardware (from paper)

  • Robot: Universal Robots UR5e
  • Force sensor: ATI Axia80 (6-axis F/T at wrist)
  • Vision: Faster-RCNN (object detection + pose estimation)

Software Stack

  • Simulation: MuJoCo 3.4.0
  • Control: Impedance/admittance control
  • LLM: GPT-4 (code generation)
  • Language: Python 3.12

Action Space

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
)

FAQ

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.


References


License

This is a research replication for educational purposes.

Contact

For questions about the Intrinsic competition application.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages