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:
- Collision detection: find which shapes are touching (see collision geometry).
- Forces: gather gravity, motor torques, springs and outside pushes.
- Contacts: work out the forces at each contact so that bodies don’t pass through each other (see soft contact).
- Integration: use the net forces to update velocities, then positions.
The integration step applies Newton’s second law, . For an articulated body it takes a matrix form, where holds every joint angle:
is the mass matrix, gathers gravity and the forces from motion, is the motor torques and is the contact forces mapped onto the joints. The simplest integrator then steps forward with time step :
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.