Webots Simulation Tutorial: Basics and Ground Truth Checks

Learn the basics of a Webots simulation: worlds, robots, controllers, time steps, sensors and Supervisor, and how I test wheel odometry against the true values.

Author
AuthorAuthor

AI Engineer · 36+ years in IT · Japanese, based in Manila for 13+ years

Webots Simulation Tutorial: Basics and Ground Truth Checks

Summary

  • A Webots simulation is made of three parts: the world (the stage), the robot (the actor) and the controller (the script). Time moves forward one frame at a time, and the length of each frame is called the "basic time step."
  • A robot's movement is set by the speed of its left and right wheels, and the robot learns about its surroundings through sensors. Supervisor watches the whole simulation from above and tells you the true position and heading.
  • When I compared the estimate from wheel rotation with Supervisor's ground truth (the true values), the error was about 0.1% when driving straight, but about 9% when turning or spinning in place. A finer basic time step did not make the turning error smaller.

Simulation lets you test how a robot moves on a computer before you bring it into a real workplace. Webots is one of the most widely used robot simulators. But when you open it, you see unfamiliar words such as world, scene tree and controller, and many people are not sure where to begin.

Here, I explain the basics you need to know to run a simulation in Webots, using everyday comparisons and simple examples with numbers. In the second half, I share a test I ran in my own setup (Webots R2025a, with the e-puck robot). It checks how far a robot's own estimate of its position and heading, calculated from wheel rotation, drifts from the true values.

A Webots Simulation Has Three Parts

The World Is the Stage, the Robot Is the Actor, the Controller Is the Script

A Webots simulation is easier to understand if you think of it as a play.

  • World: The "stage," which sets the floor, walls, lighting and so on. The contents of the world are listed in the scene tree, branching out like a tree.
  • Robot: The "actor" that moves on the stage. It has parts such as wheels and sensors.
  • Controller: The "script" that tells the robot how to move. You write it as a program.

The scene tree has an item called WorldInfo. It holds the settings for the whole world. This is also where you change the basic time step, which I explain later.

The Controller Talks to Webots One Frame at a Time

A controller does not run on its own just because you wrote it. The Webots documentation says that the command to advance one frame (wb_robot_step) must be used in every controller. This command keeps sensor values and motor commands in sync between Webots and the controller. If you do not call it, the robot does not move and the sensor values are not updated.

In terms of the play, the flow is: "each time the scene moves forward one frame, the actor looks around and decides the next move."

Start, Stop and Reset Buttons

The toolbar has buttons that run the simulation. These four are the ones you will use most.

ButtonWhat it does
Real-timeRuns the simulation at the same speed as the real world. It keeps going until you press Pause or Step.
FastSame as Real-time, but runs as fast as your computer allows.
PauseStops the simulation.
Reset SimulationReturns the simulation to its starting state.

Reset Simulation is essential for keeping the conditions the same each time you test. In my test, I confirmed after each reset that the robot was back at the start position (x and y both 0.0000) and that time started again from 0.000 seconds before I took any measurements.

Simulation Time and the Basic Time Step

The Basic Time Step Is the Length of One Frame

Time inside Webots moves forward one frame at a time, like a flip book. The length of one frame is the basic time step (basicTimeStep). It is a field in WorldInfo. The unit is milliseconds, the smallest value is 1, and the default is 32.

For example, say you run a robot for 3.2 seconds. If one frame is 32 ms, then 3.2 ÷ 0.032 = 100, so it takes 100 frames. If one frame is 16 ms, then 3.2 ÷ 0.016 = 200, so it takes 200 frames.

The Speedometer Shows How Many Times Faster Than Real Time

The toolbar has a speedometer. It shows how many times faster than real time the simulation is running. If it reads 2.00x, the simulation is running twice as fast as a real robot would.

The key point here is that simulation time and real time (the time that actually passes) are not the same thing. In my test, a 3.2-second movement in simulation time took 3.562 seconds of real time. The speedometer read 0.898x.

Finer Steps Are More Accurate, but Slower

The Webots documentation says that a larger basic time step makes the simulation faster, but lowers the accuracy and stability of the physics and collision detection. For this reason, it recommends tuning the value to find a good balance between speed and accuracy.

In flip-book terms, more frames make the motion smoother, but take more work to draw. When I changed 32 ms to 16 ms in my setup, the same 3.2-second movement took 4.910 seconds of real time, and the speedometer dropped to 0.652x.

The Speed of the Left and Right Wheels Decides How the Robot Moves

