VPL3 DOCUMENTATION

About VPL

VPL is a block-based visual programming language. You can program behaviours for Thymio by associating conditions/events to actions.

Creating a program

The program is created in the center of the interface, where the programmer combines events that the robot can detect, with the corresponding actions that the robot needs to perform. To create a program line, simply drag one or more events from the left list of events to the left side of a program line. Then associate one or more actions you want to happen in the right side of the line, taking them from the right list on the screen. A program line must always contain at least one event and one action. Two lines cannot have the same triggering event conditions. If two lines with events occurring at the same time produce conflicting actions, for instance one line states that the robot need to move forward and another backwards, and both line are triggered, the result is undefined.

Events are colored in light orange and actions in light blue. To better distinguish them also in blank/white printing, event blocks have in addition the top-right corner colored in orange:

When completed, a program line can be described by the sentence “when the Event occurs, then the Action is executed”.

Events and event conditions

On the left side of a program line an event can be extended by as many conditions as needed. Conditions allow to better specify the event which is triggered. In the case of the line below, the program line means “when the right button is pushed (event), if the bottom color of Thymio is magenta (condition), then the robot starts moving forward-right (action)”. Conditions  are displayed in a slightly smaller size to indicate the difference with the main event.


While “push the button” is a real event, some others icons (LED stated and internal variables) are representing internal states and not real events. In case one of these icons is set first, the program line will display all conditions at the same level, and all conditions will be considered with the same priority. The line below, for instance, means “when we come to the situation where both the bottom color of Thymio is magenta (condition) and the right button is pressed (condition), then the robot starts moving forward-right (action)”.

Note from the given example that switching events and conditions results in very different behaviors. It’s different to detect the pressing of the button, conditional to the color, and both conditions reunited. If the magenta color appears after pressing the button, the first event is not triggered, while the conjunction of both conditions (whichever occurs first) trigger the second event.

All LEDs and internal states icons can only be conditions and never events. All sensor readings and the clock can be used as events.

Warnings and errors

A code is ready to be executed by the robot when the programmer has included all desired functionalities, and when there are no errors anymore. Errors are visualized with a big red sign, and the error message is displayed at the bottom of the interface on a pale red background. Errors appear if, for instance, there is a code line with an event but no corresponding action. In this case the robot does not know what to do. An error also appears if two code lines have identical events, including parameters and conditions. In this case the robot cannot know what to do.

Sometimes there are code lines that could be executed but do not make much sense, and these generate warning messages. Warning messages are displayed in yellow, and the warning message is indicated in the same bottom location as the errors. Warnings do not prevent the code to be executed, but show potential problems. A warning appears, for instance, if no sensors have been selected in a obstacle detection icon. This can generate unexpected behaviors.

Errors have a priority of display over warnings, as they cause the program not to run. Therefore the message displayed at the bottom is the one for the first error, or for the first warning if there is no error.

Connecting a Thymio robot

The connection method depends on the environment you are using. In the VPL3 interface, an icon shows the connection status as follows:

A Thymio is connected

There is no Thymio connected.

Executing a program

PLAY

The green PLAY button means the code has no error, a robot is connected and the code in the interface is not yet running on the robot.

When the programmer presses on PLAY, the code is sent to the robot and executed, and the button changes shape to START AGAIN.

START AGAIN

If the programmer presses START AGAIN, the same code is resent and started again on the robot.

As soon as the code is modified by the programmer, the button goes back to the PLAY state, showing that the code running on the robot is not anymore the one visible in the programming interface. The button goes back to the PLAY state also if the STOP button is pressed.

Detailed description of the blocks:

Start of the program

init

This event does not use a specific sensor of the Thymio.

Triggering conditions: this event is triggered at the start of the program on the robot, as you hit the PLAY or START AGAIN button in VPL. You can use it to set actions Thymio will perform at the start of the program.

Example: At the beginning of the program start by (robot action, for instance setting the robot color to red)

Single button

single button

Sensor(s) used: five capacitive touch buttons on top of Thymio.

Triggering conditions: this event is triggered when a button is pressed.

Parameters: the button highlighted in orange is the button triggering the event. The grey buttons are ignored.

Example: when the forward button is pressed, then … (robot action, for instance start moving forward).

On the side

acc side

Sensor used: 3-axis accelerometer.

Triggering conditions: This event is triggered by Thymio’s orientation in respect to the direction of gravity when the robot is turned to its left or right side, be it laying on the ground or hold in the air.

Example: When the robot is placed on its side, then … (robot action, for instance switching on the left light on the LED circle).

On the back

acc upside down

Sensor used: 3-axis accelerometer.

Triggering conditions: This event is triggered by Thymio’s orientation in respect to the direction of gravity when the robot is turned upside-down, be it laying on the ground or hold in the air.

Example: When the robot is placed upside down, then … (robot action, for instance making an unhappy sound).

Impact detection

tap

Sensor(s) used: 3-axis accelerometer.

Triggering conditions: This event is triggered by a shock in any direction. A tap with your hands, for instance, is detected as a shock.

Example: When the robot gets a tap, then … (robot action, for instance start moving forward).

Ground detection

ground mean

Sensor(s) used: ground proximity sensors.

Triggering conditions: This event is triggered by the detection of presence or absence of a reflecting ground below Thymio. Note that a transparent or a black (matte, non reflecting) surface will be detected as absence of ground.

