How to simulate Thymio? - Playground

Thymio Simulator

This page explains how to use a simulated Thymio with Aseba Playground and Studio, VPL, Blockly or ScratchX. In other words this page explains how to program a virtual Thymio with Aseba Studio, VPL, Blockly or ScratchX using the simulator Aseba Playground. You don't need a real physical Thymio robot. The only thing you need is to download and install Aseba suite (version 1.6 - July 2018). Of course you can use a physical Thymio robot if you wish and all the programs you make will then be executed by both the virtual and the physical Thymio robot at the same time.

1. Aseba Playground and Aseba Studio or VPL.

1.1 Starting Aseba Playground and choosing a Thymio Playground

First, launch Aseba Playground by clicking on the corresponding icon.


A window will appear to let you choose a playground.


Several of them contain a Thymio, you can start with thymio.playground.
In fact all the existing maps (playground files) work with Studio or VPL, except "thymio-challenge-pack-web-bridge". Even this map can be converted to be suitable for Studio or VPL

After you open a map, you will see a 3D environment with a virtual Thymio (the image below shows the thymio.playground map). It has the same API as the real Thymio, so aesl files are compatible between the two.


1.2 Starting Aseba Studio or VPL and connecting to the simulated Thymio

Once Aseba Playground is running, start Aseba Studio or Thymio VPL by clicking the corresponding icon.

asebastudiothymio.svg or icon-vpl.svg

In the connection window, a list of available targets is shown. There could also be targets on another computer if they are on the same network. Read the information display to find out.


With Thymio VPL, you will first get an error message that it cannot connect to Thymio; click OK and the connection window will appear.

Select a target, click connect, and your usual Aseba Studio or Thymio VPL window will appear. You can now program your virtual robot.

2. Aseba Playground and Blockly or ScratcX.

In order to program a virtual Thymio with Blockly or ScratchX, follow these steps:

2.1 Launch Aseba Playground
2.2 Select *thymio-challenge-pack-web-bridge.playground* map. This map will launch *Thymio Web Bridge* (on its own - you don't have to do anything), that allows connection to browser applications.
In the current version of Aseba (1.6 July 2018) the above map is the only one working with Blockly and ScratchX. But don't worry! You can make all the other existing playground files work with both Blockly and ScratchX.
2.3 You can now launch Thymio Blockly or ScratchX.

3. Supported features

Because the simulated Thymio is in a limited, virtual environment, not all features are implemented. However, in order to be compatible with the real Thymio, all variables, functions and events are available. If you use them, you will not get a compilation error, however some events might never happen, some functions might do nothing and some variables might never change.

Below you will find a list of what is supported in the simulator. If you try to use a feature that is not yet implemented, a warning message will appear in the simulator.

4. Playground - Additional information

Sometimes it might be convenient to program without having a Thymio physically present and connected to a computer. However, as the Aseba Studio IDE enumerates native functions, local events and variables from the robot that is connected to it, a virtual instance of Thymio is needed in order to open a Thymio program or code a new behaviour for Thymio. Aseba provides a simulator, Aseba Playground, that can simulate different kinds of robots, including Thymio.

This document contains additional information on how to program robots in Playground, a multi-robot simulator bundled with Aseba.


Local Events

Proximity sensors

The code following the instruction onevent ir_sensors will be executed at regular intervals, just after the distance to obstacles (prox) has been updated.


The code following the instruction onevent camera will be executed at regular intervals, just after the linear camera pixels camR, camG, camB have been updated.


emit name [arguments]

emit specifies that a given robot should send an event of type name to all other robots. The event may contain up to 32 arguments. Note that you cannot choose to which robot the event will be sent, since just like a radio signal, it is broadcast to all robots (see the example below in [args] for how you can address individual robots). Note also that the name of the event and the number of arguments have to be declared in the Global Events pane of Aseba Studio.

Internal Variables


An identifier whose value is unique for every robot.


The id of the robot from which the most recent event was received.


The arguments of the most recent event received on this robot.

Example: This example shows how events can target individual robots even if the signal was broadcast to all robots. The idea is to use a vector in which each position is allocated to a specific robot: when receiving the event a robot will read only a specific part of this vector.

The robot 1 sends a move-ahead event to robot 2, waits, then sends a move-ahead event to robot 3 and a stop to robot 2, waits, and finally sends a general stop message.

Code for robot 1:

# variables
var counter = 0

onevent ir_sensors

if counter == 10 then
    emit move [1,0]

if counter == 100 then 
    emit move [0,1]

counter += 1

Code for robot 2:

# events
onevent move
    if args[0] == 1 then
        leftSpeed = 400
        rightSpeed = 400
        leftSpeed = 0
        rightSpeed = 0        

onevent stop
    leftSpeed = 0
    rightSpeed = 0

Code for robot 3:

# events
onevent move
    if args[1] == 1 then
        leftSpeed = 400
        rightSpeed = 400
        leftSpeed = 0
        rightSpeed = 0        

onevent stop
    leftSpeed = 0
    rightSpeed = 0

leftSpeed, rightSpeed

Wheel speed. Choose 400 for slow motion.

colorR, colorG, colorB

The red, green and blue components of the robot's colour.


The distance to obstacles perceived by the sensors. Note that noise produces fluctuations in the measurements. See schema here.

camR, camG, camB

Array of length 60. The red, green and blue components of values returned by the robot's camera.


Integer: [0 9]. The robot's energy level.

Create your own environment

Playground allows specific simulation environments to be defined. For instance, the following code creates a box containing four robots:

<!DOCTYPE aseba-playground>
    <color name="wall" r="0.9" g="0.9" b="0.9" />
    <color name="red" r="0.77" g="0.2" b="0.15" />
    <color name="green" r="0" g="0." b="0.17" />
    <color name="blue" r="0" g="0.38" b="0.61" />

    <world w="110.4" h="110.4" color="wall"/>

    <e-puck x="40" y="40"/>
    <e-puck x="40" y="60"/>
    <e-puck x="60" y="40"/>
    <e-puck x="60" y="60"/>

Examples: Get here a model of the German Pavilion, 1929, designed by Mies van der Rohe. And here you get a general example with all features.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License