A robot like the e-puck, with one wheel on the left and one on the right, is called a differential drive robot. You steer it the same way you push a wheelchair with your left and right hands.

  • If both sides turn at the same speed, it goes straight.
  • If the two sides turn at different speeds, it curves toward the slower side.
  • If the two sides turn in opposite directions, it spins in place.

You set wheel speed in radians per second (rad/s). A radian is a unit of angle. The e-puck's wheels can turn up to 6.28 radians per second. I explain what rad and rad/s mean in my article on robot units such as radians and torque.

Another good thing about this design is that you can predict how far the robot will go with a formula before you run it. The e-puck's wheel radius is 0.02 m. If both wheels turn at 3.0 rad/s for 3.2 seconds, then 3.0 × 0.02 × 3.2 = 0.192, so you can predict it will travel 0.192 m. You can also calculate the change in heading from the difference between the left and right speeds and the distance between the two wheels (52 mm on the e-puck).

Sensors Tell the Robot About Its Surroundings

Encoders (PositionSensor) Count How Much the Wheels Turn

An encoder is a sensor that measures how much a wheel has turned. In Webots, it is a part called PositionSensor, and for rotating parts it returns the angle in radians. The e-puck has one on each wheel.

If you know how much the wheels turned, you can calculate the distance traveled and the change in heading. It is like walking with your eyes closed and counting steps: "100 steps, so I should have gone about this far." This kind of estimate is called odometry. But if the wheels slip on the floor, the counted steps no longer match the distance actually traveled.

Proximity Sensors (DistanceSensor) Detect Nearby Objects

A proximity sensor detects whether something is nearby. In Webots, it is a part called DistanceSensor. The e-puck has 8 infrared sensors (ps0–ps7), and they can tell when an object is close within a range of about 4 cm.

Infrared sensors in Webots react more strongly to bright objects and red objects. In my test, I placed a red wall 0.25 m in front of the robot. After the robot moved close to the wall, the front-facing ps0 rose from 64.4 to 110.1, and ps7 rose from 67.4 to 103.0. The other sensors stayed between 64 and 72. Which sensor values change tells you which direction the object is in.

Supervisor Is the "Referee" That Sees Everything From Above

Supervisor is a special robot with extra powers inside Webots. It can access everything in the simulation, so it can pull out things like the exact position of a robot as seen from the whole world.

Think of it as a referee watching the field from above. The robot itself only knows what its own wheels and sensors tell it. Supervisor tells you the ground truth: where the robot really is and which way it is really facing.

Here is a rule I follow: keep ground truth and estimates clearly separate.

  • Supervisor's position and heading are the ground truth, used only to check answers.
  • The estimate from the wheel encoders is what the robot can know on its own.
  • The robot's decisions use only the estimate.

A real robot has no referee watching from above. If you use ground truth for decisions in a simulation, you get behavior that cannot be reproduced in the real workplace. What matters is to use ground truth only to check how accurate the estimate is.

Tested in Webots: Wheel-Based Estimates vs. Ground Truth

Conditions and Predictions

When I run a test, I calculate a prediction with a formula first, then run it, and judge the error as a percentage. My pass standard is an error within 5%. I explain how to set the prediction, conditions, records and success criteria in advance in Robot Experiment Basics.

The conditions for this test were as follows.

  • Robot: e-puck (wheel radius 0.02 m, distance between left and right wheels 0.052 m)
  • Run time: 3.2 seconds of simulation time. Before each run, Supervisor put the robot back at the start position
  • Straight: both wheels at 3.0 rad/s
  • Turn: left 2.0 rad/s, right 4.0 rad/s
  • Spin in place: left −2.0 rad/s, right 2.0 rad/s

Results With a 32 ms Basic Time Step

For the straight run, I compared the distance traveled. For the turn and the spin in place, I compared the change in heading (in radians).

MovementFormula predictionSupervisor (ground truth)Encoder estimateEstimate minus ground truth
Straight0.192 m0.192 m0.19179 mabout −0.1%
Turn2.46154 rad2.25538 rad2.45645 radabout 8.9%
Spin in place4.92308 rad4.51428 rad4.92255 radabout 9.0%

Webots console showing the spin-in-place result and the start position check with a 32 ms basic time step With a 32 ms basic time step. When spinning in place, the encoder estimate comes out larger than Supervisor's ground truth.

When driving straight, the prediction, the ground truth and the estimate were almost the same. The difference between the estimate and the ground truth was −0.00021 m, or about −0.1%.

On the other hand, when turning and spinning in place, only the ground truth came out smaller. For the spin in place, the prediction was 282.1 degrees, while Supervisor's ground truth was 258.6 degrees. The encoder estimate was almost the same as the prediction. That means the wheels turned as predicted, but the robot's heading did not change that much. This gap likely shows how much the wheels slipped on the floor.