Parameters: when the ground is set in white with a red border, a ground is detected. Setting it in black allows to detect no ground (or a black or a transparent ground).

Example: When I lift up Thymio and it does not detect the ground anymore, then … (robot action, for instance making a high frequency sound).

Ground sensors

ground

Sensor(s) used: two ground proximity sensors.

Triggering conditions: this event is triggered by the detection of presence or absence of a reflecting ground below Thymio. Note that a transparent or a black (matte, non reflecting) surface will be detected as absence of ground. This event allows the programmer to separately define what the left and right ground sensors should detect to trigger the event. This can be very useful to detect black lines on white paper, for instance to create line following behaviors.

Parameters: when the sensor is set in white with a red border, the sensor detects a reflective surface, for instance white. Setting it in black allows the sensor to detect no ground (or a black or a transparent ground). When a sensor is set to grey it is ignored.

Example: When the left sensor detects a white surface and the right one a black line, then … (robot action, for instance turn right toward the black line).

Proximity sensors

Proximity sensors

Sensor(s) used: five proximity sensors on the front and two on the back.

Triggering conditions: proximity infrared sensors measure the reflection of objects placed in front of them. If there is reflection, there is a close or reflective obstacle in front of them. No reflection means either a black obstacle or no obstacle at all. This event is triggered by detection of obstacles around Thymio, in seven different direction, by seven different sensors.

Parameters: when a sensor is set in white with a red border, the sensor triggers an event when detecting a reflective obstacle. Setting it in black makes the sensor trigger the event if there is no obstacle anymore (or a black obstacle, or a transparent surface). When a sensor is set to grey it is ignored.

When several sensors have been selected to trigger the event, the event is triggered by the combination of the conditions. If the front and the left sensors have been set to detect an obstacle, the event will be triggered when the front AND the left sensors detect an obstacle.

Example: When the left sensor detects an obstacle, then … (robot action, for instance turn right to avoid it).

Top color state

color 8 state

This condition block does not use a specific sensor of the Thymio. It reads the status of the RGB (Red,Green,Blue) LED displayed on the top of Thymio. It can be used only as a condition, not as a main event.

Triggering conditions: this condition is true when the top Thymio RGB LED is set to a specific color. The comparison on each color component is made by sectors, allowing the condition to be true also for an approximate color match.

Parameters: the programmer can choose one of the 7 available colors or the last parameter (bottom right) which represents the LED switched off.

Example: If the top LED on Thymio is yellow, then …. (robot action, for instance switch to red).

Bottom color state

bottom color 8 state

This condition block does not use a specific sensor of the Thymio. It reads the status of the RGB (Red,Green,Blue) LEDs displayed on the bottom of Thymio. It can be used only as a condition, not as a main event.

Triggering conditions: this condition is true when the bottom Thymio RGB LEDs are set to a specific color. The comparison on each color component is made by sectors, allowing the condition to be true also for an approximate color match.

Parameters: the programmer can choose one of the 7 available colors or the last parameter (bottom right) which represents the LEDs switched off.

Example: if the bottom LEDs on Thymio are blue, then …. (robot action, for instance switch them to red).

8-LED state check

state 256

This condition block does not use a specific sensor of the Thymio. It reads the status of the 8 LEDs around Thymio’s buttons. It can be used only as a condition, not as a main event.

Triggering conditions: this condition is true when the LEDs on Thymio display the same pattern (LEDS on and off) as defined on the block. Since each LED can be either on or off there are 256 possible combinations.

Parameters: every led can be set on (yellow) or off (dark grey). None of the LEDs are ignored.

Example: If only the top LED is on, then …. (robot action, for instance start moving forward).

Directions

move

Actuators: two wheel motors.

Action: this action sets a direction of movement for Thymio using a set of 9 predefined speed settings.

Parameters: Choose any arrow to make Thymio move or choose the center button to make it stop.

Example: when (event, for instance detection of obstacle on the left), then start moving forward right.

Set top color

top color 8

Actuator: top color LED

Action: this action allows the programmer to set a specific color for the top Thymio RGB (Red,Green,Blue) LED.

Parameters: the programmer can choose one of the 7 available colors or the last parameter (bottom right) which represents the LED switched off.

Example: when (event, for instance detection of obstacle on the left), then set the top color to yellow.

Set bottom color

bottom color 8

Actuator: bottom color LED

Action: this action sets a specific color for the bottom Thymio RGB (Red,Green,Blue) LEDs.

Parameters: the programmer can choose one of the 7 available colors or the last parameter (bottom right) which represents the LEDs switched off.

Example: when (event, for instance detection of obstacle on the left), then set the bottom color to blue.

Set 8-LEDs state

set state 256

Actuators: 8 circular LEDs around Thymio buttons.

Action: this action sets on or off each LED.

Parameters: every LED is set on (yellow) or off (dark grey).

Example: when (event, for instance forward button pushed), then switch on the front LED and switch off all others.

Play melody

notes

Actuator: speaker

Action: this action starts playing a melody with Thymio.

Parameters: each blue line corresponds to a tone. Up to six notes can be placed. Each click switches between black (one time unit), white (two time units), or pause (four time units).

Example: when (event, for instance pressing the forward button), then play a melody illustrating the start.