← all projects
Robotics · December 2025 · 1 min read

MPC for UR5e Robotic Arm — Warehouse Sorting

Model Predictive Control for a UR5e manipulator with analytical DH kinematics and real-time obstacle avoidance. Picks and stacks colored cubes around obstacles using a receding-horizon CasADi/IPOPT solver, replanning every timestep in MuJoCo — deployed on real hardware.

PythonMuJoCoCasADiOptimal Control

On Real Hardware

UR5e sorting colored cubes on real hardware using MPC
The full sorting loop running on a physical UR5e: the arm detects red and black cubes via a depth camera, plans a collision-free trajectory with a receding-horizon CasADi/IPOPT solver, grasps each cube with the Robotiq 2F-85 gripper, and places it in the correct labeled zone — no hand-coded waypoints, replanning every control tick.
Hardware setup — UR5e with cubes and sorting zones Red cubes successfully sorted into the red zone

Red cubes in the red zone, black cubes in the black zone — fully autonomous. The arm reclassifies each cube’s color from the camera feed and routes it to the correct drop location while avoiding the obstacle wall separating the pickup region from the placement region.

MuJoCo Simulation

MuJoCo sim — arm approaching cubes MuJoCo sim — arm grasping cube
MuJoCo sim — arm carrying cube over obstacle MuJoCo sim — cube placed in drop zone

The MuJoCo environment matches the real lab setup: colored drop zones, an obstacle wall, and a Robotiq gripper. The MPC horizon visualizes the predicted end-effector path (cyan markers) in real time. Each frame of the 20-step horizon is solved live via IPOPT in ~10 ms.

Trajectory Analysis

Top-down workspace view and side elevation showing obstacle clearance

Left: top-down view of four sorting runs — trajectories route around the obstacle wall to reach the drop zones. Right: side elevation showing the arm lifting over the wall (z = 0.5 m) without any pre-programmed height constraint.

Convergence & Safety

Position error converges within 3 cm tolerance Obstacle clearance stays above safety threshold

Position error converges below 3 cm by end of approach. Obstacle clearance stays above zero throughout — minimum 7.9 cm from the wall, well above the 2 cm NLP safety margin.

Joint Profiles & Solve Time

All 6 joint profiles — smooth within limits Solve time: ~38ms warm-start, ~10ms steady state

Joint profiles are smooth across all six DOF — the receding horizon doesn’t produce jerky commands even replanning every tick. Solve time drops from 38 ms (cold warm-start) to a steady ~10 ms, well within the 50 ms control timestep.

#mpc#robotics#trajectory-optimization#mujoco#kinematics

Related projects