How robots learn, explained for non-engineers: demonstrations, teleoperation, simulation, trial and error and large robot models.
Guide

Training robots in simulation and moving skills to the real world

Why robots train in simulation, what the reality gap is, how domain randomisation works, and where simulation still struggles.
Training robots in simulation and moving skills to the real world

Robots train in simulation because thousands of virtual copies can practise at once and a simulated fall costs nothing. A policy trained there can still fail on hardware because simulation differs from reality. That difference is the reality gap, and domain randomisation, tested on a real robot in a 2017 paper, is one common way to reduce it.

Why train robots in simulation

A real robot has strict limits as a student. It runs in real time, so one hour of practice is one hour. It wears out, and a bad policy can damage the robot, the objects around it or people nearby. Someone has to reset the scene after every attempt. A task that needs ten million attempts is out of reach.

A simulated robot has none of these limits for ordinary purposes. It can run faster than real time, many copies can run side by side, resets are instant, and a violent fall costs nothing. Simulation also makes it easy to measure things that are awkward to measure in the lab, such as the exact position of every object at every moment, which can be used to build a training signal.

That is why simulation is closely tied to the trial and error method in the reinforcement learning guide, which needs huge numbers of attempts. It also supports imitation learning, by generating demonstrations from a scripted expert in the simulator and by producing extra training images.

What a robot simulator models

A physics simulator for robotics represents a world as a set of bodies with shapes, masses and joints, and steps it forward in small increments of time. At each step it applies forces, detects contacts and works out how the bodies move. For a robot arm this includes the arm’s links and joints, the motors that drive them, and the objects on the table.

Simulators differ in what they emphasise. Some are built for speed on graphics processors and run thousands of robots at once with simplified contact. Others aim for more accurate contact and friction and run more slowly. Some include soft bodies, cloth or fluids, usually at a large computational cost. A simulator can also render images from virtual cameras, so that a vision system has something to look at, and the quality of those renderings ranges from basic shading to close to photographic. Two names appear often in robot learning code: MuJoCo, which the 2023 ACT study’s code uses for its simulated tasks, and NVIDIA’s Isaac Gym, used by the 2021 legged walking study described below, whose environments have since moved to NVIDIA’s Isaac Lab.

A simulation is a model, and every model leaves things out. The settings chosen for friction, mass, motor strength and camera position are estimates. Getting them from measurements of the real robot is called system identification, and it narrows the gap without eliminating it.

What is the reality gap?

The reality gap is the collection of differences between the simulation and the world. There are several kinds.

  • Dynamics. Real motors have delays, backlash and temperature effects. Real gears have friction that changes with wear.
  • Contact. Real surfaces have texture and slight deformation. How a gripper holds a smooth object depends on details a simulator may round off.
  • Sensing. Real cameras have noise, blur, exposure changes and lens distortion. Real force sensors drift.
  • Appearance. Real rooms have lighting, reflections and clutter that a plain simulated scene lacks.
  • Timing. Real systems have variable delays between measuring, deciding and acting.

A policy trained in simulation can quietly exploit any of these simplifications. If the simulated floor is a little too grippy, a walking policy may learn a stride that slips on real floors. A policy that has only ever seen clean synthetic images may be confused by a shadow.

How does domain randomisation work?

One response to the reality gap is to avoid chasing a perfect simulator and instead train across many imperfect ones. In domain randomisation, the settings of the simulator are changed at random during training: friction, object masses, motor strengths, lighting, camera positions, textures and colours. The policy must succeed across the whole range, so it cannot depend on any single setting being exactly right. If the range is wide enough to include the real world, the real world looks to the policy like one more variation.

A 2017 paper, Domain Randomization for Transferring Deep Neural Networks from Simulation to the Real World, tested this on object localisation. The authors trained a detector only on simulated images with non-realistic random textures and reported that it located objects on a real robot’s table to within about 1.5 centimetres, and that it coped with distractor objects and partial blocking of the view. They state it was the first successful transfer of a deep network trained only on simulated colour images to the real world for the purpose of robotic control. Note the scope: one task, object localisation, and a specific robot setup.