The robot itself only knows its encoder values. If it decided its heading from this estimate alone, it would move on to its next action believing it had turned 282 degrees.

Changing the Basic Time Step to 16 ms

I changed only basicTimeStep in WorldInfo to 16 and ran the same movements again.

Webots scene tree with basicTimeStep in WorldInfo changed to 16 In the scene tree, I changed basicTimeStep in WorldInfo from 32 to 16.

Item32 ms16 ms
Steps100200
Real time3.562 s4.910 s
Speedometer0.898x0.652x
Straight difference−0.00021 m (about −0.1%)−0.00008 m (about −0.04%)
Turn differenceabout 8.9%about 9.5%
Spin-in-place differenceabout 9.0%about 9.4%

Webots console showing the spin-in-place result and the start position check with a 16 ms basic time step With a 16 ms basic time step. The error when spinning in place is about as large as it was with 32 ms.

The straight-line error got smaller, but the errors for turning and spinning did not. Meanwhile, the run took longer in real time and the speedometer reading dropped. The proximity sensor values changed in almost the same way at 16 ms (ps0 from 67.0 to 110.6, ps7 from 64.4 to 103.9).

Judging Against the 5% Standard

When I apply my standard (pass if the error is within 5%), the results are as follows.

  • Straight: Pass at both 32 ms and 16 ms
  • Turn and spin in place: About 9% error at both settings, so fail
Try it: decide the success criteria first, then check each run

Change any result. Bars inside the green band pass.

Distance (cm)
  • Run 1: 98 cm(difference -2 cm)→ Pass
  • Run 2: 101 cm(difference +1 cm)→ Pass
  • Run 3: 97 cm(difference -3 cm)→ Pass
  • Run 4: 103 cm(difference +3 cm)→ Pass
  • Run 5: 100 cm(difference +0 cm)→ Pass

5 of 5 runs passed. Average of the runs: 99.8 cm

What this shows is that a finer basic time step does not make everything accurate. It is better to see it this way: estimating heading from wheel rotation alone has limits built into the method itself. For a robot that turns a lot, you need to think about ways to correct the estimate with clues other than the wheels.

Wheel Estimates Drift in the Real World Too: The Mars Rover Example

Errors in wheel-based estimates are not just a simulation problem. A paper on NASA's Mars Exploration Rovers (MER) gives a clear example.

The Mars rovers estimated changes in position by combining measurements of their attitude (tilt and orientation) with how much the wheels had turned. This method was accurate enough on flat ground. But it did not work well on steep slopes or sandy ground.

  • When Opportunity actually traveled 19 m while climbing a slope, the wheel-based estimate alone came up 1.6 m short. The estimated final position was off by almost 5 m.
  • In an area of sand ripples, the wheel tracks were only 2 m long, but the wheels had turned enough to travel 50 m on flat ground. Since 50 ÷ 2 = 25, the wheels turned 25 times more than the rover actually moved.

After this, the rovers began using a mode that checks for slip while driving (Slip Check) on sandy ground. And when the wheels slipped on large rocks or steep slopes, they corrected the wheel-based estimate with an estimate from camera images (Visual Odometry).

The roughly 9% error I saw when turning in the Webots test is the same kind of problem. If you compare against ground truth in simulation, you can find this weakness before you go into the field.

Examples for Japanese Companies in the Philippines

The following are hypothetical examples of how Japanese companies in the Philippines might use robots. The numbers are samples for explanation only.

Warehouse Transport Robot

Say the wheel-based estimate shows the robot traveled 100 m, but it slipped on a waxed floor and actually traveled 95 m. The error is 100 − 95 = 5, or 5 m. As a percentage, (100 − 95) ÷ 100 × 100 = 5, so 5%. By my standard, that is right at the limit for passing. Any change in the floor would quickly push it over the limit, so you should compare against Supervisor's ground truth and also test slippery floor conditions.

Restaurant Serving Robot

Say a serving robot moves at 0.5 m/s. If one frame is 32 ms, it moves 0.5 × 0.032 = 0.016, or 0.016 m, per frame. At 16 ms, it moves 0.5 × 0.016 = 0.008, or 0.008 m. The finer the frames, the more precisely you can calculate contact with the corners of tables. The trade-off is that the simulation takes longer to run.

Factory Inspection Line

If you can run a 60-minute operation test with the speedometer at 10x, then 60 ÷ 10 = 6, so it finishes in 6 minutes. But you will not always get the speed you expect. In my setup, even a single e-puck ran at 0.898x. When you estimate how long a test will take, the safe approach is to run it first and check the speedometer value before you decide.

