Glossary · Physics simulation

Physics simulation

Also called physics engine, simulator, rigid-body dynamics, sim-to-real

Computing how objects move under forces, one small time step at a time, so a virtual body behaves like a real one.

A physics engine holds the state of a world (positions and velocities of everything in it) and moves it forward by a small step of time, again and again. Each step:

  1. Collision detection: find which shapes are touching (see collision geometry).
  2. Forces: gather gravity, motor torques, springs and outside pushes.
  3. Contacts: work out the forces at each contact so that bodies don’t pass through each other (see soft contact).
  4. Integration: use the net forces to update velocities, then positions.

The integration step applies Newton’s second law, F=maF = m a. For an articulated body it takes a matrix form, where qq holds every joint angle:

M(q) q¨+c(q,q˙)=τ+J⊤fM(q)\,\ddot{q} + c(q, \dot{q}) = \tau + J^\top f

MM is the mass matrix, cc gathers gravity and the forces from motion, τ\tau is the motor torques and J⊤fJ^\top f is the contact forces mapped onto the joints. The simplest integrator then steps forward with time step hh:

q˙t+h=q˙t+h q¨t,qt+h=qt+h q˙t+h\dot{q}_{t+h} = \dot{q}_t + h\,\ddot{q}_t, \qquad q_{t+h} = q_t + h\,\dot{q}_{t+h}

Why train in simulation

  • It’s safe: a simulated fighter can fall thousands of times.
  • It’s fast: many copies run in parallel, much faster than real time.
  • It’s measurable: every force and position is known exactly.

Sim-to-real

The catch is that a simulation is never exactly the real world. A policy can exploit quirks of the simulator that don’t exist in reality. Moving a policy onto a real robot, sim-to-real transfer, usually needs extra work, such as randomising masses and friction during training so the policy can’t rely on exact values.

In this project

We use MuJoCo. The fighter isn’t aimed at a real robot, so sim-to-real isn’t the goal. What matters is that the physics is close enough to a human’s for a coach to judge the movement.

Related terms

Used in

← All terms