Later theoretical work asked why the approach succeeds. A paper titled Understanding Domain Randomization for Sim-to-real Transfer proposes a mathematical framework in which the simulator is a family of environments with adjustable parameters such as friction. Its authors prove that transfer can succeed under mild conditions without any real-world training samples, and that giving the policy a memory of its recent history is important. The conditions in a proof are not the conditions of a lab, but the result supports the intuition that wide variation can stand in for knowing the exact truth.

Randomisation has costs. A very wide range makes the learning problem harder, so the policy may become cautious and less skilled. A range that misses the real value fails. Choosing ranges is therefore part of the craft, and some methods adjust them automatically.

A well-known example: a robot hand and a cube puzzle

In 2019, a group at OpenAI reported solving a Rubik’s cube with a humanoid robot hand using policies trained only in simulation. Their paper, Solving Rubik’s Cube with a Robot Hand, introduced what the authors call automatic domain randomization, in which the system generates a distribution of randomised environments that grows more difficult as the policy improves, instead of a range set by hand. The abstract reports that control policies and vision state estimators trained this way showed greatly improved transfer to reality, and that memory-augmented models showed signs of what the authors call emergent meta-learning at test time, meaning the policy appeared to work out properties of the environment while running.

Reading this result carefully is useful. The hand was part of what the authors call a custom robot platform built for machine learning. The task was a single, very hard manipulation problem. The result was a demonstration that simulation-trained policies can handle contact-rich control on a real robot, not that any robot can learn any skill this way.

Synthetic images for robot vision

Simulation is also used to make training data for the robot’s vision, separate from control. A renderer can produce thousands of labelled images of objects in varied poses and lighting, and each image comes with perfect labels because the simulator knows where everything is. Labelling real photos by hand is slow and error-prone by comparison.

The same reality gap applies, with appearance as the main issue. Randomising textures, lighting, backgrounds and camera angles, as in the 2017 paper above, is the common remedy. Teams often mix a large amount of synthetic data with a smaller amount of real images, so the real images anchor the model to how things actually look.

Running thousands of copies at once

Modern simulators run on graphics processors and can step thousands of environments in parallel. All the copies share one policy. Each copy sends back its experience, and the policy is updated on the combined data. This turns a few hours of clock time into a very large amount of single-robot experience, and it is the main reason trial and error learning became practical for tasks like legged walking.

A 2021 study from ETH Zurich and NVIDIA, described on arXiv, shows the effect. Using one workstation graphics card and thousands of simulated copies of the four-legged ANYmal robot, the authors trained a walking policy for flat ground in under four minutes and one for uneven terrain in twenty, then ran the policies on the real robot.

The calculator on the reinforcement learning page shows the scale. For example, with 4,096 copies running for two hours at real-time speed, the total is roughly 340 days of single-robot experience. The figure is an illustration of parallelism, and real training runs vary in how many copies, how fast and for how long.

Parallelism also changes what is feasible to test. A team can run the same policy through thousands of randomised variations and count failures, which gives a more informative picture of reliability than a handful of real trials, though only to the extent the simulator reflects reality.

Testing a simulation-trained policy on real hardware

Moving a policy to a real robot is a staged process. Teams usually begin by checking that the real robot’s sensors and actions are expressed in the same units and conventions as the simulator, since a flipped sign or a different frame of reference is a frequent cause of failure. Then they run the policy with conservative limits on speed and force, often with a person ready to stop it, and observe. Safety measures such as emergency stops, force limits and clear space around the robot matter most at this stage, because an untested policy can move in unexpected ways.

If performance is poor, the options include widening the randomisation, identifying the real robot’s parameters more accurately, or fine-tuning the policy using a small amount of real data. Fine-tuning on real hardware often closes the remaining gap, which is why published sim-to-real results typically report real-world tests rather than only simulated ones.

