Cartesian Impedance Control for Franka Panda

Null-space projected Cartesian impedance controller for a 7-DOF Franka Panda, simulated in MuJoCo with Pinocchio for kinematics/dynamics

What it is

A Cartesian impedance controller for a 7-DOF Franka Emika Panda, simulated in MuJoCo with Pinocchio handling the kinematics and rigid-body dynamics. Rather than commanding joint positions directly, the controller makes the end-effector behave like a virtual spring-damper toward a target pose — letting the arm comply with unexpected contact instead of fighting it, which matters for any task where contact is expected (as opposed to purely free-space motion).

How it works

  • At each control step, Pinocchio computes the end-effector Jacobian and the current Cartesian pose/velocity from the robot’s joint state.
  • Desired joint torques are computed from the Cartesian pose and velocity error against a target pose, through a stiffness/damping law mapped back into joint space via the Jacobian transpose.
  • Because the Panda has 7 joints for a 6-DOF Cartesian task, there’s one redundant degree of freedom — a null-space projection term adds secondary damping in that redundant direction, so the arm doesn’t drift or oscillate in ways that don’t affect the end-effector pose.
  • Torques are applied directly as MuJoCo actuator commands, closing the loop in simulation.
Tracking results across three scenarios (free-space, wall contact, disturbance) and three stiffness/damping configurations, plus the estimated external force recovered from tracking error.

Scenarios

The repo evaluates three configurations — Stiff & Critically Damped, Low-Stiffness & Critically Damped, and Low-Stiffness & Underdamped — across three tasks:

  • Free-space: tracking a Cartesian trajectory with nothing in the way.
  • Wall-contact: tracking the same trajectory into a rigid obstacle, where a stiffer controller pushes harder against the wall while a compliant one yields.
  • Disturbance: an external push mid-trajectory, testing how each configuration recovers.

The estimated external force plots (rightmost column above) come directly from the tracking-error term in the impedance law, without any force/torque sensor — a compliant controller effectively gives you a rough contact-force estimate for free.

Code

github.com/sanger640/impedance_controller