On-Site Delivery Robot

If a robot runs 1,000 m and its estimate is off by 2%, then 1000 × 0.02 = 20, so the difference is 20 m. Even if the percentage looks small, the longer the distance, the larger the error in meters. You can use simulation to check in advance how far the robot can go before the estimate needs correcting.

How to Use Simulation When Planning for the Real Workplace

I was once involved in boiler design. Back then, we first tested a boiler at our own facility, then checked that it worked on site before installing it. The idea of checking at a test site and at the real site separately applies to robots too.

Webots is the robot's version of that "in-house test site." I recommend working in this order.

  1. Make a prediction with a formula: Calculate the travel distance and change in heading from the wheel speeds.
  2. Run the simulation: Use reset to keep the conditions the same, record settings such as the basic time step, and run it.
  3. Compare ground truth and the estimate: Calculate the difference between Supervisor's ground truth and the encoder estimate as a percentage.
  4. Judge against your standard: Decide pass or fail using the standard you set in advance (mine is within 5%).
  5. Check on site: Test the movements that passed in simulation on the real floors and aisles.

Passing in simulation is not the end. Conditions you did not put in the world, such as the floor material and the weight of the load, exist only on site. It is best to think of simulation as a tool for narrowing down what you need to check on site.

FAQ

Q: What should I set the Webots basic time step to?

The default is 32 ms. A smaller value makes the physics and collision detection more accurate, but slows the simulation down. In my test, changing it to 16 ms made the error smaller when driving straight, but did not change the error when turning. I recommend comparing against ground truth for the movement you care about, and deciding based on the balance between speed and accuracy.

Q: Can a simulation run faster than real time?

The Fast button runs the simulation as fast as your computer allows. You can check how much faster it is with the speedometer on the toolbar. 2.00x means twice the speed of real time. But it will not always run faster than real time. In my test setup, the speedometer read 0.898x.

Q: Can I use Supervisor's position for the robot's decisions?

I do not recommend it. Supervisor is a special robot that watches the whole simulation from above. A real robot does not have the same information, so if you use it for decisions, the behavior cannot be reproduced on site. A good split is to use only estimates from encoders and sensors for decisions, and use Supervisor to check the answers.

Q: Can wheel encoders alone tell you where the robot is?

If the robot only drives straight on a flat floor, they can tell you quite accurately. In my test, the error when driving straight was about 0.1%. But when turning or spinning in place, the error was about 9%. NASA's Mars rovers also saw large errors in their wheel-based estimates on slopes and sandy ground, and corrected them with camera images. In places with many turns or slippery floors, you need to combine encoders with other clues.

Q: Do proximity sensor values show the distance directly?

No. The Webots DistanceSensor converts the measured value using a lookup table (a preset conversion table) before returning it. Infrared sensors react more strongly to bright objects and red objects. The e-puck's infrared sensors can detect objects within a range of about 4 cm. The basic way to use them is to watch how the values change and judge whether an object is close and which direction it is in.

Conclusion

When you run a robot simulation in Webots, the first things to understand are how the world, the robot and the controller relate to each other, and how time moves forward one frame at a time based on the basic time step. Once you also understand that the wheel speeds decide how the robot moves and that sensors tell it about its surroundings, the screen starts to make sense.

My test showed that the estimate from wheel rotation is accurate when driving straight, but drifts a lot when turning. And that error did not get smaller with a finer basic time step. By keeping Supervisor's ground truth separate from the estimate and comparing the two, you can find weaknesses like this before you go into the field.

PH AI Works is based in Manila, Philippines, and helps small and mid-sized businesses adopt AI and automate their work. If you are considering robots or automation for a warehouse, factory or store, feel free to reach out for a free consultation. We will ask about your on-site conditions and help you sort out where it makes sense to start testing.

References

About the author

Author
Author

Founder / AI Engineer (36+ years in IT)

  • ●From Tokyo · based in Manila for 13+ years
  • ●36+ years in IT (development, SEO, AI)
  • ●Google Certified AI Professional
  • ●IBM Certified Generative AI Engineer
  • ●AI chatbots, RAG & AI agent development
  • ●Physical AI Engineer

A Japanese AI engineer with 36+ years in IT and 13+ years on the ground in the Philippines. I write from hands-on experience to help Japanese companies adopt AI that actually delivers results — chatbots, workflow automation, AI agents, and AI-driven marketing. Feel free to reach out in Japanese or English.

Your Competitors Are Already Using AI!

Is your business keeping up?