Where simulation struggles: cloth, liquids and contact

Some things are hard to simulate well. Cloth bends and folds in complicated ways, and a towel on a table has far more degrees of freedom than a rigid cube. Liquids and granular materials such as sand or rice involve huge numbers of interacting particles. Soft and squishy objects deform under grip. Cables and ropes tangle. Rich contact, such as a screwdriver turning a screw or two parts sliding into place, depends on small surface details and fine force control.

For these tasks, simulation is slower, less accurate or both, and real demonstrations carry more weight. This is part of why towel folding, pouring and cable handling appear so often in imitation learning papers, which gather data on real hardware. Researchers are working on better soft-body and fluid simulation, but the accuracy needed for fine manipulation is a high bar.

Mixing simulation with real-world data

In practice many projects combine sources. A policy might be pretrained in simulation to learn basic motion, then fine-tuned on a few hours of real teleoperated demonstrations, as discussed in the teleoperation guide. Simulated data may supply the bulk of vision training, with real images added for calibration. A system may use simulation to test safety and edge cases before any hardware is risked.

The mix reflects a plain trade-off. Simulation is cheap, fast and safe, but only approximately correct. Real data is correct but costly and slow. The method comparison sets this alongside the other approaches.

Myth or fact

Myth Myth: A good simulator makes real-world testing unnecessary.

Fact Fact: Policies trained in simulation are still tested, and often fine-tuned, on real hardware.

Myth Myth: Realistic graphics are what matter most.

Fact Fact: For control, physics such as friction, mass and contact often matter more, which is why domain randomisation varies them.

Myth Myth: Simulation suits every task equally.

Fact Fact: Cloth, liquids and soft objects remain hard to simulate accurately.

Myth Myth: Training in simulation is slow.

Fact Fact: Thousands of simulated robots can run in parallel, gathering experience far faster than one real robot.

Myth Myth: Sim-to-real is brand new.

Fact Fact: The domain randomisation paper described on this page is from 2017, and the simulation-trained robot hand that solved a Rubik's cube was reported in 2019.

Questions about a particular simulator or paper can be sent through the contact page.

Frequently asked questions

Why don't researchers just train robots in the real world?

A real robot practises in real time, wears out, needs resets and can cause damage. Simulation runs faster, in parallel, and a fall costs nothing. Real testing is still needed, since a simulation is only an approximation.

What is the reality gap?

It is the difference between a simulator and the real world: friction, motor delay, contact, sensor noise and appearance. A policy that exploits a quirk of the simulator may fail on hardware, which is why transfer is studied as its own problem.

What is domain randomisation?

It is varying simulator settings, such as friction, mass, lighting and textures, during training so the policy cannot rely on any one setting. If the range includes the real world, reality looks like one more variation. A 2017 paper used it for object localisation.

Which simulators do robotics researchers use?

MuJoCo and NVIDIA's Isaac tools are two common choices: the code for the 2023 ACT study uses MuJoCo for its simulated tasks, and a 2021 legged walking study used Isaac Gym, whose environments have since moved to Isaac Lab. Simulators differ in speed, contact accuracy and soft-body support, and most papers name the one they used. This site does not rank them.

Can a robot trained only in simulation work in a real home?

Research has shown simulation-trained policies working on real robots for specific tasks, such as a robot hand solving a cube puzzle in 2019. A general home robot trained only in simulation has not been shown, and homes are varied and hard to model.

What tasks are hardest to simulate?

Cloth, liquids, granular materials, soft objects, cables and fine contact such as inserting parts. These involve many interacting parts or small surface details, so simulations are slow or inaccurate and real demonstrations carry more weight.

Was this page useful?

Have a question?

Send it through the contact page or email hello@trainingrobot.com.

Ask how robots learn
Ask how robots learn