Discover our
resources

See all resources
See all resources
See all resources
See all resources
See all resources
Welcome
Welcome

Welcome to the resource section of the Learning Robots website

 

Here you will find all the pedagogical content developed by our Artificial Intelligence experts to guide you in your learning of artificial intelligence concepts using the AlphAI solution.

- If you have not yet downloaded the AlphAI software, please go to the following page download to take advantage of our 60-day free trial.
- If you're just discovering our solution, we invite you to learn a little more about it by visiting the page AlphAI Solution.

Download
Related courses
Software installation
Software installation

The software is designed to operate without an Internet connection (except for license activation and updates).

It does, however, require a wifi connection (recommended) or Bluetooth to communicate with the robot.

If you haven't purchased a license yet, you can take advantage of a 60-day trial version!


Windows installation

  1. Download the software 
  2. Launch the installation program
  3. Follow the instructions, then launch the software!

This screen appears once the software has been downloaded:

Screenshot - Software installation

System requirements:

  • Windows 8.1 minimum
  • 4 GB RAM
  • 2 GB hard disk space
  • OpenGL version ≥ 2.1
  • Internet access (during installation only for license retrieval)

* Windows 7 is not supported by Python 3.9, so our software cannot be installed on it. Please contact us for installation assistance.

Mac installation 


Go to the download and follow the instructions.

System requirements:

  • Mac OS
  • 4 GB RAM
  • 2 GB hard disk space
  • OpenGL version ≥ 2.1
  • Internet access (during installation only for license retrieval)

In case of difficulty, please refer to the FAQ page.



Linux installation

  1. AlphAI is compiled to work with python 3.9 (ideally python 3.9.13). If you have a python 3.9 environment, you can use this one. If not, you can download python 3.9.13 from
    https://www.python.org/downloads/release/python-3913/.
    In the following instructions, the python3 command refers to this python 3.9 environment.
  2. Download a version of AlphAI software: Download the installation script.
  3. Unzip the downloaded folder to the location where you want to install AlphAI.
  4. Open a terminal and navigate to the newly created folder, for example using the command: cd AlphAI-1.8.10.11.
  5. In the terminal, run the command: python3 -m pip install -r requirements-mac.txt. This should install all the python libraries needed to run the software.
  6. Finally, to launch the software, enter the command: sudo python3 Start_Alphai.pyc, then enter your user password. Please note that python3 must be replaced by an explicit path to the python interpreter, e.g. ./python3 or ~/Documents/AlphAI/alphaienv/bin/python3, otherwise the default interpreter will be launched.

System requirements:

  • Ubuntu 18
  • 4 GB RAM
  • 2 GB hard disk space
  • OpenGL version ≥ 2.1
  • Internet access (during installation only for license retrieval)

In case of difficulty, please refer to the FAQ page.

Download protection problem. My browser blocks software installation.
Download protection problem. My browser blocks software installation.
Download protection problem. My browser blocks software installation.
Download
Related courses
License activation
License activation

When you launch the software for the first time, the license activation window will appear.

Make sure you have an Internet connection, and choose one of the following options:

Check the Trial version box.

‍Inthis case, you have the option of using the software free of charge on this computer for a period of 60 days. Please note: this option can only be activated once per computer!



Use an activation key.‍

This will allow you to use the software for an unlimited period of time. To do this, enter your activation key in the field provided and select a validity period. At the end of the validity period, you'll need to reactivate your license. To make sure you don't lose it, you can save your activation key on your computer.
⚠️ Warning: this makes it possible to reactivate the license on this computer with a single click, so don't save your activation key on a computer that doesn't belong to you!




Reactivate your license with a registered key, by checking the Use registered key box. You will also need to select the duration of the new validity period.

The following window asks you to provide us with some information:

This step is not compulsory, but we kindly ask you to fill in the various fields. This information will enable us to provide you with assistance if necessary, and to inform you of any software updates.

About the validity period :

  • The validity period is the time during which you can use our software without an Internet connection.
  • When this period expires, you will be asked to reactivate your license, a step that requires an Internet connection.
  • Each activation key is issued with a limit on the number of simultaneous activations allowed (usually 2 computers or 30 computers).
  • If the software is to be used in a classroom, it is advisable to choose an activation period that corresponds to the period of intended use, e.g. until the end of the school year. This way, when the licenses expire, it will be possible to use the software in another room.

Example: Suppose my activation key has a limit of 2 computers. On January 1, I use this key to activate a license on computer A for 6 months (i.e. until June 30). Then, on February 1, I use the same key to activate a license on computer B for 3 months (i.e. until April 30). From February 1 to April 30, the maximum number of activations has been reached, so I can't use my activation key on a third computer. On the other hand, from May 1st, the license on computer B has expired, so I can activate a license on computer C for a period of my choice. Similarly, from July 1, the license on computer A is no longer valid, making it possible to activate on another computer (or renew the license on computer A).

How long do I have to activate my license once I've received it?
How long is my license valid?
How long do I have to activate my license once I've received it?
How long do I have to activate my license once I've received it?
Download
Related courses
Activation key validity
Activation key validity

Duration

Activation keys sold by Learning Robots are perpetual (updates are subject to an annual subscription). 

Device limits

Depending on the product you choose, your license is valid for 2 or 30 devices.

Thymio features

Licenses for Thymio robots have a few differences from other types of license. The first difference is that the license activation window will not appear when the software is launched, but only when you first connect to a Thymio robot.

If this robot is a simulation, then everything happens as described above.

If this robot is a real Thymio, then the license will be stored on the robot itself and not on your computer. This will then allow you to connect this robot to any computer where the software is installed, even if it doesn't have an active license. However, you will only be able to use your activation key in this way on a single Thymio robot. If you want to use AlphAI with several Thymio robots, you'll need to purchase a license for each robot.

The validity period for real Thymio robots is unlimited.

To connect your Thymio to your computer, please refer to the Thymio datasheet.

How long is my license valid?
How long do I have to activate my license once I've received it?
How long is my license valid?
How long is my license valid?
Download
Related courses
Software launch and updates
Software launch and updates

Launch the software by clicking on the shortcut (PC) or by running the command "alphai" in the terminal and entering your computer password (Mac).

When you launch the software, if you're connected to the Internet, it may detect that an update is required. It launches automatically, and takes just a few minutes!

You will then be taken to the login screen.

How often is the software updated?
How do I update the software?
How often is the software updated?
How often is the software updated?
Download
Related courses
Connection screen
Connection screen

Robot selection


In the top right-hand corner of the home screen, you can choose the robot model you'd like to work with. Depending on the license you've purchased, you can choose between :

  • the AlphAI robot
  • the Thymio robot
  • the mBot robot
  • the Buddy robot
  • Spike robot (LEGO)
  • computer (robot-free activities)

Connection modes


Depending on the robot you choose, you can choose between several connection modes: WiFi, Bluetooth (with a dongle or the computer's Bluetooth), or a simulated robot.


For the AlphAI robot, we recommend that you always choose a WiFi connection if possible. If you choose a Bluetooth connection, you'll find a button in the top right-hand corner of your screen that allows you to deactivate the "Bluetooth Low Energy" mode if your robot is an older model.

Simulation


AlphAI and Thymio robots can be used for a wide range of simulation activities. To understand how to use the simulation mode, please refer to the corresponding pages: 

Resources - AlphAI - Robot connection

Resources - Thymio - Connecting to the robot


Instructions and help

Depending on the robot you've chosen, buttons at the bottom of the screen provide instructions and information on how to connect to the robot and how to deal with bugs. If the instructions haven't helped you solve your problem, you can refer to our FAQ page.

How many robots can I connect to the same PC at the same time?
How do I connect my robot to wifi?
How many robots can I connect to the same PC at the same time?
How many robots can I connect to the same PC at the same time?
Download
Related courses
Main screen
Main screen

You are now connected to your robot and have reached the main screen. On this page, we present each of the elements you can see on the screen: 

The title


At the top of your screen, a title informs you about the characteristics of the currently selected settings: the learning mode (supervised, reinforcement, or no learning), the control mode (piloted/autonomous), and the number of data recorded in the experience memory during learning.

The robot

On the left of your screen, you can see an image of the robot you are currently using.

For the AlphAI robot, the sensors used in the activity appear in black.
The color of the wheels indicates whether they are blocked (red) or not (green).

You can also see the color of the shell.

Central display

The entire right-hand side of your screen is taken up by the central display. It can contain :

A neural network

On the far left, the input neurons: these are the robot sensors used.

In the middle, the connections and intermediate layers of neurons.

On the far right, output neurons and corresponding action icons: these are the actions the robot can perform.

You can fully parameterize the neural network (AI tab) and modify its visualization (Visualization tab).

A visualization of the state space

For example, if the chosen algorithm is K nearest neighbors, the neural network will be replaced by a graph. See the KNN activity

Visualization of learning data
Once you have provided the robot with example data, you can also display each piece of recorded data on screen: the information provided by the sensors and the associated action. You can correct a bias by deleting a piece of data, modifying an action, etc.

A combination of these elements

For example, in the Intruder detection activity, you can see the state space and the neural network

Video screen


If the camera sensor is required for the chosen activity, you'll see a return of the robot's camera in the top left-hand corner of your screen (even for a simulated robot!). If the activity uses the computer's webcam, this is where it will appear.

2D simulation (for the AlphAI robot)

If you have chosen the AlphAI simulated robot for your activity, a 2D arena will appear at the bottom left of your screen, with the simulated robot moving around it live.

If you wish to modify this simulated arena, open the Sensors tab and scroll down: you can then add/remove the central island and choose the color of the interior and exterior walls.

Battery level

If you're connected to an AlphAI robot, at the bottom left of your screen you'll see a battery level indicator. There are 2 states:

  • either the battery icon is green, in which case there's nothing to report
  • either the battery icon is red or black, in which case we advise you to disconnect the robot from the software and change the batteries immediately 

Changing batteries on an AlphAI robot


Awards and levels

If you've chosen an activity with reinforcement learning, 2 bars will appear at the bottom of your screen: reward (the rewards given to the robot according to the actions performed: red if negative, green if positive) and level (average of rewards received).

The color of the LEDs under the robot does not match the color of my robot.
Why won't my robot turn on?
The color of the LEDs under the robot does not match the color of my robot.
The color of the LEDs under the robot does not match the color of my robot.
Download
Related courses
Menus

Files

Example configurations

‍choosean example configuration from all those designed by Learning Robots! You'll find detailed instructions for each activity on the resource pages for the robot you're using:


AlphAI activities


Thymio activities


mBot activities

Load

  • Load configuration: selects a configuration saved on the computer (.json format)
  • Load default configuration: allows you to return to the default configuration.
  • Load training data: allows you to load training data that has been saved on your computer (.zip or .npz format - take care to load data that corresponds to the current configuration).
  • Load template: allows you to load a template saved on your computer (.zip or .pth format - take care to load a template that corresponds to your current configuration).

Save

  • Save configuration: saves the current configuration on the computer (.json format)
  • Save as default configuration: saves the current configuration as the default configuration (when you launch the software, this configuration will be loaded automatically).
  • Reset configuration: resets and loads the configuration to factory settings
  • Save training data: saves current training data on computer
  • Save model: saves the current trained model on the computer

Language

  • ‍Choosethe language in which you wish to use the software

Parameter display

‍Choosethe parameter display level between standard (more streamlined), advanced and expert (all options) modes.
We advise you to choose standard mode, unless you're familiar with AlphAI and have a good knowledge of AI.

Activate teacher mode

  • ‍Ifyou're a teacher, activating this mode will give you access to new features. To access it, you'll need your activation key.
    For example, in the help menu, you can click on "License information" to see the list of devices on which the license has been activated.

Other program parameters...

  • Font size: change the font size on the software if you wish to have a better view, for example, of neural network connection weights.
  • Big Brother: This option is used in particular in our "Ethics of AI" activity. Once activated by the teacher prior to the session, the program saves the images taken by the camera, without the students' knowledge, in a sub-folder of the software installation directory, named "to_upload" expressly to provoke reactions.
    The teacher can show this folder to the students at a later stage to discuss with them the issues surrounding data collection, with or without consent.
    The saved images are automatically destroyed when the program is closed. AlphAI software does not collect or transmit any information, and in fact works offline.
    This option can only be used for educational purposes.

Tools

  • Change configuration folder: allows you to change the location of the configuration folder on your computer. This folder contains log files and program settings.
  • Download robot event log: allows you to download the robot's log file (requires WiFi connection).
    Useful to pass on to us in the event of a bug!
  • Robot test: to detect any hardware faults on the robot

    From the login screen, you can also find :
  • Robot update: force robot update if it didn't work automatically
  • Diagnose robot start-up: check that the robot starts up correctly (this test takes about 20 seconds. Another window opens when the test is complete)

Aids

  • Resources: access the resources and help center provided by Learning Robots: find out everything there is to know about the AlphAI software, all the instructions and activities for each robot, the FAQ, etc.
  • Change log: access the list of updates
  • About AlphAI: tells you which version of AlphAI you are currently using

Report a bug

If you encounter a problem that you can't solve, this form allows you to send us a message that will be associated with the software log, and thus help us solve your problem (please enter your email address so that we can contact you if necessary).

Download
Related courses
Controls
Controls

Autonomy

Control your robot's autonomy with these buttons:

  • Autonomous: the robot is continuously autonomous
  • Step by step: click to watch your robot make one decision, and one decision only! The robot will take just one step each time you press the button.
  • Exploration: in reinforcement learning mode, this button lets you force your robot to occasionally attempt a random action (configurable in the AI tab).

Learning

Control your robot's learning curve:

  • Learning: if this button is selected, the robot stores the data supplied in its experience memory and changes the connections in its neural network. It's learning!
    In expert display mode, you have more control:some text
    • acquire data: if this button is activated, the robot memorizes the actions it performs.
    • Train the model: if this button is activated, the learning algorithm evolves the values of the model parameters.
  • Manual editing: in "Manual editing" activities, click this button to modify neural network parameters directly from the interface.
  • Forget action: if you click on this button, the robot forgets the last piece of data it learned: very useful if you make a mistake during the learning phase!
  • Reset AI: Clicking this button resets the training data and the model, so you can start learning the robot all over again!
    In expert display mode, you have more control:some text
    • Reset data: deletes stored training data
    • Reset model: model parameters are reset.

Graphs

This button opens a pop-up window giving you information about your robot's training, and graphs that present this data visually. 



This graph tracks the robot's progress by displaying its rewards and the error of its predictions over time. If the robot is progressing well, the reward graph should increase and the error graph should decrease.


If there is too much noise in the data, you can smooth the curves, for example over 2 minutes, by clicking on Smoothing - 2 minutes.

Settings (for AlphAI)

Use this button to set your robot's parameters:

  • Speed (from 15 to 50): you can set the robot's speed, depending on the activity and the size of the arena used.
  • Trajectory correction: the robot may have a small trajectory error. Use this tool to correct it (test using the go straight action).
  • Accelerated simulation: if you have chosen a simulated robot, this button lets you accelerate the robot's decision-making and actions, instead of imitating real speed.

Log off

Use this button to disconnect from the robot, to change the batteries or when your session is over!

⚠️ If you disconnect from the robot, you will automatically return to the home screen. However, if you reconnect the robot and restart the activity without quitting the software, neither the configuration nor your training data will be lost.

Download
Related courses
Tabs
Tabs

Sensors tab

The Sensors window lets you select the robot sensors to be used.

Click on a sensor to choose one of the possible usage options.


Find out more about the different sensors used in different robots:

AlphAI robot sensors

Thymio robot sensors

mBot robot sensors


You can also choose the number of instants, and in the case of a simulated robot, change the arena parameters.

Actions tab

The Actions window lets you choose which actions the robot can perform.

Click on an action to add it to the neural network.
⚠️ Adding a new action will delete the robot's experience memory.

Discover the different actions used depending on the robots involved:

AlphAI robot shares

Thymio robot actions

mBot robot shares

You can also choose speed, duration (from 0.1s to 2s), and whether or not you want the robot to pause between actions, and for how long.

Awards tab

If you have launched an activity with reinforcement learning, you can use the Rewards tab to choose the type of reward and its configuration.

Speed and blocking

‍Rewardthe robot if it goes fast, punish if it stops. You can customize the reward the robot gets when it performs a turning action, and the penalty value when it blocks or backs up.

Color in image‍

Reward the robot if many of the camera pixels are of a certain color.
You can customize hue, luminance and saturation.

Color and blocking‍

Reward the robot if many of the camera pixels are of a certain color, and punish it if it stops.
You can customize hue, luminance and saturation.

Line tracking

‍Recompensethe robot if it detects black just below it. You can customize the blocking detection threshold.

Python‍ code

Set up your own rewards using a Python code file.

AI tab

The A.I. tab lets you choose how the robot is trained, for example, whether to use supervised learning or Deep Q Learning. It also lets you set the parameters of the various algorithms.

" " = all modes

"advanced and expert only

" " = expert only

  • Type of learning

  • Algorithm: Select the AI algorithm used.

  • Learning speed: Increase for faster learning... but decrease if divergence errors appear.

  • Gamma: Adjusts the importance given to immediate rewards (value close to 0) in relation to more distant rewards (value close to 1).

  • Exploration: Frequency of explorations (value between 0 and 1).

  • Layers of intermediate neurons: Number of neurons in each intermediate layer e.g. leave blank to connect inputs directly to outputs, put "100 50" for two intermediate layers of 100 and 50 neurons respectively.

  • Activation function: choice of activation function for intermediate layers.

  • 2 neurons per binary variable: Check to have binary inputs represented by 2 neurons (of which one and only one will always be activated); Uncheck to use only 1 neuron.

  • Neuronal bias: Check to allow neurons to adjust their activation threshold (this is equivalent to considering that all neurons receive a constant input that they can adjust, not represented in the graphical interface).

  • Experience memory: Check to ensure that the AI continues to learn from past actions and rewards.

Visualization‍ tab

The View tab lets you choose what is displayed or not on the main screen.

" " = all modes

"advanced and expert only

  • Display type: neural network, state space, or both

  • Animation: animating activity in the network (movement from inputs to outputs)

  • Connections : Show network connections

  • Apprenticeships: Show apprenticeshipsessome text
    • green: connections intensify
    • red: connections decreasing

  • Synaptic activity: Display activity in the text network
    • yellow: exciting activities
    • blue: inhibition activities

  • Input/output values : Display values of input and output neurons

  • Connection values : Display connection weights. This option automatically activates the I/O display.

  • Spacing between neurons: switches input neurons from vertical to horizontal mode

For AlphAI robot only: you can change the color of the shell. Note: the robot will memorize its new color, which will then appear on the connection screen.

Download
Related courses
Python programming tools
Python programming tools

AlphAI API documentation


This document contains all the information you need to use the AlphAI API:

https://drive.google.com/file/d/1C4ovPW_eH5KFz5Y9JvSrzLhtmdOpcp6-/view

In the IA tab of the software



You can choose "Python code" for the algorithm parameter.

A pop-up window appears, prompting you to choose between creating a new file or opening an existing one.

This file is used to write python code that will be executed by the software.

In the Software Rewards tab (AlphAI only)



Program your own reward function by clicking on the "python code" button.

Download
Related courses
Updates
Updates

Learning Robots works continuously to develop the software's functionality and improve the user experience.

That's why we carry out updates from time to time, which start after approval when the software is launched if you're connected via WiFi. They only take a few minutes!

We advise you to update all workstations at the same time, to ensure you have the same version of the software on each workstation.


If you have any further questions, you can search for them in our FAQ or write to us via our contact form.

How often is the software updated?
How long does the update take to download and install?
How often is the software updated?
How often is the software updated?
Can I go back to earlier versions?
Download
Related courses
List of modifications
List of modifications

To consult the list of changes made during each update since the creation of the software, please refer to the following page:

AlphAI modification list

Download
Related courses
Recurring problems
Recurring problems

Please consult our FAQ!

Download
Related courses
Introducing the AlphAI robot
Introducing the AlphAI robot

Introduction

Learning Robots has designed a small, friendly-looking robot with a lot going for it!

This robot has been designed specifically for use with the AlphAI solution: its large number of sensors(in particular the wide-angle camera), its versatility and its compact size enable it to carry out all the activities available in the software.

This robot has been designed to be both robust and easy to dismantle at any time. 

The hulls and bumpers are printed in-house, giving us a great deal of freedom in the design of the robot. Don't hesitate to ask us for the 3D files via our contact form if you'd like to customize them! 

Composition


Sensors

Wide-angle camera

Ultra-sound

5 infrared line-following sensors

Operators

2-wheel drive

4 multi-color LEDS

Buzzer

On-board computer

Raspberry Pi Zero (linux, Python)

WiFi & Bluetooth connection to PC

Hull

Attractive, shock-absorbing, removable, available in 8 colors

  1. Sensors

The sensors you can use on the software are :

  • Obstacle detection Add a binary input (1 if the robot tried to move but failed, 0 otherwise).
    In expert mode, you have access to two additional parameters:some text
    • camera motion detection threshold: used to set the sensitivity of the obstacle detector. Increase the value if you have too many false positives (sensor detecting a non-existent obstacle), and conversely decrease the value if you have too many false negatives (sensor not detecting a real obstacle).
    • camera blocking height: allows you to ignore the upper part of the image when blocking is detected. With a value of 1, the entire image is analyzed, with a value of 0.5, only the lower half is analyzed.

  • IR sensors The 5 infrared sensors on the underside of the robot can be used. Each sensor communicates a value between 0 and 1, depending on the brightness of the surface. There are two main modes:some text
    • Black detection: value 0 corresponds to white and value 1 corresponds to black. Recommended for tracking a black line on a white background.
    • Reflection detection: value 0 corresponds to black and value 1 corresponds to white.

The binary mode option allows you to obtain only integer values 0 and 1 instead of decimal values between 0 and 1.

When binary mode is active, the IR threshold parameter is used to set the switching threshold between binary values 0 and 1. For example, when the threshold is set to 0.5 (default value), all values between 0.5 and 1 are rounded to 1, and all values between 0 and 0.5 are rounded to 0.

There are also several buttons(5 sensors, central sensor, indoor sensors, outdoor sensors) for selecting which subset of IR sensors to activate.

  • Ultra-Sounds : uses the ultrasonic sensor on the front of the robot. It communicates a value according to the distance sensed. There are 3 operating modes:some text
    • obstacle distance: the value returned is the distance from the obstacle measured in meters.
    • obstacle proximity: the value returned is inversely proportional to the distance measured.
    • Absence/presence of obstacle: the sensor returns 1 if an obstacle is detected and 0 otherwise. The obstacle detection distance can be adjusted using the slider below.



  • Camera: activates the camera on the front of the robot. Several options are available to determine camera resolution and whether or not to use the zoom function.

The camera image pre-calculation button is used to modify the processed values:

  • when pre-calculation is deactivated, the image defaults to color (RGB system).
  • grayscale mode captures the brightness of each pixel.
  • the color mode in the image detects colors. All white/gray/black pixels will obtain the value 0 and colored pixels the value 1.
  • green channel mode detects only the presence of green (values close to 1) or its absence (values close to 0).
  • red vs. green mode returns a value between -1 and 1 for each pixel, corresponding to the amount of red minus the amount of green.

The take photo button lets you take a photo with the robot's camera and save it on your computer.

  • The last action button activates the last action memory when the robot needs to make a decision. This can be useful, for example, to avoid situations where the robot performs an action which cancels out the previous action (moving backwards after having moved forwards, or pivoting to the right after having pivoted to the left).
  • In simulated robot mode, the simulated robot status sensor returns information on the position, orientation and speed of the simulated robot.

  1. The actions

The actions you can use on the software are :

You can also create a custom action by clicking on the button: 


The following window will then appear: 


Name your action and check "robot action" to modify the parameters: the new action is now available.

To save it for future use, click on File > Save > Save configuration.

  1. Operating environment

We recommend using the robot in an AlphAI arena.

Buy an arena (store link)

To carry out all the activities on the software, the robot will need :

  • A very flat, clean, solid-colored surface
  • Exterior and interior walls in different colors (and different from the floor), higher than the robot.
  • One or more lines on the ground in a color that contrasts sharply with the tarpaulin (use black scotch tape, for example; it's supplied with the arenas).

 

If you don't have an arena, or even a robot, there are plenty of activities you can do with the AlphAI robot, simulated in 2D in the software.

How do I connect my AlphAI robot via Bluetooth?
How do I connect my robot to wifi?
How do I connect my AlphAI robot via Bluetooth?
How do I connect my AlphAI robot via Bluetooth?
Download
Test
Related courses
Robot connection
Robot connection

Wifi (recommended)

Video - alphai - preparation 1

(Video in progress)

We recommend that you always use a WiFi connection if possible, as this enables you to communicate with the robot at a much higher speed. What's more, it's mandatory for robot updates.

  1. Look at the number on the underside of your robot, taking care to hold it by its base and not its shell, then switch it on by turning the PWR SWITCH to ON.
  2. Place the robot in the arena and wait a few moments, until the robot vibrates and flashes.
  3. Open your computer's WiFi connection panel: the robot will appear under the name "ALPHAI-00XXXX" (XXXX being the number you've written under the robot). Connect to the robot: the password is an exact copy of the WiFi network name (ALPHAI-00XXXX).
  4. Launch AlphAI software. In the top right-hand corner of the home screen, check that you have selected the AlphAI robot model.
  5. The robot with its number and a Wifi icon then appears on the connection screen: click on it
  6. The robot vibrates, its lights glow steadily and the software interface opens. And off you go!

⚠️ Before switching off your robot or changing its batteries, we advise you to press the "disconnect" button at the bottom right of the interface screen.

By Bluetooth

Video - alpha - preparation 2

(Video in progress)

If you prefer to connect the robot to your computer via Bluetooth, you should be aware that the transmission rate is lower than with WiFi. What's more, when the robot needs updating, you'll need to use the WiFi connection.

  1. Look at the number on the underside of your robot, taking care to hold it by its base and not its shell, then switch it on by turning the PWR SWITCH to ON.
  2. Place the robot in the arena and wait a few moments, until the robot vibrates and flashes.
  3. In your computer settings, check that Bluetooth is enabled.
  4. Launch AlphAI software. In the top right-hand corner of the home screen, check that you have selected the AlphAI robot model.
  5. Make sure that the "Bluetooth Low Energy" button at the top right of your screen is activated (with a yellow background).
  6. The robot with its number and a Bluetooth icon then appears on the connection screen: click on it
  7. The robot vibrates, its lights come on continuously and the software interface opens.

⚠️ Before switching off your robot or changing its batteries, we advise you to press the "disconnect" button at the bottom right of the interface screen.

Your robot doesn't appear? → BLE deactivation

In simulation

Video - alpha - preparation 3

(Video in progress)

If you don't have an AlphAI robot, you can still use our software with the 2D simulator: 

  1. Launch AlphAI software
  2. Check at the top of the screen that you have selected the AlphAI robot model in the software.
  3. Click on "2D Simulator
  4. The software opens: in the bottom left-hand corner of the screen, watch a small robot simulated in a 2D arena!
  5. The virtual arena can be customized by changing the colors of the outer and inner walls, as well as deleting this wall. To access it, Settings → View settings → ExpertSensors → bottom of page
Download
Related courses
Robot maintenance
Robot maintenance

Battery replacement

Video - alpha - preparation 4

(Video in progress)

The robot uses rechargeable lithium-ion batteries, which are very powerful but discharge quickly. For this reason, we recommend that you always keep the spare batteries supplied charged nearby.

If the robot's batteries are about to run down, a red battery icon will appear in the bottom left-hand corner of your screen. Change the batteries in less than a minute: 

  1. Press the "logout" button at the bottom right of the screen. You'll land on the home screen
  2. Lift the robot, taking care to hold it by its base and not its shell, then switch it off by turning the PWR SWITCH to OFF.
  3. Remove the robot shell by exerting gentle pressure on its base, then pivoting it forward to release the camera.
  4. The batteries are located on the rear panel: use your finger to replace them with charged batteries, taking care to observe the + and - signs.
  5. We recommend that you immediately place the empty batteries to be recharged on the AC charger supplied.
  6. Replace the shell on the robot, starting from the front; make sure the camera is correctly positioned in its slot, then check that the entire base of the shell is inserted into the robot chassis. Press gently on the back of the shell: you should hear a small "click".
  7. Switch the robot back on, reconnect it and resume your activity!

We recommend that you always charge the batteries used during activities at the end of the session.

Robot updates

Learning Robots is constantly working to develop the AlphAI software and robot, and to improve the user experience. That's why we release updates from time to time, which are automatically transmitted to the robot's Rapsberry Pi the next time it connects via WiFi.

See FAQ.

Recurring problems

Your robot won't turn on? Can't connect to the software? Are your robot's wheels blocked?

Find the answer to your problem on this page: 

See FAQ.

Support & warranty

AlphAI robots are guaranteed against malfunction for up to 2 years from date of purchase.

In case of intensive use, it is normal for motors to show wear: we offer motor replacement kits (link to store). Don't hesitate to contact us if you'd like us to take care of the replacement.

The Learning Robots team remains at your disposal. If you can't find a solution to your problem on our FAQ page, please don't hesitate to contact us via our contact form.

Download
Related courses
AlphAI Arena
AlphAI Arena

To enable the robot to evolve in a perfectly adapted environment, Learning Robots has designed a modular arena system that is easy to assemble and transport.

The arenas are available in 4 different sizes, which can be combined according to your needs and the number of robots.

They consist of painted wooden boards, tarpaulins and supports.

They are made from Jura pine by Olivier Sauge (artisans-du-bois.com) in France.

Composition

  • tarpaulin(s) to lay on the ground, with or without printed design, on a perfectly flat surface. Assemble the tarpaulins with painter's tape (included) to increase the surface area of the arena!

  • red planks, which form the outer walls of the arena, to be assembled using notches and brackets

  • black boards, which form the inner walls of the arena, to be assembled using the notches and brackets. Hold the black boards to the red boards using the racing banners.

  • race banner(s), which join interior and exterior walls, creating a race start for your robots! They are supplied with

  • Supports :
    • Feet: for use in corners under notches (interlocking boards) or at the ends. There's no need to use them on top.
    • Connectors: use to join boards in a straight line. It is advisable to use them both above and below the connections. They can be used both parallel and perpendicular to the boards, depending on the desired layout.

Video - alphai - preparation 5

(In progress)

Assembly

  1. Start by laying the tarpaulins on the ground, on a very flat surface, and hold them together with painter's tape for greater stability.
  2. Assemble exterior walls using notches and brackets (only underneath for feet)
  3. Position the inner wall(s) in the center of the arena with their foot supports.
  4. Connect the inside and outside walls with the racing banner(s), making sure to raise the banner(s) with the risers supplied.

The arenas can be adapted to suit your needs! Here are just a few examples:

⚠️ If you have a single black board in the center of the arena (which cannot be held to the outer red boards by the racing banner), we recommend doubling up this board using connectors for greater stability.

Using scotch tape

Using the black tape supplied with your arena, you can draw lines on the ground for your robot to follow! They can be easily removed from the tarpaulin at the end of the activity.
Video - alpha - preparation 6

(In progress)

The most common shape is an 8, but don't be afraid to use your imagination! Use gentle curves to avoid disturbing the robot.

Download
Related courses
Activity: Autonomous robot race
Activity: Autonomous robot race

Materials required:

  • 2 robots minimum
  • 1 computer/robot
  • Racing arena


The advantages of this activity :

  • Fun
  • Popular with all ages
  • Perfect for introducing the principle of supervised learning

Duration: 40 to 60 minutes

Age: + 8 years

Software configuration:
Robot run mode

A fun activity for an arena with several robots: students train the robots to drive around a circuit, then organize a race. Through manipulation, students learn the principle of supervised learning and the importance of quality training data.

Robot racing is the recommended activity for getting started with AlphAI.

Video content

Introduction

Build your arena to form a circuit. We recommend using a racing arena designed by Learning Robots, but you can also build your own circuit: in this case, make sure there's a good visual contrast between the ground and the edges of the circuit, as well as uniform lighting. Make sure the floor is clean too.

Setting

Connect each robot to a computer, then choose the "robot race" example configuration or create your own settings.

Make sure that all robots have the same settings and, above all, the same speed.

Training

Check that the "stand-alone" button is deactivated, and that the "learning" button is activated.

It's your turn to play! You can train your robot to move by clicking on the actions on the right of the screen, or by controlling it with the arrow keys or AZEQSD on the keyboard.
We recommend that you move around the arena in a clockwise direction.

During this learning phase, there's no need to try to go fast: the aim is to teach the robot to make turns in the right direction, without bumping into walls. Take the time to choose the right action each time (if you make a mistake, click on "Forget action" next to the learning button). Be careful not to confuse left and right when the robot is moving in the opposite direction!

Teach the robot to stay away from the central obstacle to avoid getting stuck when it becomes autonomous.

You can also move the robot by hand to intentionally confront obstacles and teach it what to do in these situations.

In the control panel at the bottom of the screen, you can set the robot's top speed. We recommend a maximum speed of 30 for a small race arena, 35 for a large race arena, and 40 for a very large race arena.

The higher the speed, the faster the robot will be, but the harder it will be to control. Choosing a very high speed is not always an advantage!

Learning tests and improvements

Once you've done a few laps around the arena, you can activate autonomy. If your robot is well trained, it will then start doing tricks on its own!

But the learning process isn't over yet: even when the robot is self-piloting, you can continue to control it by pressing the arrow keys while it's moving. For example, if the robot gets stuck against a wall and doesn't know what to do, you can unblock it by asking it to go backwards.

The robot race

Once your robots have been trained, organize a competition: place the competing robots on the starting line. Give the starting signal, and the teams simultaneously click on the "Autonomous" button (or press the space bar) to start the race.

During the race, only autonomous mode is allowed: participants must not give instructions to their robot. A referee may move robots that are blocked for more than 5 seconds, to allow them to continue the race.

The first robot to complete 3 full laps wins!

Feedback and conclusion

Here we have used a supervised learning algorithm. This algorithm is based on the artificial neural network displayed on the screen (but there are other types of algorithm that are not based on neural networks, such as the K-nearest neighbor algorithm). All supervised learning algorithms work as follows:

In a first phase called training, we provided the algorithm with example decisions, i.e. both images of what the robot's camera sees and the actions it should choose when the camera sees these images. During training, the artificial neural network was modified by the learning algorithm (more specifically, certain connections were strengthened, others diminished, so that the neural network became capable of mimicking the same decision making).

In a second phase, called utilization, the algorithm is able to make good decisions on new images.

We have seen that not all the robots learned the same thing: some performed better during the race, others worse. As all participants used the same algorithm, we can see that the quality of autonomous decision-making depends on the quality of the training data.

We can discuss together what makes quality training data:

- Quality of training data = absence of decision-making errors

- Data quantity not always a guarantee of autonomy quality

- Exhaustiveness of situations: the robot is more likely to make the wrong choice when faced with an unknown situation.

Further information

Now that the students have understood that the most important factor in winning the race is the quality of the training data, start the activity all over again!

You can also restart the race by adding new rules:

  • Limit training data (e.g. 25 data points maximum), but allow participants to move their robot by hand.
  • Making the arena more complex
  • A different arena for training and racing

Materials required:

  • 2 robots minimum
  • 1 computer/robot
  • Racing arena

Duration: 40 to 60 minutes

Age: + 8 years


The advantages of this activity :

  • Fun
  • Popular with all ages
  • Perfect for introducing the principle of supervised learning

Software configuration:
Robot run mode

Activity: Line tracking
Activity: Line tracking

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Flat, light-colored surface
  • Black adhesive tape

Software settings: "Line tracking" in manual mode (create connections directly in the software) or supervised learning mode (train the robot on the track).

Duration: 20 to 30 minutes

Age: 10+ years

The advantages of this activity : 

  • Little equipment required
  • Quick and easy to make
  • Easy-to-understand neural network

This activity is carried out with each robot individually. We're going to teach the robot to follow a line on the ground, without making any mistakes!

Students will learn that the success of supervised learning depends more on the quality and completeness of the robot's training data than on its quantity. They will easily understand the neural network principle, as the one used in this activity is very simple and easy to read (5 inputs, 5 or 6 outputs).

Video content

Introduction

On a flat, light-colored surface, trace a course using dark-colored tape (supplied with the arenas).

= Video - alpha - preparation 6 (in progress)
If you wish to use your own equipment, please ensure that the robot is able to perceive the contrast between the ground and the line.

The classic shape is an "8", but feel free to use your imagination!
Be sure to create gentle curves to avoid disturbing the robot.

Parameter setting (connection)

Connect the robot to a computer, then choose the "line tracking" example configuration for manual editing or supervised learning, or create your own parameters.

Use the cursor at the bottom of your screen to check that the robot's speed is less than or equal to 20.

Training

If you are editing manually : 

Check that the "stand-alone" and "learning" buttons are disabled, and that the "manual editing" button is enabled.

Click on the links between the input (infrared sensors) and output (robot action) neurons to create a connection. We recommend you create the following connections: 

  • Left IR sensor: rotate left
  • Center-left IR sensor: turn left
  • Central IR sensor: go straight ahead
  • Center-right IR sensor: turn right
  • Right IR sensor: rotate to the right

This is what your neural network should look like: 

If you are a supervised apprentice : 

Check that the "stand-alone" button is unchecked, and that the "learning" button is checked.

Place the robot on the line drawn on the floor to activate the sensors. Each time one of the sensors is activated, trigger the corresponding action: 

  • Left IR sensor: rotate left
  • Center-left IR sensor: turn left
  • Central IR sensor: go straight ahead
  • Center-right IR sensor: turn right
  • Right IR sensor: rotate to the right
  • No sensor: back off

We recommend that you give several examples for each situation.

Learning test

Once the neural network is configured, let's see if the robot manages to follow the line!

Place it at the beginning of the course, activate the autonomy and watch how it performs. 

You can then make the track more complex by adding intersections to create new challenges for the robots!


Review and feedback

Thanks to a very simple neural network and very little training data, the robot succeeded in following the line.

We can observe on the software the weight given to each connection, and understand how the robot makes its decisions: depending on which sensor is activated (or not), the algorithm assigns preferences to each of the actions to be chosen: the robot selects the action with the strongest preference.

Has your robot gone off track or taken the wrong action? Find out why! Here are a few suggestions:

  • there's a bias: you've made a mistake in training the robot
  • several sensors are activated at the same time, for example at a crossroads: has the robot been trained to react to this situation?
  • the angle of a ground line curve is too steep
  • robot speed is too high

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Flat, light-colored surface
  • Black adhesive tape

Duration: 20 to 30 minutes

Age: 10+ years

Software settings: "Line tracking" in manual mode (create connections directly in the software) or supervised learning mode (train the robot on the track).

The advantages of this activity : 

  • Little equipment required
  • Quick and easy to make
  • Easy-to-understand neural network

Related courses
Activity: Robot tracker
Activity: Robot tracker


Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Optional arena
    (recommended for high surfaces)

Software configuration :

  • example configuration:
    "navigation with camera

Duration: 1 hour


Age: 8+ years

The advantages of this activity :

  • Fun and visual
  • Quick to set up
  • Very suitable for younger children

Students can teach the robot to follow their hand or a clearly identifiable object.

This can be taken a step further by letting the students' imaginations run wild, creating courses or choreographies in which the robot reacts to various visual cues, such as hand signals.

‍Video content

Introduction

Place the robot on a table with enough space to move around. You can use an arena if you don't want the robot to fall off the table. In this case, a small, unobstructed arena will suffice.

Setting

Connect the robot to the computer, then select the "navigation with camera" example configuration.

We'll use the camera sensor, and the following actions: move forward, rotate right, rotate left, and stop.

Be sure to adapt the speed to the size of the table.

‍‍

Training and implementation (learning phase)

Training will be done in pairs, taking care to be well coordinated.
One of the students will wave to the robot, while the other manages the software.

The aim is to teach the robot to follow the student's hand (or a clearly identifiable object).

In the first phase, one of the students places his hand in the robot's camera field of view, while the other chooses the action that will bring the robot closest to the hand. Give the robot several examples for each hand position in the image.

In the second phase, you'll need to teach the robot to stop when it doesn't see a hand. Again, the robot needs several examples with different points of view: the student in charge of the software clicks on the "stop" action, while the other student places the robot in different locations (taking care not to put anything in front of the camera, of course!).

Learning tests and improvements

Now activate Stand-alone mode.

Check that the robot has learned correctly by observing whether it follows your hand correctly.
If this is not the case, deactivate autonomous mode again and re-train the robot.

Avenues for further development

  • Reverse the roles. Does the robot manage to follow the other student's hand or a different object? If not: continue training until the robot is able to follow the hands of both students.
  • Place the robot on a course (draw 2 parallel lines on the floor, for example), set it in autonomous mode and guide it along the course by hand. Allows you to evaluate both the robot's training and the student's guidance.
  • Train one robot to follow another! The robot in front will be controlled, and the other will have to follow in autonomous mode. Tip: remember to choose a slightly slower speed for the following robot.
  • Visualize training data and correct errors. This will improve the robot's behavior.

Review and feedback

The students' mission was to train an AI (supervised learning).

After learning, the robot is able to interact with a user by reacting to hand signals.

By showing the robot examples, it can correctly associate the right actions with the corresponding hand signals, thus "communicating" with it.

Notions to remember:

  • Training data determines robot behavior.
  • Data quality (absence of errors) is very important.
  • We also need to provide the robot with sufficiently diverse examples if we want it to be able to generalize the behavior it follows (e.g. following another object or a different hand).


Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Optional arena
    (recommended for high surfaces)

Duration: 1 hour


Age: 8+ years

Software configuration :

  • example configuration:
    "navigation with camera

The advantages of this activity :

  • Fun and visual
  • Quick to set up
  • Very suitable for younger children

Download
Related courses
Activity: KNN algorithm
Activity: KNN algorithm

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Minimum individual arena (without obstacles)

Software configuration :

  • example configuration: "KNN camera".

Duration: 30 minutes


Age: + 14 years

The advantages of this activity :

  • Intuitive algorithm
  • Can be performed with the simulator
  • Excellent visualization of robot decision-making

Visualization and application of the K-nearest neighbor algorithm (part of the first year NSI curriculum) to teach the robot to avoid obstacles.

Expert level: in the "Advanced KNN Algorithm" activity, students can reprogram the algorithm themselves and implement it on the robot.

Video content

Introduction

Place the robot in an arena without interior walls. Make sure the arena is well lit, so that there is a strong contrast between the floor and the walls.

Setting

Connect the robot to the computer, then select the "KNN camera" example configuration.
Ensure that the robot speed is 30 or less.

For this activity, the robot analyzes camera images whose resolution has been reduced to just 2 pixels, and without color. The result is a left pixel and a right pixel, which measure gray levels. The abscissa (left pixel) and ordinate (right pixel) of the graph show these grayscale values, with 0 corresponding to black and 1 to white.

The default actions are forward (yellow), rotate left (pink) and rotate right (green).

It is possible to add more actions for this scenario, but be sure to do so from the outset, as modifying actions causes experience memory to be erased.

Training phase

Check that the "stand-alone" button is unchecked, and that the "learning" button is checked.

Steer the robot by clicking on the arrows on the right of the screen, or by using the arrow keys on your keyboard.

Turn when the robot is close to the walls, go straight otherwise. You can also move the robot by hand to suit each situation.


After each movement, a new point appears. The position of each point is determined by its coordinates (x; y), with the x-axis representing brightness in the left-hand zone and the y-axis representing brightness in the right-hand zone. The color around each point is the color associated with the chosen action (green to rotate right, yellow to rotate forward and red to rotate left).

These points are the training data. This phase is essential if the AI is to work properly. If the training data contains too many errors or approximations, the AI will not deliver a satisfactory result.

When you've finished training, open the Visualization panel and check the "Background" box in the "State space" section.

You will then see the 3 different color zones appear on the screen, corresponding to the action the robot will choose according to the brightness captured by its camera.

If your robot has been properly trained, the graph should look like this: 

Brightness decreases as the robot approaches the walls. Normally, if the area on the left is the darkest, turn right, and vice versa.

When you have three clear regions on the graph, stop the training phase and activate autonomy to move on to the test phase.

Learning tests and improvements

Activate autonomy by clicking on the corresponding button on the screen or by pressing the space bar.

How does the robot behave? Does it avoid obstacles as expected?
If the robot is well trained, it will be able to avoid the edges on its own. If, on the other hand, the robot is poorly trained, or the lighting conditions in the arena are uneven, the colored areas on the graph will have more irregular contours, and the robot will perform more inappropriate actions.

Understand the algorithm's decision-making: the largest point is the one captured by the camera at that moment: it links up with the nearest point in the graph, which was recorded during the training phase: it is the action corresponding to its nearest neighbor that it will choose to perform!

Further information

  • In the AI tab, vary the value of k (the number of neighbors). Observe the effect on decision making and graph background coloring. Which value of k gives the best behavior? Why or why not?
  • Once you've fully understood the learning principle, repeat the learning process with a smaller number of points (e.g. 5-point training challenge only).

Review and feedback

Points to remember :

  • The principle of the k-nearest neighbor algorithm: understand and explain how the robot makes decisions.
  • What impact does training data have on results? How do I choose the right training data?
  • What is the impact of parameter k? How do you choose the best value for this parameter?

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Minimum individual arena (without obstacles)

Duration: 30 minutes


Age: + 14 years

Software configuration :

  • example configuration: "KNN camera".

The advantages of this activity :

  • Intuitive algorithm
  • Can be performed with the simulator
  • Excellent visualization of robot decision-making

Activity: Intruder detection
Activity: Intruder detection

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • a flat object (box, board, smartphone, etc.)

Software configuration :

  • example configuration: "intruder detection

Duration: 2 hours

Age: 15 and over

The advantages of this activity : 

  • Ideal for the classroom
  • Little equipment required
  • Cross-disciplinary (maths / IT)

Intruder detection

Mathematical understanding of neural networks through an activity based on the robot's ultrasonic sensor. In particular, we discover why intermediate layers of neurons are needed.

Video content

Installation

Place the robot next to the computer, facing a wall (or arena board) about 50 cm away, and provide a flat-sided object (a box, a board, a smartphone) to play the role of intruder.

Load 'Intruder detection' configuration. This scenario uses the ultrasonic sensor only.

The entire activity is carried out in 'manual editing' mode, i.e. you choose the neural network parameters yourself, without using a learning algorithm.

Interface presentation

In this activity, your main screen has two views:

  • Below, the neural network under study. At the start of the activity, the manual editing mode must be activated, allowing you to modify the neural network parameters yourself. To modify the value of a connection, place your mouse over it (it turns red), then use your keyboard to enter the desired value, or your mouse wheel to modify the current value. To modify the value of a neuron's bias, place your mouse over the neuron itself (not the value display), then proceed as for connections.
  • Above, a graph showing thestate space. On the abscissa, the distance measured by the ultrasonic sensor. On the ordinate, the activation levels of the output neurons. There are two curves represented because there are two output neurons. Curve/neuron correspondence is color-coded. The value of the output neurons is a function of the input value (distance). The background color of the graph indicates which curve is above the other for each input value, and therefore which action will be chosen by the robot for that input value.

‍‍

Objectives and issues

The robot faces a wall and must beep when someone (an intruder) passes between it and the wall.

The neural network must be configured to perform this task. Since the only sensor used is the ultrasonic sensor, the aim is to obtain a beep when the distance is small, and the action 'do nothing', when the distance is normal.

Integration of neural biases

The simple 'connection weight' parameters are insufficient to accomplish this task. We need to activate the 'neural bias' option (in the AI tab), which unlocks new parameters that will enable us to achieve this goal.

Attempted cheating

Issues

An intruder tries to cheat by exploiting the characteristics of the ultrasonic sensor: if the flat side is placed diagonally to the sensor, the waves bounce back and the distance captured is then much greater than that of the wall! We need to adapt our neural network to detect this cheating attempt too.

Intermediate neural layers

To do this, we'll need to add an intermediate layer to our neural network (in the AI tab), in order to obtain a non-linear model thanks to the activation functions.

Review and feedback

I remember:

  • A neural network is a set of neurons organized in layers. Each layer may contain one or more neurons.
  • Neurons are abstract objects containing a simple numerical value.
  • Neurons are linked together by connections whose values are called weights.
  • Each neuron also has a bias, which is added to the neuron's value.
  • Input layer neuron values are determined by sensor values.
  • The neurons in the output layer correspond to the robot's actions. In autonomous mode, the action with the highest value is always selected.
  • Intermediate layers enable the network to perform more complex tasks. The graph shows that the straight lines of the output neurons are replaced by increasingly complex curves as the number of intermediate layers increases.
  • Training a neural network simply involves choosing a value for each of its parameters: connection weight and neuron bias. When the number of neurons and connections becomes large, this complex task is performed by a learning algorithm!

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • a flat object (box, board, smartphone, etc.)

Duration: 2 hours

Age: 15 and over

Software configuration :

  • example configuration: "intruder detection

The advantages of this activity : 

  • Ideal for the classroom
  • Little equipment required
  • Cross-disciplinary (maths / IT)

Activity: Obstacle avoidance
Activity: Obstacle avoidance

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Minimum individual arena

Software configuration :

  • example configuration: "Reinforcement learning - obstacle avoidance

Duration: 30 minutes

Age: 8+ years


The advantages of this activity :

  • Introducing reinforcement learning
  • Understanding the "try and learn" principle = pedagogical benefits
  • Can be performed with the simulator

This activity involves observing a robot learning autonomously, based on the principle of reinforcement learning. Some general conclusions can be drawn about the conditions required for effective learning.

Video content

Introduction

In this activity, we're not training the robot: it's the robot itself that will create the examples it uses to make the right decisions about which actions to take.
To help the robot distinguish between good and bad decisions, the algorithm includes a reward system.

Here, the robot receives the following rewards for its actions: 

  • advance: 100 points
  • turn: 82 points
  • back off: -50 points
  • The robot also receives a penalty of -50 points for blocking.

In the "Level" bar, you can see the average reward score obtained by the robot. Its aim is to maximize this score, so it will gradually learn to choose the actions that will bring it the optimum rewards, taking into account what its sensors are telling it.

We'll now be able to observe the robot's progress as it learns. Start by setting up an obstacle-free arena, and place the robot in it.

Learning to use the robot independently

In the AlphAI software, select the example configuration: "Reinforcement learning - obstacle avoidance".

In this activity, the robot teaches itself!

Start the autonomous mode, and watch your robot. How does it behave?
When the robot has identified a rewarding action (e.g. turning), it may decide to perform only that action from now on.

We'll now activate the "explore" button: from time to time, the robot will decide to perform a random action. This will enable it to discover that the action it would have chosen may not be the optimal reward, and to enrich its learning with new data.

Normally, he learns in succession to go straight ahead, to turn around when he bumps into an obstacle, and then to recognize these obstacles in advance and turn before bumping into them! This learning process takes about 10 minutes.

Don't hesitate to deactivate the "exploration" mode when the robot starts to choose the right actions to perform.

Review and feedback

Once training is complete, stop your robot and click on "graphs" in the bottom bar (if the button doesn't appear, change the parameter display to "advanced" or "expert"). Normally, the values should be very high at the start of the activity, then gradually tend towards zero: the robot has trained itself not to make any more mistakes!

The way reinforcement learning works can be summarized as follows: 

What's needed to teach the robot :

  • Repetition of the same task: the robot doesn't immediately find the right solution, but only improves through repetition.
  • Exploration: the robot may need to try out new ideas, to avoid being locked into a non-optimal solution.
  • Rewards or penalties : the robot needs external help to assess whether its decisions are optimal or not.
  • Room forerror: the robot learns from its mistakes without getting discouraged! Mistakes help it learn which actions not to repeat!

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Minimum individual arena

Duration: 30 minutes

Age: 8+ years

Software configuration :

  • example configuration: "Reinforcement learning - obstacle avoidance


The advantages of this activity :

  • Introducing reinforcement learning
  • Understanding the "try and learn" principle = pedagogical benefits
  • Can be performed with the simulator

Download
Related courses
Activity: Blocked VS Movement
Activity: Blocked VS Movement

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Individual arena

Software configuration :

  • example configuration: "Blocked VS Movement" in manual editing mode, then in "reinforcement learning" mode

Duration: 90 minutes

Age: 15 and over

The advantages of this activity :

  • Understanding the Q-learning algorithm
  • Multidisciplinary (math/computer science)
  • Can be performed with the simulator

The aim of this activity is to understand how the Q-learning algorithm works.

Q-learning is a reinforcement learning algorithm. The robot learns by trial and error, based on rewards determined by the user (as in the "Obstacle avoidance" scenario).

Using this method, we're going to train an AlphAI robot to move around an arena without getting stuck against the walls. This simple task will give us a good understanding of the mechanisms involved in the neural network.

Video content

Installation

Place the robot in a small, unobstructed arena. 

Reward and manual editing

In the first part, we discover the principle of rewards, and use the "manual editing" mode to find the robot behavior that maximizes the rewards received.

Reinforcement learning

In the second part, we observe the robot's step-by-step learning process and the evolution of connection weights in the network. We discover the importance ofexploration in learning.

Q-learning

The next step is to discover the Q-learning algorithm itself. It mainly consists of a formula for updating the connection weights after each robot trial. This formula involves two parameters whose usefulness is debated.

We are discovering the impact of temporality on learning: we need to learn fast enough without 'jumping to conclusions'. The algorithm must also be able to take future rewards into account, and not just the immediate reward: it must develop a longer-term vision.

Deep Q-learning

Deep Q-learning is an evolution of the Q-learning algorithm to apply it to more complex (multi-layered) neural networks. This is the algorithm used in the "Obstacle avoidance" scenario, for example.

Materials required:

  • 1 robot minimum
  • 1 computer/robot
  • Individual arena

Duration: 90 minutes

Age: 15 and over

Software configuration :

  • example configuration: "Blocked VS Movement" in manual editing mode, then in "reinforcement learning" mode

The advantages of this activity :

  • Understanding the Q-learning algorithm
  • Multidisciplinary (math/computer science)
  • Can be performed with the simulator

Download
Related courses
Activity: Remote-controlled AlphAI
Activity: Remote-controlled AlphAI


Materials required:

  • 1 computer/robot
  • 1 robot minimum or software simulation
  • Optional activity arena (robot race)

Software configuration :

  • example configuration: depends on the code situation

Duration: 1 to 2 hours

Age: + 14 years

The advantages of this activity :

  • Can be performed with the simulator
  • A very good introduction to programming

In this Python programming activity, students learn how to send commands to the robot based on the keys pressed on the keyboard, and then organize a robot race.

Video content

Handling the robot

The alphai.py module sends instructions written in Python to the robot.

For the module to work, the "AlphAI" software must be running. You can connect to an AlphAI robot (or its simulated version).

In your favorite Python editor, create a new project in the location of your choice and configure the Python environment to contain the alphai module by typing in the IPython console or a terminal :

pip install alphai-api

This command downloads and installs the module and its dependencies.

Open a new python document or restart the console, copy and execute the following code:

from alphai import *

motor(30, -30, 5)

If the first line of the program causes an error, the alphai library has not been installed correctly. If the line motor(30, -30, 5) causes an error, AlphAI has probably not been started.

If there is no error, you watch the robot (or the robot simulated in the software) turn on itself for 5 seconds.

The motor(left, right, duration) command sends left and right values to the robot's left and right motors for duration, after which it stops. The left and right values must be between -50 and +50. If the duration is not specified, the robot continues to move forward until the next motor(0,0) call.

⚠️ It is possible and sometimes useful to make the connection in your python script rather than by clicking "connect" in the software, using the functions connect_bluetooth(n) (replacing n with the number of your robot) or connect_wifi(), as well as disconnect() to disconnect.
The code in this case looks like this:

from alphai import *

connect_bluetooth(n)
motor(30, -30, 5)

disconnect()


On the right-hand side of this page, in the downloadable appendices, you'll find the documentation for the alpha-api library, which contains all the functions included in the alphailibrary . Check it out now.

First script

Now you can create a Python script in your favorite programming environment.

Create a new Python file and copy the following code:

from alphai import *


if _ _name_ _ == '_ _main_ _':
connect_bluetooth(n)
motor(30,30,1)
disconnect()

Then execute it: the robot moves forward for one second, then stops.

The motor(left, right, duration)command sends left and right values to the left and right motors. These values must be between -40 and +40. Naturally, motor(0, 0) is used to stop the robot.

On the right-hand side of this page, in the downloadable appendices, you'll find the documentation for the alpha-api library, which contains all the functions included in the alphai library . Check it out now.

Programming a sequence

To make coding easier, define the following five functions. Make them very simple: each function should only make one call to the motor function.

forward()

Moves the robot straight ahead.

backward()

Moves the robot backwards.

stop()

Stop the robot.

left()

Rotates the robot to the left.

right()

Rotates the robot to the right.

Finally, create a walk_around() function that causes the robot to perform a sequence of actions using these five functions. Test it by calling it in the main block.

Remote control programming

Reading pressed keys

Using the API function wait_for_key (see explanations on last page) and a while loop in the main function, print the keys pressed on the keyboard in the console. To avoid writing an infinite loop, use a special key to exit the loop, such as the "esc" key:

keys = []

while "esc" not in keys:

    # don't forget indentation

Remote control programming

Still using the wait_for_key function and a while loop, create a remote_control()function that reacts to directional keys in such a way that the robot moves according to the instructions given on the keyboard. To retrieve the last key pressed, select the last item in the list using the -1 index. Warning: the list may sometimes be empty!

Remember to stop the robot when no key is pressed. Test your code by remote-controlling the robot!

Further information

We'll be able to organize races between your remote-controlled robots, but you'll also want to improve your program by adding new commands, as suggested below... These improvements are only suggestions, so don't hesitate to create your own!

Different curves

Create two new functions that you can use when the wait_for_key function returns a list of several keys:

forward_left()

Moves the robot to the left when the top and left arrows are pressed simultaneously. In this way, you can make the robot make both tight turns with left() (left arrow only) and wide turns with forward_left() (top and left arrows).

forward_right()

Pressing the up and right arrows simultaneously also moves the robot to the right.

Braking and boost

Add input variables to all your functions, so you can modulate the robot's speed, or the strength of turns, depending on which other keys are pressed.

For example, add a speed input variable to all your functions (e.g. forward(speed)), and call the functions with a lower speed when the space bar is pressed at the same time (braking), and a higher speed when the "x" key is pressed at the same time ("boost").

Pilot your robot and adjust the speed parameters to make it as maneuverable and fast as possible. Don't forget to practice overtaking competitors too!

Programming a sequence

On the key of your choice, have the robot perform a little choreography, for example to celebrate victory!

Review and feedback

In programming, the list of accessible program functions is called an API, for Application Programming Interface. It is used by programmers to find out how to interact with the program. You'll find the API for the alphai python module here: https: //drive.google.com/file/d/1C4ovPW_eH5KFz5Y9JvSrzLhtmdOpcp6-/view


Materials required:

  • 1 computer/robot
  • 1 robot minimum or software simulation
  • Optional activity arena (robot race)

Duration: 1 to 2 hours

Age: + 14 years

Software configuration :

  • example configuration: depends on the code situation

The advantages of this activity :

  • Can be performed with the simulator
  • A very good introduction to programming

Activity: Camera programming
Activity: Camera programming

Materials required:

  • 1 robot minimum or software simulation
  • 1 computer/robot
  • Racing arena

Software configuration :

  • example configuration: depends on the code situation

Duration: 1 to 2 hours

Age: over 15

The advantages of this activity :

  • Can be performed with the simulator

Python programming: get to grips with the ultrasound and the camera to program autonomous robot movements, then organize a robot race.

Video content

Introduction

The aim of this tutorial is to program AlphAI so that it moves autonomously, rather than being "remote-controlled" by the student as in the "Remote-controlled AlphAI" tutorial. To do this, we'll need to use its sensors to enable it to react to its environment, in particular to detect obstacles. 

We'll look at a quick example using ultrasound, then move on to the camera to organize autonomous robot races on a circuit.

Navigation with ultrasound

Discover the ultrasonic sensor

The get_distance() function (details in the API on the last page) returns the distance measured by the robot's ultrasound (in centimeters). Make sure you activate the sensor with the set_distance(True) function, or it will return the value None instead of distance.

Test this function with the real robot with the following code:

set_distance(True) # activate the ultrasonic sensor
while True:
d = get_distance() # retrieve the ultrasonic value from the robot
print("distance:", d)

By moving the robot by hand, check that the measured distance decreases when the robot is facing an obstacle. You may also notice that, unfortunately, if the robot is in front of a wall, not directly in front of it, but diagonally, this wall is not detected (the measured distance is much greater because the ultrasound reflects off the diagonal wall without returning directly to the robot).

Autonomous movement with ultrasound

Using the get_distance() function, define and test an ultrasound_race() function that moves the robot forward until it detects an obstacle with its ultrasound, and pivots to the right when it detects an obstacle. 

Don't try to achieve perfect behavior (that would be difficult). As soon as you have a behavior where the robot knows how to turn if it's facing a wall, and how to go straight if there's no wall, move on to the next step.

Camera navigation

The camera provides much richer information than the ultrasonic distance sensor, and will enable more sophisticated decision-making.

Discovering the camera image

Let's start by displaying the robot's camera image in the software. Open the "Sensors" settings tab on the left, and choose the "64x48 image" camera mode.

the image of what the robot sees appears. 

An image is a grid of pixels; in a color image, as in this case, each pixel contains 3 values: the intensities of red, green and blue in that pixel. To see this more clearly, select the low-resolution camera mode "8x6 image".

and in the "Visualization" tab, check "Camera: degraded resolution".

: a very coarse image appears, and the red/green/blue values of each pixel are displayed (values between 0 and 255). 

To set the image resolution in the Python code rather than in the software, start by initializing the camera, e.g. set_camera("8x6"). Then retrieve the image with get_camera(). This function returns a 3-dimensional array in the form of a "List" object. The only thing you need to know about this object is how to access the pixel values: if you call this returned object image, you access the pixel value in row i, column j and channel k(k=0 for red, 1 for green, 2 for blue) with image[i][j][k].

Copy and run the following code, and check that the 3 values displayed correspond to the 3 red/green/blue values in the pixel software in the 5th row from the top (index 4 when starting from zero) and the4th column from the left (index 3).

from alphai import *

from time import sleep

set_camera("8x6") # set the camera to the correct resolution

sleep(1) # waits 1s for software to activate camera

while True:
image = get_camera() # retrieves camera image

    line = image[4]

    pixel = line[3]
print('red', pixel[0], 'green', pixel[1], 'blue', pixel[2])

First autonomous move with the camera

We want the robot to run laps around the circuit autonomously. If you're using an arena supplied with AlphAI robots, the floor is white, the outer enclosure is red, and the central island is black. We'll assume this is the case, and that you want the robot to circulate by turning clockwise. 

Start by writing a camera_race() function to make decisions repeatedly, as follows (based solely on the color of a single pixel in the lower part of the image):

Si image[4][3][0] < 100 (canal rouge sombre 🡪 le pixel est noir), pivoter à gauche à vitesse 25 pendant 0.5 seconde.

Sinon, si image[4][3][1] < 100 (canal rouge lumineux et canal vert sombre 🡪 le pixel est rouge), pivoter à droite à vitesse 25 pendant 0.5 seconde.

Otherwise (bright red and green channels 🡪 pixel is white), go straight ahead at speed 40 for 0.5 seconds.

Test this program on the track.

As a reminder, the if, else if, else structure is of the following form in Python:

if condition_1:

action_1()

elif condition_2:

action_2()

else:

action_3()

Counting pixels of different colors

You've probably found that making decisions based on a single pixel isn't always the best thing. For example, it may happen that the pixel in the 5th row /4th column is white, so the robot decides to move forward, whereas there's a wall on its side and it should turn instead.

To improve the program, we'll consider all the pixels in the camera image. First, we'll count how many pixels are black, red and white. Then the decision will be made as follows: if the majority of pixels are red, turn right; if the majority of pixels are dark, turn left; and if not, go straight ahead.

To count the number of pixels of a given color, perform a series of for loops for each image component: rows and columns, and then count the color of each pixel using its red, green and blue values. You can use the thresholds you found earlier to determine the pixel's color. You can start with the following code or find your own way - there are many! 

def count_pixel_colors(image: list):

# create dict here

number_pxl_black = 0

red_pxl_number = 0

number_pxl_white = 0

for i in range(len(image)):

line = image[i] 

for j in range(len(line)):

pixel = line[j]

red_channel = pixel[0]

canal_vert = pixel[1]

canal_bleu = pixel[2]

if ...

number_pxl_black +=1

...

else:

...

return {"noir": nombre_pxl_noir, "rouge": nombre_pxl_rouge, "blanc": nombre_pxl_blanc}

Tip Python syntax for for loops, instead of using indices i and j to access the elements of an array, you can change syntax and simply write :

for ligne in image:
for pixel in ligne:
red = pixel[0]
green = pixel[1]
blue = pixel[2]
...

Autonomous robot race and further improvements

Now you can start organizing races between your robots. 

These will be spiced up even further if you continue to improve your program by modifying, for example: movement speeds, color thresholds, additional actions (in addition to the turn by pivoting on the spot, a turn by advancing forward), and so on.

Review and feedback

In programming, the list of accessible program functions is called an API, for Application Programming Interface. It is used by programmers to find out how to interact with the program. You'll find the API for the alphai python module here: https: //drive.google.com/file/d/1C4ovPW_eH5KFz5Y9JvSrzLhtmdOpcp6-/view

TP download (teacher and student)

alphai-api library documentation

Related courses

Materials required:

  • 1 robot minimum or software simulation
  • 1 computer/robot
  • Racing arena

Duration: 1 to 2 hours

Age: over 15

Software configuration :

  • example configuration: depends on the code situation

The advantages of this activity :

  • Can be performed with the simulator

Advanced KNN algorithm
Advanced KNN algorithm

Materials required:

  • 1 robot minimum or software simulation
  • 1 computer/robot
  • Small arena minimum

Software configuration :

  • example configuration: depends on the code situation

Duration: 2 hours

Age: 16 and over

The advantages of this activity :

  • Can be performed with the simulator

Advanced KNN algorithm

A fun activity for a class with several robots: students train the robots to drive on a circuit, followed by a race. Through manipulation, students learn the principle of supervised learning and the importance of quality training data.

Video content

Introduction

Machine learning and supervised learning

Machine Learning is a branch of artificial intelligence whose aim is to enable computers to learn. A computer isn't intelligent; it simply performs tasks. In the form of programs, it is told what to do and how to do it. This is called programming.

Machine Learning deals with complex subjects where traditional programming finds its limits. Building a program that drives a car would be very complex, if not impossible. Machine Learning deals with this problem in a different way. Instead of describing what to do, the program will learn by itself how to drive by "observing" experiments.

Machine Learning: Enabling a program to learn tasks that have not been programmed.

Based on the experimental data that the learning algorithm takes as input, it will deduce an operating hypothesis on its own. It will use this hypothesis for new cases, and refine its experience over time.

There are three types of Machine Learning:

  • Supervised learning
  • Unsupervised learning
  • Reinforcement Learning

Supervised learning is the most common type. It involves providing learning algorithms with a set of training data (Training Set) in the form of pairs (X, Y), with X the predictive variables (or input data), and Y the result of the observation (or decision). Based on the Training Set, the algorithm will find a mathematical function to transform (at best) X into Y. In other words, the algorithm will find a function F such that Y≈F(X) .

So, in situation X, it will know what decision Y should make.

Study situation and AlphAI robot training set

We now need to specify the X situations and Y decisions expected. 

The proposed case study is to move the robot in a red arena. The aim is for the robot to move on its own without ever touching the walls.

To do this, the robot can make the following decisions:

  • Turn left 
  • Go straight ahead 
  • Turn right 

In order to make a decision, you need feedback in the form of data or a training set.

This is given by the sensors. The choice made here is to use the camera. From the camera's image area, two zones are extracted which will be called super pixels (see opposite). The amount of red in each super-pixel increases as the robot approaches the walls, due to the contrast between the white track and the red walls.

Activity 1. Indicate in the table below the result expected as a decision based on what is located in the superpixels.

The simplified cases described above occur very rarely. To be able to make a decision in all possible cases, we need to know the numerical value of the red level. 

The camera image is 48*64 pixels in size. The position and geometry of the super-pixels is defined by the following figure:

Activity 2. Open the file get_values.py. Enter the path of the image forward_0.jpg and execute the code below to display the image in python.

from PIL import Image

import numpy as np

import matplotlib.pyplot as plt

def read_image(name):

    return np.array(Image.open(name, "r"))

img1=read_image("forward_0.jpg") #indicate image path

plt.imshow(img1)

plt.show()

You should obtain an image of the shape below, 48 pixels by 64 pixels in size, coded with the three RGB (Red Green Blue) colors.

"img1" is an array of pixels of size 48*64*3

The pixel array contains the 3 color levels Red Green Blue, coded between 0 and 255.

From this image, we'll need to extract the two super-pixels defined above and determine a method for obtaining the red level for each.

We will compare different techniques to obtain the best contrast between the red and white of each super-pixel:

  • the average gray level of each super-pixel
  • the average red level of each super-pixel
  • the average green level of each super-pixel

First, the image is transformed to grayscale using the rgb2gray function as follows:

def rgb2gray(rgb):

    return np.dot(rgb[...,:3], [0.299, 0.587, 0.144])

img2=rgb2gray(img1)

plt.imshow(img2, cmap="gray")

plt.show()

"img2" corresponds to the grayscale image. There is only one numerical value between 0 and 255 for each pixel. 0 corresponds to a white pixel and 255 to a black pixel. Super pixels are in the "lower" part of the image.

Activity 3. Write an average(img,x,y,height,width) function that takes as arguments an array of pixels "img" at one color level, the "x" and "y" coordinates of the top-left pixel of a super-pixel, the " height " and " width " of a super-pixel and returns the average color level of the super-pixel. 

It is thus possible to retrieve two values with the two super-pixels defined above, using the code :

def get_two_values(img, x1=10, y1=28, x2=42, y2=28, height=16, width=13):

    value1 = average(img, x1, y1, height, width)

    value2 = average(img, x2, y2, height, width)

    return np.array((value1, value2))

The color level of the left super-pixel is value1, the color level of the right super-pixel is value2. It is thus possible to define a point with coordinates (value1, value2)

Activity 4. Execute the code to retrieve the value1 and value2 values from the grayscale image obtained previously.

The choice made in AlphAI software is to use the python mean function, which will calculate the mean value of the table.

Activity 5. Apply the AlphAI software method and the greyscale method and complete with the values value1 and value2 in both cases.

Mean function

Grey Level

Forward_0

Forwad_1

Left_0

Left_1

Right_0

Right_1

Right_2

Test_0

Test_1

Activity 6. Place the points on the graph and identify the zones corresponding to the different decisions (turn left, go straight ahead, turn right). Conclude which method you think is the most appropriate for distinguishing the different decisions.

Right super-pixel intensity

Left super-pixel intensity

At this stage, it would be possible to control the robot using conditional actions based on these super-pixel values. In what follows, we'll take a different approach. We're going to use a method known as theK-nearest neighbor algorithm.

The k-nearest neighbor algorithm, KNN

We're going to take a closer look at a well-known machine learning algorithm: the K Nearest Neighbours algorithm. This algorithm has the advantage of being very simple, and therefore provides a good basis for understanding supervised learning.

The idea is to use a large amount of data to "teach the machine" to solve a certain type of problem. The algorithm is particularly intuitive when the data is in the form of points in a 2-dimensional space, which can then be displayed on screen. So we're going to choose a configuration with just 2 sensor inputs, i.e. 2 "super-pixels" from the camera, to enable the robot to spot the walls and move around the arena without blocking. Initially, it will be up to us to tell the robot the associated action for each new piece of data (2 "super-pixels"), but then it will be able to move around on its own by choosing the majority action taken by the K nearest neighbors from the data entered during the training phase.

This supervised learning algorithm classifies data according to their proximity to the existing training data. The new data considers k neighbors, the k closest, to choose which classification to apply. With discrete data, such as points in a plane or in space, the nearest neighbors are selected using Euclidean distance, but other methods can be used in other situations, such as Manhattan distance if the data are placed on a grid or chessboard. The interest of this algorithm lies in the choice of k: too small and the algorithm becomes too sensitive to errors or missing data, too large and it considers data that should not be considered.

The operation of k-NN can be simplified by writing it in the following pseudo-code:

Start Algorithm

Input data :

  • a data set D, corresponding to the training set created
  • a function for calculating the distance between two points with coordinates [x1,y1] and [x2,y2]. d=x2-x12+y2-y12
  • An integer k, representing the number of neighbors to be taken into account

For a new observation X whose decision Y we want to predict Do :

  1. Calculate all distances between this observation X and the other observations in the dataset D
  2. Select the K observations of dataset D closest to X using the distance calculation function d
  3. Take the Y values of the k observations selected. Perform a regression and calculate the mean (or median) of the selected Y values. 
  4. Return the value calculated in step 3 as the value predicted by K-NN for observation X.

End Algorithm

So you need to be able to calculate the distance between two points. In a two-dimensional graph, as in our example, this simply corresponds to the norm of the vector between the two points.

Activity 1. Write the function distance(point1, point2) which takes two points as arguments (point1=[x1,y1], point2=[x2,y2]) and returns the distance between these two points.

Activity 2. Complete the table below by determining the distance between the super-pixels of the previous images (forward_0.jpg, forward_1.jpg,...) and the two test images (test_0.jpg and test_1.jpg).

Activity 3. Apply steps 3 and 4 of the K-NN algorithm, taking K=1,2,3 and 4, and deduce the decision to be made (go straight, turn left, turn right).

Robot drive

Preparing the working environment

  • In the Parameters - > Load example configurations menu, select the "Supervised learning - KNN Camera" example configuration. 
An image containing text, automatically generated clockDescription

Caution: For this scenario, to obtain the best possible contrast, place a white surface on the floor, and make sure you have uniform lighting across the surface of the arena.

Training phase

Activity 1. Follow the protocol to complete the training phase

You are now connected to the robot, and your screen should look like the image below. Its battery level should be displayed in the bottom right-hand corner (check that the robot is fully charged).

  • As long as the robot has room to move, press go straight ahead. 
  • If the robot approaches a wall, press turn on the spot to the left or right. 

Each time an instruction is sent to the robot, a new point is added to the graph. The abscissa of this point corresponds to the value of the super-pixel on the left, and its ordinate corresponds to the value of the super-pixel on the right. The color of each point corresponds to the action chosen: yellow for going straight ahead, green for turning right and red for turning left. These points are the training data. This training phase is essential if the AI is to learn correctly. If the training data contains too many errors or approximations, the AI's behavior may not be satisfactory. 

Please note:

Pixels become darker as the robot approaches walls. Normally, if the left pixel is the darkest, turn right, and if the right pixel is the darkest, turn left. Once you've added a few points to the graphic, you can activate the background color in the visualization settings tab. This option colors each pixel of the graph with the color of the nearest data point.

When you have three clear areas on the graph, stop the training phase and reactivate the autonomy to move on to the test phase. Don't hesitate to move the robot by hand if an area of the graph contains too few dots.

Tests

If the robot is well trained, it will be able to avoid the edges on its own. If, on the other hand, the robot is poorly trained, or the arena's brightness is uneven, this will produce noise in the regions created, and the robot will perform more inappropriate actions.

Please note:

To obtain the best robot behavior, you need to test several values of k. To change this value, go to the "AI" tab and change the value of the "number of neighbors" parameter.

A good k value reduces the effect of noise and enables the robot to better manage unexplored regions.

Once the robot is well trained and the tests are running smoothly, you can move on to the activities.

Activity 1. Compare the robot's behavior with k=1, k=3, k=10 and k=30. Then, based on what you see, try to determine the value of k that minimizes the effect of errors and gives the best robot behavior, i.e. the greatest distance covered without hitting a wall. The right value will depend on the number of data points, and the number of errors in that data.

Activity 2. Now that you've understood the algorithm, try to train the robot with as little data as possible to enable it to turn without banging into walls. 

Start by making a theoretical version by drawing the areas you'd like to obtain on your graph. Which points need to be placed to achieve this? Test these points with the robot after entering them into the software. Was your theoretical model applicable in reality, or did you have to make any modifications? What are the limitations of this method for a robot like this?

Tip: You can move the robot by hand to select the points you want to teach it.

Note: We managed to teach the robot to move around the arena without hitting the walls with just 3 points.

To find out more :

Activity 3. If you have time left and want to experiment, switch algorithms and see how the robot behaves differently from KNN. What other algorithm would you suggest for faster learning? And what other algorithm do you think would enable learning of more complex tasks, such as kicking a green ball or recognizing commands communicated with hand signals?

Program the K-nearest neighbor algorithm

1. Stop the robot and reactivate the "Stand-alone" button.

An image containing text Description generated automatically

2. In the AI tab, select Algorithm: student code , this will open a new window asking you to name the file. 

3. After giving it a name, the file appears in Windows Explorer: open it in your favorite code editor (Spyder, for example).

This code presents 3 existing functions: init, learn and take_decision. These functions will be called by the main software. Only the take_decision function is important for this tutorial.

4. Note that when you disconnect, a simulated mini-robot appears in the bottom right-hand corner. If you wish, you can do the questions below with this mini-robot and return to the real robot at the end of the test; but you can also do the whole test while connected to the real robot: as you prefer!

PROGRAM THE ROBOT DIRECTLY

Before programming an artificial intelligence, let's start by understanding the principle of the take_decision function. You'll be able to modify this function to change the robot's behavior: after each modification, save your code and click on the "Reset AI" button. This step must be repeated for each code modification: save, then reload the code.

The function has the following prototype:

take_decisionsensors:listint

The sensors input is the state of the robot's sensors, i.e. in our case a list of two values sensors[0] and sensors[1], which are the intensity of what the robot sees to its left and right. Its output is the number of the chosen action.

  1. Add the print(sensors) instruction inside the function. Save, click "Reset AI" in the software, and start the robot. The sensors value is now displayed in the console (click on the icon in the taskbar to display the console). What is the approximate sensors value when the robot is facing a wall? when it's not facing a wall? when there's a wall to its left or right?

  1. For now, the function returns 0. What value must be returned for the robot to go straight ahead? (Try it out)

  1. Use the variable x to program consistent robot behavior: "If there's no wall, I go straight; if there's a wall, I turn."

ALGORITHM PROGRAMMING

Distance calculation

If you haven't already done so in the previous activity, program a new distance function that takes as arguments two points a and b, which are arrays of two elements each containing their coordinates, and returns the Euclidean distance of these two points. The prototype of the function is as follows:

distancea:list, b:listfloat

With a=x1, y1 and b=x2, y2

As a reminder, the Euclidean distance between these two points is: d=x2-x12+y2-y12.

The square root can be used in Python by importing the math (or numpy) library at the top of the :

import math

and is written as follows :

y = math.sqrt(x)

The square operator can be made as follows:

y = x**2

  1. Program the new distance function. Then, to test it, write at the bottom of the :

# compute distance

a = [0, 0]
b = [1, 2]
print("distance", distance(a, b))

Save, load the code with "Reset AI" and note the result displayed in the console below:

Calculating all distances

Now that you have a method for calculating a distance, write a new function all_distances that calculates all the distances from a point to the variable train_sensors, which are the drive input data. This function will take as argument a new point x which is a list of two elements as before, and return an array containing all these distances. Its prototype is :

all_distances(a:list[float], train_sensors:list[list[float]])→list[float]

With a=x0, y0 and train_sensors=x1, y1, x2, y2, ..., xn, yn The train_sensors array being of length n.

  1. Program all_distances, then test with the following code at the bottom of the file:

# compute all distances

a = [0.4, 0.6]

train_sensors = [[0, 0], [0, 1], [1, 0]]

distance_list = all_distances(a, train_sensors)

print('distances to data', distance_list)

Reload the code and copy your result:

Find the smallest element in an array

Create a function called find_minimum, taking an array as its only argument and returning the index of the first smallest element. Its prototype is :

find_minimum(dlist:listfloat)→int

  1. Program and test find_minimum with the following code:

# minimum in a list

idx_min = find_minimum(distance_list)

print('index of minimum', idx_min)

Note the result:

The nearest neighbor

Now that we have all the functions we need, we can create the nearest_neighbor_decision function, which takes the drive data and the current camera input as arguments, and returns the command to be sent to the robot. Its prototype is :

nearest_neighbor_decision(train_sensors:list[listfloat],train_decisions:list[int],a:list[float])→int

As before, a=x0, y0 and train_sensors=x1, y1, x2, y2, ..., xn, yn and train_decisions = d1,...,dn where each di is the decision made for point xi, yi in the train_sensors array

To realize the function, calculate the distances, find the shortest and return the associated command using train_decisions.

  1. Program and test nearest_neighbors_decision with the following code:

# KNN

a = [0.4, 0.6]

train_sensors = [[0, 0], [0, 1], [1, 0]]

train_decisions = [1, 2, 0]

decision = nearest_neighbor_decision(train_sensors, train_decisions, a)

print('KNN', decision)

Copy the result:

USING YOUR ALGORITHM WITH THE ROBOT 

Congratulations, you've programmed the K-nearest neighbor algorithm yourself in the case of K=1. Now you just need to use it in the program to train the robot.

To do this, copy the lines below to program the take_decision function to make the right decisions, but also learn to remember the train_sensors and train_decisions training data that will be created as you go along in the main program:

train_sensors = train_decisions = None

def learn(X_train, y_train):
global train_sensors, train_decisions
train_sensors, train_decisions = X_train, y_train
loss = 0
return loss

def take_decision(sensors):
if train_sensors is None:
return 0
return nearest_neigbor_decision(train_sensors, train_decisions, sensors)

 And now you can train your robot!

  1. Reload your code
An image containing text Description generated automatically
  1. Deactivate the robot's autonomy by clicking on the icon
An image containing text Description generated automatically
An image containing text Description generated automatically
  1. ,
  2. Steer the robot by clicking on the arrows on the right of the screen. Turn when the robot is close to the walls, otherwise go straight ahead. 

The train_sensors and train_decisions tables are filled in automatically by the software each time you click an arrow.

  1. After a short training period, reactivate autonomy
An image containing text Description generated automatically
An image containing text Description generated automatically
  1. The robot navigates the arena alone. Does it avoid the walls on its own?

Further information

K nearest neighbors

The algorithm you've written uses the nearest neighbor to make its decision. Modify your code so that it takes into account the majority of decisions made between a number k>1, k∈N. The difficulty lies in modifying the function that finds the minimum. It must now find k and not just 1.

InTroduction to neural networks

Load the "Supervised learning, navigation with camera" example configurations and run a training session again. What are the differences between the two algorithms? 

Review and feedback

In programming, the list of accessible program functions is called an API, for Application Programming Interface. It is used by programmers to find out how to interact with the program. You'll find the API for the alphai python module here: https: //drive.google.com/file/d/1C4ovPW_eH5KFz5Y9JvSrzLhtmdOpcp6-/view

Materials required:

  • 1 robot minimum or software simulation
  • 1 computer/robot
  • Small arena minimum

Duration: 2 hours

Age: 16 and over

Software configuration :

  • example configuration: depends on the code situation

The advantages of this activity :

  • Can be performed with the simulator

Download
Related courses
Activity: Q-learning or programming with Pytorch
Activity: Q-learning or programming with Pytorch

Materials required:

  • 1 robot minimum or software simulation
  • 1 computer/robot
  • Small arena minimum

Software configuration :

  • example configuration: manual editing: "blocked vs. movement".

Duration: 2 to 3 hours

Age: over 15

The advantages of this activity : 

  • Can be performed (in part) with the simulator.

Program the reward function that the robot receives to perform an original learning task: follow a line with the camera, ... or something else!

Video content

Introduction

Discover AlphAI software

AlphAI software gives you a visual (re)discovery of Machine Learning in general, and supervised and reinforcement learning algorithms in particular: neural networks, KNN, Q-learning, DQN, etc.

  • Launch the software by clicking on the "AlphAI" icon on the desktop or from the start menu.

If the software asks which robot to choose, select "AlphAI". Next, we'll start by using the simulated robot. Click on the "Simulation" button.

PRINCIPLE OF SUPERVISED LEARNING IN THE SOFTWARE

Here are the main elements of the software:

  • Press
An automatically generated image containing textDescription
  • you see the network making a decision, linked to the random initialization of connections in the network
  • Press
An automatically generated image containing textDescription
  • connections have been reset and decisions are no longer the same
  • Switch to advanced mode, then in the Visualization tab activate the display of connection values to see the details of the calculations performed by the neural network.

An automatically generated image containing textDescription

We are now going to train the neural network by building and feeding it a dataset of 2 data:

  • When the robot is not blocked (green wheels)
  • press the "straight ahead" arrow
  • (you can also use the up arrow on the keyboard). 
  • And when it's blocked (red wheels)
  • press a "back" arrow
  • (or back arrow on keyboard).
  • You have now created two data sets
  • which have enabled the learning algorithm to modify the connections within the neural network, so that now, when switched to autonomous mode, it chooses to go straight ahead when the robot is not blocked, and to turn around otherwise.

Continue exploring the software:

  • In the sensor tab, change the neural network inputs
  • In the action tab, change the possible actions
  • (Ignore for the moment the Reward tab, which applies only to Reinforcement Learning)
  • In the AI tab, change the intermediate neuron layers. Check that the AI doesn't learn when the learning speed is set to zero, and that it diverges when the learning speed is set too high.
  • In the Visualization tab, test the display parameters of the "Neural network" section. Notice how
An automatically generated image containing textDescription
  • will allow you to visualize the connections that increase or decrease during learning.

LEARNING A CIRCUIT

Activate a camera mode, choose the actions you want, try to set the AI parameters just right, and have the simulated robot learn to do laps!

Note also that you can change the speed of the robot at the bottom of the screen.

 

CONNECTION TO THE REAL ROBOT

Once you think you've set all the parameters correctly, you can connect the real robot!

  • Disconnect from the simulated robot (
  • bottom right)
An image containing interior, redAutomatically generated description
  • Set up a racing arena.
  • Switch on the robot (the switch is on the underside). It makes a small movement, then flashes white when ready to receive a connection. 
  • Note the robot number on the bottom plate.
  • Choose whether you want to connect via Wi-Fi or Bluetooth (Wi-Fi will be necessary the first time to update the robots with the latest software version, but Bluetooth may be preferable for a more stable connection afterwards).

Wi-Fi connection

  • Connect the computer to the robot's Wi-Fi: look for the Wi-Fi network starting with ALPHAI and ending with your robot's number; the password is identical to the wifi name.
  • Click on the robot icon that appears in the software, with a small wifi logo.

Bluetooth connection

  • Go to Windows Bluetooth settings and pair your robot ("add a new device").
  • Click on the robot icon that appears in the software, with a small Bluetooth logo.

ROBOT RACE

Now you can train your robot to run laps around the circuit, and organize a race against one or two colleagues in the arena!

NEURAL NETWORK DETAILS: INTRUDER DETECTION

In the Settings > Load sample configurations menu, load the demo configuration 

An automatically generated image containing whiteboardDescription

You're looking at a very small neural network. Try to teach it to sound the robot's alarm when it's 30cm away from an object, but to stop the alarm if the object is less than 25cm away, or more than 35cm away:

You'll see that this is impossible with the initial network, which is too simple. You'll have to add a bias to the neurons, and at least one layer of 2 intermediate neurons.

Programming the neural network

Work with the simulated robot at first, then switch back to the real thing at the end. Switch off the robot to save its batteries.

In the AI tab, select Algorithm: "Student code", then answer "New" to the question and choose the name of the file to save your code in.

You're going to edit the code of 3 functions "init", "learn" and "take_decision" to code your own neural network.

Understanding the 3 functions

  1. Add prints to each of the 3 functions and note that 
  • init is called when "Reset AI" is pressed
  • learn is called up as often as possible (but only if the "Learn" button is activated and there is learning data in the experience memory)
  • take_decision is called each time the program wants to know a decision (it is in fact called 2 times per step: 1 time to display the values on the screen, 1 time to make the robot take the decision
  1. Modify the value returned by the take_decision function: this determines the action chosen by the robot in autonomous mode.

Coding a first network "outside" the software

Here's a code that builds a neural network with 1 input, 2 outputs (corresponding to 2 categories), and an intermediate layer of 100 neurons.

He trains it on a set of 3 data (x=-2 🡪 category 1), (x=0 🡪 category 0), (x=2 🡪 category 1) and checks that the error is small at the end of the training.

    import torch as th

    from torch import nn

    import numpy as np

    ninput = 1

    noutput = 2

    # Example data set

    data = [[-2], [0], [2]]

    classes = [1, 0, 1]

    data = th.Tensor(data)

    classes = th.LongTensor(classes)

    # Init neural network

    network = nn.Sequential(

            nn.Linear(ninput, 100),

            nn.LeakyReLU(),

            nn.Linear(100, noutput),

    )    

    print("first layer: weights = ", network[0].weight)

    print("first layer: bias = ", network[0].bias)

    # Test network output before learning

    sensors = th.Tensor([[0], [1], [2]])

    output = network(sensors)

    print(output)

    # Init loss function

    lossfn = nn.CrossEntropyLoss()

    pred = network(data)

    print("loss:", lossfn(pred, classes))

    # Init optimizer

    optimizer = th.optim.SGD(network.parameters(), lr=1e-1)

    # Learning

    nrepeat = 2000

    for i in range(nrepeat):

        optimizer.zero_grad()

        pred = network(data)

        loss = lossfn(pred, classes)

        print("loss:", lossfn(pred, classes))

        loss.backward() # this computes the gradient, i.e. the derivatives

        optimizer.step()

    # Test network output after learning

    pred = network(data)

    print("loss after", nrepeat, "learning steps:", lossfn(pred, classes))

    print("first layer: weights = ", network[0].weight)

    print("first layer: bias = ", network[0].bias)

  1. Copy the following code at the end of the Python file and test it by pressing the "Reset AI" button (you can see the print displays in the console).
  2. Now you will fill in the 3 functions init, learn and take_decision :

At the top of the file, define the following variables, which will be accessible in the various functions

network = lossfn = optimizer = None

Within each of the 3 functions, make these variables accessible with the line :

global network, lossfn, optimizer

Move the "network initialization" part to the init function

Move the "learning" part into the learn function (but remove the for loop: put in only one learning step, knowing that the function will be called a large number of times).

Write the take_decision function, which must return the category number corresponding to the "sensors" input, i.e. 0 or 1.

  1. Test your program in the software, with the simulated robot, and then with the real robot!

‍Assessmentand feedback

We hope this session has helped you rediscover neural networks in a concrete way!

In programming, the list of accessible program functions is called an API, for Application Programming Interface. It is used by programmers to find out how to interact with the program. You'll find the API for the alphai python module here: https: //drive.google.com/file/d/1C4ovPW_eH5KFz5Y9JvSrzLhtmdOpcp6-/view

Materials required:

  • 1 robot minimum or software simulation
  • 1 computer/robot
  • Small arena minimum

Duration: 2 to 3 hours

Age: over 15

Software configuration :

  • example configuration: manual editing: "blocked vs. movement".

The advantages of this activity : 

  • Can be performed (in part) with the simulator.

Activity: Introduction to AI - 4 levels of autonomy
Activity: Introduction to AI - 4 levels of autonomy

Duration: 40 to 60 minutes

Age: 8+ years

Introduction to AI - 4 levels of autonomy

Video content

Introduction

Duration: 40 to 60 minutes

Age: 8+ years

Activity: AI ethics
Activity: AI ethics

Suggest an activity!
Suggest an activity!

Suggest an activity!


AlphAI software lets you create completely customized configurations to suit your needs and objectives.

Choose a level of autonomy, an algorithm, the sensors and actions you want to use, ... and invent your own activity!
You can also start from an example configuration and then customize it.

Once you're happy with the configuration you've chosen, you can save it on your computer for future use!

To understand how to configure the software, follow this link:
link to Software resources > Software overview > Window panel

You have invented an interesting, fun and educational activity?

We'd love to try it out, and why not offer it to all software users!

Please contact us via our contact form with the following information:

  • Your first and last name
  • Your function

  • Activity title
  • Activity objective
  • Minimum age for participation
  • Estimated time required

  • Arena size and layout
  • Type of robot used
  • Number of robots used

  • Activity description
  • Parameter file (.json)

Download
Related courses
Curriculum proposals
Curriculum proposals

Curriculum proposals

Elementary

Discover AI" course

Objectives: Familiarize yourself with AI and learning
Time required: approx. 4h

Activities :

  1. Robot racing - introduction to supervised learning
  2. Line monitoring (supervised learning only)
  3. Robot tracker
  4. Reinforcement learning - Obstacle avoidance

College

Complete introduction to AI" course

Objectives: Understand the basic workings of AI and learning
Time required: approx. 6h

Activities :

  1. Introduction to AI
  2. Robot racing - introduction to supervised learning
  3. Line tracking (manual editing + supervised learning)
  4. Robot tracker
  5. Reinforcement learning - Obstacle avoidance
  6. AI ethics

Rapid introduction to AI" course

Objectives: Understand the basic workings of AI and learning
Time required: approx. 3h

Activities :

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. Robot tracker
  4. Reinforcement learning - Obstacle avoidance

Lycée

Introduction to AI" curriculum

Objectives: Understand the basic workings of AI and learning
Time required: approx. 5h

Activities :

  1. Introduction to AI
  2. Robot racing - introduction to supervised learning
  3. Line tracking (manual editing + supervised learning)
  4. Reinforcement learning - Obstacle avoidance
  5. AI ethics

AI & Mathematics" curriculum

Aims: Understand how AI and learning work, and that everything is governed by math!
Time needed: approx. 8 hours

Activities :

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. KNN algorithm
  4. Intruder detection (neural network mathematics)
  5. Reinforcement learning - Obstacle avoidance
  6. Reinforcement learning - Blocked VS Motion

Simple "AI & Python Programming" course

Aims: Understand how AI and learning work, and program algorithms in Python
Time needed: approx. 9h

Activities :

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. AlphAI remote control (python programming)
  4. KNN algorithm
  5. KNN advanced algorithm (programming)
  6. Reinforcement learning - Obstacle avoidance
  7. Reinforcement learning - Blocked VS Motion

Advanced "AI & Python Programming" course

Aims: Understand how AI and learning work, and program algorithms in Python
Time needed: approx. 14h

Activities :

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. AlphAI remote control (python programming)
  4. Camera programming
  5. KNN algorithm
  6. KNN advanced algorithm (programming)
  7. Intruder detection (neural network mathematics)
  8. Reinforcement learning - Obstacle avoidance
  9. Reinforcement learning - Blocked VS Motion
  10. Reinforcement learning - Q-learning (programming)

Python programming" course

Objectives: Know how to program simple algorithms in Python
Time required: approx. 4h

Activities : 

  1. AlphAI remote control (python programming)
  2. Camera programming

Superior

AI & Python Programming" course

Aims: Understand how AI and learning work, and program algorithms in Python
Time required: approx. 16h

Activities : 

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. AlphAI remote control (python programming)
  4. Camera programming
  5. KNN algorithm
  6. KNN advanced algorithm (programming)
  7. Intruder detection (neural network mathematics)
  8. Neural network programming with Scikit-learn
  9. Reinforcement learning - Obstacle avoidance
  10. Reinforcement learning - Blocked VS Motion
  11. Reinforcement learning - Q-learning (programming)

This course was given by Learning robots at Paris Saclay. You can find it here.

IA" curriculum

Objectives: Understand how AI and learning work
Time required: approx. 8 hours

Activities : 

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. KNN algorithm
  4. Intruder detection (neural network mathematics)
  5. Reinforcement learning - Obstacle avoidance
  6. Reinforcement learning - Blocked VS Motion

Introduction to AI" course

Objectives: Understand the basics of AI and learning
Time required: approx. 4h

Activities : 

  1. Robot racing - introduction to supervised learning
  2. Line tracking (manual editing + supervised learning)
  3. Reinforcement learning - Obstacle avoidance
  4. Reinforcement learning - Blocked VS Motion

Python programming" course

Objectives: Know how to program simple algorithms in Python
Time required: approx. 4h

Activities : 

  1. AlphAI remote control (python programming)
  2. Camera programming

Download
Related courses
The robot: Introduction
The robot: Introduction

Introduction

Thymio is an educational robot designed by researchers at EPFL, in collaboration with ECAL, and is very popular in colleges for teaching programming with Scratch.

Thanks to our AlphAI software, teachers can now help their students discover and understand AI.

In our activities, you will have the opportunity to train AI models in supervised or reinforcement learning, in order to carry out more complex tasks with the Thymio robot.

Composition

Sensors

The sensors you can use on the software are :

IR proximity‍

Allows use of the robot's 5 front and 2 rear infrared sensors.some text

  • The first button lets you select which sensors you wish to activate: all, none, front sensors, rear sensors, central sensor, side sensors.
  • The binary mode option allows you to obtain integer values 0 or 1 instead of decimal values between 0 and 1.
  • When binary mode is active, the IR threshold parameter is used to set the switching threshold between binary values 0 and 1. For example, when the threshold is set to 0.5 (default value), all values between 0.5 and 1 are rounded to 1, and all values between 0 and 0.5 are rounded to 0.


Line tracking IR‍

  • allows you to use the 2 infrared line-following sensors located under the robot. They communicate a value between 0 and 1 depending on the brightness of the surface. There are two main modes:some text
    • Black detection: value 0 corresponds to white and value 1 corresponds to black. Recommended for tracking a black line on a white background.
    • Reflection detection: value 0 corresponds to black and value 1 corresponds to white

         The binary mode option allows you to obtain only integer values 0 and 1 instead of decimal values between 0 and 1.

  • When binary mode is active, the IR threshold parameter is used to set the switching threshold between binary values 0 and 1. For example, when the threshold is set to 0.5 (default value), all values between 0.5 and 1 are rounded to 1, and all values between 0 and 0.5 are rounded to 0.



accelerometer‍

  • Allows you to use the robot's gyroscope. It communicates a value for each axis: x (behind - in front), y (left - right) and z (down - up). You can select a single axis, or a combination of them.



computer camera‍

  • allows you to use your computer's webcam as a sensor. Several options are available, determining camera resolution and whether or not to use zoom.

The camera image pre-calculation button is used to modify the processed values:

  • when pre-calculation is deactivated, the image defaults to color (RGB system).
  • grayscale mode captures the brightness of each pixel.
  • the color mode in the image detects colors. All white/gray/black pixels will obtain the value 0 and colored pixels the value 1.
  • green channel mode detects only the presence of green (values close to 1) or its absence (values close to 0).
  • red vs. green mode returns a value between -1 and 1 for each pixel, corresponding to the amount of red minus the amount of green.

  • The take photo button lets you take a photo with the webcam and save it on your computer.
  • The mirror effect option reverses or not the image (left-right axial symmetry).
  • The camera index option lets you select which webcam to use when your device has more than one.

The actions

The actions you can use on the software are :

  • Movement:


  • Pivoting :
  • Lighting :

You can also create a custom action by clicking on the button: 

The following window will then appear: 

Name your action and check "robot action" to modify the parameters: the new action is now available.

To save it for future use, click on File > Save > Save configuration.

Operating environment

We recommend that you use Thymio in an AlphAI arena.

MOBSYA also offers robotic tracks for Thymio to move around. However, the absence of walls limits the activities you can carry out.
You can also simply move Thymio on a flat surface.



To carry out all the activities on the software, Thymio will need:

  • A very flat surface, ideally covered with a tarpaulin
  • Walls higher than the robot
  • One or more lines on the ground in a color that contrasts sharply with the tarpaulin (you can use black tape).

 

All activities can be carried out with the simulated robot in Thymio Suite.

Download
Related courses
The robot: Connection
The robot: Connection

Robot connection

Wireless key with Thymio Suite

Getting started with Thymio AI

‍Video- thymio - preparation 1

  1. Open Thymio Suite
  2. Connect the robot to your computer by plugging in the Wireless key (USB Dongle).
  3. Switch on your Thymio robot
    (simply press and hold your finger on the circle in the center of the arrows until the robot makes a sound and turns green. This takes a few seconds.)
    When the robot is connected to the key on the computer, it starts flashing! 
  4. Launch AlphAI software
  5. Select the robot in the software home screen 
  6. The main screen opens, and you can begin your activities!

⚠️ When you first connect to the robot, you will be asked for the software activation key number supplied with the robot.‍

Simulation with Thymio Suite

Video - thymio - preparation 2

  1. Open Thymio Suite
  2. Click on "Launch simulator" in the toolbar. Select the arena of your choice.
  3. Launch AlphAI software
  4. Select the simulated robot that appears on the software home screen

⚠️ Vous devrez idéalement disposer d’un deuxième écran afin de pouvoir avoir les fenêtres du logiciel Thymio Suite et du logiciel AlphAI ouvertes simultanément.

Download
Related courses
The robot: Maintenance
The robot: Maintenance

Robot maintenance

Battery recharge (USB type A)

To recharge Thymio, simply plug it into a computer using the supplied micro-USB cable.

If your Thymio won't turn on even when connected to a computer, connect it to a wall charger.

When Thymio is charging, a red light comes on near the USB port). If it's on, the battery level LEDs will flash.

Recurring problems

A help button on the Thymio suite redirects you to the Thymio help page: FAQ Thymio

Robot update

  1. Download and install the latest version of Thymio Suite.
  2. Connect Thymio to your computer using the USB cable.
  3. Launch Thymio Suite.
  4. Launch VPL or any other programming language.
  5. If an update is available, an update icon appears on the robot. Right-click on the robot you wish to update and select "update firmware", or simply click on the update icon.
  6. Wait for the blue bar to fill up. Once it's full, the update is complete.

Support / warranty

To validate your robot's warranty, you need to register it on the Thymio website. If you have any problems with your robot, please contact the Thymio support center.

Download
Related courses
The robot: Arena and track
The robot: Arena and track

Arena and track

If you own an AlphAI arena, please refer to this page to understand how to assemble it and the different possible layouts: 

link to AlphAI's resources page > Preparing the material > Setting up the arena

Our partner MOBSYA offers a wide range of tracks to roll out on the floor, buy or print at home: https: //www.thymio.org/fr/ressources/ressource-dactivites/

In each of the activities presented on this resource page, we've added a link to download the printable track where possible.

Download
Related courses
Activity: Fearful Thymio
Activity: Fearful Thymio

Notions learned :

  • View sensor activation
  • Familiarize yourself with AI training in software

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Age: 8+ years

Duration: 1h30 (2*45 min)

Example parameters :

  • Thymio the timid
    Possibility of enriching sensors and actions

Fearful Thymio

Recommended for hands-on learning.

Teach your robot to react to specific situations!In this activity, you'll learn how to set up the AlphaAI software and its neural network to operate Thymio in a simple environment.

This activity was designed with our partner MOBYSIA, makers of the Thymio robot.

Objectives

In this activity, we'll teach Thymio to react if something comes too close to him. Specifically, if its front and rear horizontal sensors detect an object, it will try to move away with its wheels. What's more, if he's surrounded on all sides and can't escape, he'll turn on himself.

Equipment set-up

Connect your robot to Thymio suite and then to AlphaAI. Place the robot on a flat surface, ideally with a tarpaulin, in a space of at least 80 cm². Select the parameters for this activity in the AlphaAI software

First phase: observation

Switch on the "stand-alone" button and switch off the "learning" button. Move your hand in front of the front and rear proximity sensors. What can we see? The robot's random behavior is normal: it has not yet learned to react to sensor stimulation.

Second phase: learning

Switch off the "stand-alone" button and switch on the "learning" button.
From now on, our actions will be recorded for Thymio training:

1. Approach Thymio to a receiver there's something in front of:
Place a finger in front of the central front sensor and click on the down arrow action icon.

2. Teach Thymio not to move if there's nothing there:
Ensuring that all Thymio's infrared sensors are at zero, click on the stop icon.

Third phase: autonomy

Now we can test how well Thymio has learned!

Switch on the "stand-alone" button and switch off the "learning" button.

Place your finger in front of its sensors: does Thymio behave as expected?

Fourth phase: more complete learning

Now let's make Thymio's reactions more complex by using all available sensors.

Start by adding new actions: move back right, move back left, turn right, turn left, move forward, and rotate 180°.
⚠️ Adding a new action will delete the robot's experience memory.

Switch off the "stand-alone" button and switch on the "learning" button.

Associate the stimulation of each sensor with a specific action, for example by following the instructions in this table:

Once Thymio has learned all the reactions for each situation, switch on the "autonomous" button and switch off the "learning" button.

Does Thymio behave as expected?

Notions learned :

  • View sensor activation
  • Familiarize yourself with AI training in software

Age: 8+ years

Duration: 1h30 (2*45 min)

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Example parameters :

  • Thymio the timid
    Possibility of enriching sensors and actions
Download
Related courses
Activity: Keeping track
Activity: Keeping track

Equipment:

  • 2 robots
  • 1 computer/robot
  • Downloadable circuit provided in the subject

Settings :

  • example configuration: "supervised learning - line tracking".

Duration: 1 hour

Age: 8+ years

The advantages of this activity :

?

Keeping track

In this activity, we're going to teach Thymio to follow a line drawn on the floor, its aim being to make as many round trips as possible in the allotted time (2 to 3 minutes).

Equipment set-up

Connect your robot to Thymio suite and then to AlphAI.
Place the robot on a flat surface, ideally with a tarpaulin, and add a 60 cm long track. Create the track on a light-colored surface.

A track is also available in A2 format in the appendix on the right-hand side of this page.

○ ligne-noire-2xA3.pdf which can be printed on 2 A3 sheets to be joined together with adhesive tape.

○ ligne-noire-4xA4.pdf which can be printed on 4 A4 sheets and assembled in the same way.


Select the "supervised learning - line tracking" example configuration in the AlphAI‍ software.

Regulations

Several teams of 2 or 3 students compete, each choosing a name for the team and the robot.

A team places its robot at the start of the track. When the timer starts, the robot begins its journey. At the end of the allotted time, the number of outward and return journeys is added up, and the result recorded in a table.

If a participant's hand helps the robot, a 10-second penalty is deducted from the total course time.

For example, a helper will reduce the time from 2 min to 2 min -10 sec = 1 min 50 sec.

If the robot leaves the track without returning on its own, the current outward or return journey is not taken into account. The team may return the robot to the beginning of the section covered, but a 10-second penalty is applied.

If the robot turns around and returns to the track in reverse before reaching one of the ends, let it continue, but the outward or return journey in progress will not be counted.

There may be several rounds.

The winning team is the one whose robot has made the greatest number of round trips over all the rounds.

AlphAI settings

  • Sensors tab

Use the ground IR sensors in value mode, unchecking the "binary_mode" box if you haven't already done so.
Capture ecran - thymio - activites 1

  • Actions tab

The team is free to choose the actions to be used. They can also set the duration, pause and maximum speed parameters as they wish (trial runs are recommended). These 3 parameters can be modified without having to repeat the learning process.

  • AI tab

⚠️Laisser default choices supervised learning and neural network. Do not modify learning speed. Possibly reduce it if the robot often makes mistakes.

Choose the combination 10 20, i.e. 2 layers of neurons, one of 10 and the next of 20.

It's up to you to lead the learning process. Make sure you consider all possible cases - there aren't too many of them. If you wish, you can save your settings in the menu Settings > Save settings ...

Solutions (->Help)

On your marks!

Equipment:

  • 2 robots
  • 1 computer/robot
  • Downloadable circuit provided in the subject

Duration: 1 hour

Age: 8+ years

Settings :

  • example configuration: "supervised learning - line tracking".

The advantages of this activity :

?

Download
Related courses
Activity: Don't just stand there!
Activity: Don't just stand there!

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Small arena with obstacles

Settings :

    • example configuration: supervised learning

Duration: 1 hour

Age: 8+ years

The advantages of this activity :

?

Equipment set-up

Make a 60cm-diameter circle on the tarpaulin with the black tape, doubling the thickness of the circle to 4-5 cm. Place the Thymio robot and 4 or 5 small objects inside the circle. Object characteristics: These objects must be light enough to be moved by Thymio. They can be of any shape, but light in color to reflect the sensors' infrared rays. They should be between 2 and 9 cm wide. Example: cups, Lego elements, small wooden blocks...‍

Objective

No, we're not turning Thymio into a vacuum cleaner! Thymio will simply be in charge of pushing all objects outside the circle, as shown in the figure below:




What Thymio has to do

We're going to teach Thymio what to do using the method we discovered in the previous activity, "Thymio the Fearful", the supervised learning method.Recall that in supervised learning, we looked at the values of his sensors, then told Thymio the action to perform.We had studied only a few important situations. Thanks to the neural network, Thymio had learned what to do in situations it had never encountered before.‍

A first simulation by hand‍

Place a few objects at random inside the black circle, including Thymio. Simulate by hand what the robot has to do to push the objects out of the circle. But be careful, there are a few guidelines to follow. Otherwise our ideas won't be used in the program. Check that the actions you've imagined are actually present in the Actions tab of the Alphai software. The action to be performed will always depend on the sensor values. You'll need to imagine what the sensors are sensing. In particular, for a given sensor state, don't suggest several different actions.
For example, let's say that if the central sensor picks up something, you ask it to move forward: don't later suggest that it turn right if the central sensor picks up something again. Take the robot by hand. The first movement is to move the robot straight ahead for a short distance, 3 or 4 cm. Then push an object out of the circle. You can take the situation described in the previous figure, where Thymio will touch the purple object from the side. Determine the actions to be performed based on the information from the sensors. Once you've analyzed the situation, you can try to reproduce it with Alphai, adding actions if necessary.

‍Gettingorganized

‍Tohelp you remember which action to take, when looking at the status of the sensors, it's handy to use a table. Use the table in Appendix 2 and fill it in as follows: In the first column, indicate what's around or under Thymio. In the sensors columns.

  • if the sensor picks something up, put a cross
  • if he doesn't get anything, put a hyphen
  • if it doesn't matter what it picks up, put a question mark.

In the actions column, enter the correct action. Once you've figured out how to push an object out of the circle, find out how to use the black circle to send Thymio back inside the circle. Then continue the simulation by hand until you've pushed all the objects [1]. Note: to complete the picture, there are several possible solutions [2] and you don't have to use all the lines. Finally, complete the learning process, switch to autonomous mode and watch Thymio push all the objects out of the circle! Final adjustment of actions and possible solutions in appendix 3.

[1] It may be interesting to film the 'cleaning' done by hand with a webcam and view it afterwards so that the group can check whether the robot will really be able to perform all the movements made by hand.

[2] A solution that would consider all possible cases with 7 collectors (5 horizontal and 2 below) would have to study at least 128 different situations!

Reminder to connect Thymio*Appendix and Appendix (solution->Help)

Appendix (solution->Help) 

First tab settings

Sensors tab

Select proximity IR sensors and line-following IR sensors in values.

Actions tab
AI tab

Possible solutions

Only the Actions tab needs to be modified.

10 actions in all.

Caption:

X: something in front

- nothing in sight

Note that the left and right rear sensors are not used at all. To do this, in the Sensors tab, select Proximity IR / sensor selection: front sensors.

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Small arena with obstacles

Duration: 1 hour

Age: 8+ years

Settings :

    • example configuration: supervised learning

The advantages of this activity :

?

Download
Related courses
Activity: The autonomous car
Activity: The autonomous car

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Small arena with obstacles

Settings :

  • example configuration: supervised learning

Duration: 60 to 90 minutes

Age: 8+ years

The advantages of this activity :

?

The autonomous car

Recommended for deepening supervised learning

Teach your robot to perform specific tasks with supervised learning. This last activity brings together everything seen in the last supervised learning activities. It combines obstacle detection, U-turns and line following.

Equipment set-up

An example route is given in Appendix 1. The walls are the size of an A4 sheet folded lengthwise into 4.

‍Walls can be created inexpensively with A4 sheets and a roll of tape.

Long wall: fold an A4 sheet lengthwise 3 times. Flatten it and glue the 2 opposite sides with a piece of adhesive, then give it back its 3D volume (bar shape). The dimensions are 297 x 52 x 52 mm.

If a wall section doesn't stay square, it can be reinforced by sliding another wall in at right angles.

Short wall: Simply cut a long wall when it is flattened.145 x 52 x 52.

‍Theproposed layout uses 9 sheets: long wall and 3 sheets of short wall.

Avoid overly rough or bumpy floors.

The challenge

In this activity, Thymio takes on the role of an autonomous car traveling down a street.

The street is simulated by a series of parallel walls, forming a sinuous path. At the end of the street, a black line is placed perpendicular to the end walls.

The robot has to travel along the street without touching the walls. Once it reaches the end of the street, it turns around and travels in the opposite direction.

Possible enhancements: Pedestrian simulation. An obstacle up to 6 cm wide is placed in the middle of the street to simulate a pedestrian. Thymio must stop in front of it. The pedestrian is removed, Thymio restarts and continues its journey.

You can repeat the rules of the game presented in the activity: "Keeping track". If the latter activity has already been done as a game, the scores from the two activities can be combined.


Add pedestrian with or without pause

  • 1st strategy

If all 3 central sensors pick up, stop. If only the central sensor picks up, stop.
Works well with a pedestrian, but stops in front of a wall.

  • 2nd strategy

If the sensor in the center picks it up, stop.
Works well with a well-placed narrow pedestrian, better with a wall in front, but sometimes wrong.


AlphAI settings

Sensors tab:

Proximity sensors and IR ground sensors will be used.

Actions tab:

The team is free to choose the actions to be used. They can also set the duration, pause and maximum speed parameters as they wish (trial runs are recommended). These 3 parameters can be modified without having to repeat the learning process.

AI tab :

Leave the default choices supervised learning and neural network. Leave learning speed unchanged. Possibly decrease it if the robot often makes mistakes. Choose the 10-20 combination, i.e. 2 layers of neurons, one of 10 and the next of 20. It's up to you to carry out the learning process. Make sure you consider all possible cases, there aren't too many of them. You can save your settings in the menu Settings > Save settings ...

Appendices

Learning
Solutions

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Small arena with obstacles

Duration: 60 to 90 minutes

Age: 8+ years

Settings :

  • example configuration: supervised learning

The advantages of this activity :

?

Download
Related courses
Activity: Reinforcement learning
Activity: Reinforcement learning

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Smallest enclosed arena with obstacles

Settings :

  • example configuration: "obstacle avoidance (reinforcement learning)".

Duration: 1 hour

Age: 8+ years

The advantages of this activity:
?

The Arena

Equipment set-up

Set up an AlphAI rectangular arena with solid walls, or a space bounded by objects heavy enough that Thymio can't move them.

Minimum dimensions: 80cm x 80 cm‍

Reinforcement learning

Thymio mission :

‍Thymiois inside an arena. His goal is to explore this arena without touching the walls. As usual, in the beginning, Thymio doesn't know how to do anything.

We decide to teach it to carry out its mission using a new method called reinforcement learning. This method is also part of the field of artificial intelligence.

Once again, we'll be using a neural network.

In this method, Thymio is not told which of the various possible actions it should perform. It's up to him to choose one. But how does the robot know which action to choose? Through the rewards it is given, or not1.

[1] This evokes the guessing game, "t'es froid, t'es chaud, tu brûles! ..."

AlphAI settings

Thymio connection reminder (top)

‍Inthe parameters menu, select the load example configurations option ...

In the box that appears, double-click on the obstacle avoidance option (reinforcement learning).

Below the network are two black progress bars.

  • The left-hand bar displays rewards or penalties in numerical form. A reward is represented by a positive number, while a negative value corresponds to a penalty.
    Possible values for rewards are already set by Alphai.
  • The right bar shows the level, i.e. the average of previous rewards. It corresponds to Thymio's learning status.

We also leave the learning and exploration buttons activated.

First apprenticeship

Watching Thymio in the arena

Launch autonomous mode. Thymio starts moving. Its first move is chosen at random. Observe its movements and color changes. Click on the autonomous button again after about 20 seconds to stop learning.

‍Question1: 

Make connections between what the robot does and the colors it uses. Note the answer.

When Thymio moves forward in the arena, he's green. When he gets too close or hits a wall, he turns red.

Green means: Thymio receives a reward, his action is in line with his mission.

Red means: Thymio receives a penalty, its action is contrary to its mission. 5 to 10 minutes of learning.

‍Question2: 

Have you noticed any changes in Thymio's behavior? If so, describe it. Write down your answer.

At first, Thymio bumps into the walls quite often and struggles to get away from them. Then he manages to avoid it more and more often.

There are even several stages in the learning process:

At first, Thymio quickly discovered that there was no need to go backwards.

Then he quickly adopted one of two behaviors (students will observe one or the other with their Thymio): either spinning in circles (the most common), or making straight lines and turning around when he hits a wall.

Then he gradually learns to alternate between straight ahead and turning, choosing straight ahead more and more frequently when there's no obstacle ahead, turning left if there's a wall to the right, and turning right if there's a wall to the left.

Exploration: click on the exploration button to deactivate it.

‍Question3:

‍Doyou notice any changes in Thymio's behavior? If so, describe it. Note the answer.

Thymio makes fewer mistakes, and no longer interrupts its straight lines with unexpected movements.

Reset the AI with the Reset AI button. This makes Thymio "forget" everything it has learned, and start learning again from scratch (keep autonomous enabled, but exploration disabled).

‍Question4: 

Do you notice any differences between this new apprenticeship and the previous one? If so, please describe them.

If you don't notice any difference, start a new training session again by pressing Reset AI. Note the response.

Thymio remains stuck in the "going round in circles" behavior without discovering the straight line (this is not systematic and it sometimes learns correctly even when exploration is deactivated).

‍Conclusion

‍Explorationis essential to learning.

the AI occasionally tries actions other than the one it "thinks" is best (when this happens, the action icon on the right of the screen lights up blue rather than black). This avoids getting stuck in mediocre behavior.

On the other hand, once learning is complete, exploration is no longer useful, so it's a good idea to deactivate it to obtain the most perfect behavior possible.

Neural networks

Observe the behavior of the neural network.

We'll observe and record behavior in detail in a few stages at the start of the learning process.

1. Reset the AI with the Reset AI button. Place Thymio in the middle of the arena. Remember that his first move is chosen at random. To convince yourself of this, click several times in succession on Reset AI and Autonomous.

2. Complete the first line of the table. The small dash means that Thymio's front sensors pick up nothing because there's nothing there.

3. Take a good look at Thymio and click on the step-by-step button.

Question 5

What movement did Thymio make? In the row of the table you've just completed, write down the value corresponding to this movement. Compare this number with the values of the other actions. What do you notice? Write down your answer.

This value is the largest. So Thymio performs the movement corresponding to the highest value.

Question 6

We can also see that the robot has received a reward. Does this reward seem to be in line with the purpose of the mission? Please explain.

Possible answer: Thymio turned left, and received a reward of +55. This is normal, as there's nothing in front of him, so he can turn. Once the first reward has been awarded, the output values are recalculated by the neural network.

Complete the 2nd line of the table and guess Thymio's next move. Make a few more clicks on the step-by-step button, watching the rewards and level evolve.

Awards

Observe the behavior of the neural network 

We'll observe and record behavior in detail in a few stages at the start of the learning process.

1. Reset the AI with the Reset AI button. Place Thymio in the middle of the arena. Remember that his first move is chosen at random. To convince yourself of this, click several times in succession on Reset AI and Autonomous.

2. Complete the first line of the table. The small dash means that Thymio's front sensors pick up nothing because there's nothing there.

3. Take a good look at Thymio and click on the step-by-step button.

Question 7:

How does the level change when the robot is rewarded or penalized? What does the level represent?

Note the answer.

  • If the reward is positive, the level increases.
  • If the reward is negative, the level decreases.

The level represents Thymio's ability to obtain positive rewards. More precisely, it is calculated as the average of the rewards received during the last minute.

Now press autonomous to let Thymio continue learning.

Question 8: 

How does the level evolve during the learning process?

Why is this? Explain:

The level increases as you learn. Indeed, Thymio receives more and more high rewards (especially when he goes straight) and fewer and fewer punishments (since he hits himself less and less). In fact, the aim of learning is precisely to raise Thymio's level.

Penalties

If we summarize the different values shown in the progress bar, we find :

100: When Thymio moves straight ahead without obstacles, this is the highest value.

55: When Thymio turns without obstacles in front.

-50: Thymio performs one of a number of "bad" actions, such as moving against a wall, backing up when there's nothing in front...

We can modify the penalty value.

● Open the reward tab and set the penalty to a small value, e.g. 0: reset the AI and restart learning for a few minutes.

Observe Thymio's behavior: is he bolder, more cautious?

Does he hit the walls more or less often?

● Set a higher penalty, e.g. 1.5. Reset the AI again and run the learning process for a few minutes. Same question as above.

Question 9: 

Summarize how Thymio's behavior changes when the penalty value is modified. Note the answer.

If the penalty is low, Thymio often hits the walls, but becomes more daring and roams the premises to the full.

If the penalty is high, Thymio hits the walls less often, but becomes more cautious and stays within a restricted area.

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Smallest enclosed arena with obstacles

Duration: 1 hour

Age: 8+ years

Settings :

  • example configuration: "obstacle avoidance (reinforcement learning)".

The advantages of this activity:
?

Download
Related courses
Activity: use your imagination!
Activity: use your imagination!

Configuration & backup

AlphAI software lets you create completely customized configurations to suit your needs and objectives.

Choose a level of autonomy, an algorithm, the sensors and actions you want to use, ... and invent your own activity!
You can also start from an example configuration and then customize it.

Once you're happy with the configuration you've chosen, you can save it on your computer for future use!

To understand how to set up the software, follow this link:
link vers Resources page > Software overview > Window panel

Have you come up with an interesting, fun and educational activity? We'd love to try it out, and why not offer it to all software users!

Please fill in the form below to provide us with information about the activity you've invented: 

Activity proposal form : 

  • Your first and last name : 
  • Your function:

  • Activity title : 
  • Activity objective: 
  • Minimum age for participation : 
  • Estimated time required :

  • Arena size and layout : 
  • Type of robot used : 
  • Number of robots used :

  • Activity description: 
  • Parameter file : 

Upload file (.json)

Download
Related courses
Curriculum proposals
Curriculum proposals

Elementary

Introduction to AI" curriculum

Objectives:
Time required : 

Activities : 

  1. AI presentation / ethics
  2. Remote control
  3. Programming
  4. Fearful Thymio
  5. The arena

College

4 levels of autonomy" curriculum

Objectives:
Time required : 

Activities : 

  1. Remote control
  2. Programming Resources page
  3. Fearful Thymio
  4. The Arena

Curriculum: "Understanding AI".

Objectives:
Time required : 

Activities : 

  1. Introduction to AI + ethics (course)
  2. Fearful Thymio
  3. The Arena
  4. Keeping track
  5. Don't just stand there!
  6. The Autonomous Car
  7. Review

Download
Related courses
Robot presentation
Robot presentation

Introduction

mBot is an educational robot designed by Makeblock, a company specializing in the creation of educational robot kits for learning robotics and programming. It is particularly popular in secondary schools for teaching Scratch programming.

Thanks to our AlphAI software, teachers can now help their students discover and understand AI.

In our activities, you will have the opportunity to train AI models in supervised or reinforcement learning, in order to carry out more complex tasks with the mBot robot.

Composition

The robot is made up of various modular sensors on the mBot robot. 

Sensors

  1. 1 Ultrasonic sensor and one motion sensor
    Ultrasonic:
    enables use of the ultrasonic sensor on the front of the robot. It communicates a value according to the distance sensed.
    There are 3 operating modes:
  • obstacle distance: the value returned is the distance from the obstacle measured in meters.
  • obstacle proximity: the value returned is inversely proportional to the distance measured.
  • Absence/presence of obstacle: the sensor returns 1 if an obstacle is detected and 0 otherwise. The obstacle detection distance can be adjusted using the slider below.

  1. 1*2 IR sensor transmitter/receiver
  1. 1 camera (optional)

The actions

The actions you can use on the software are :

You can also create a custom action by clicking on the button:

The following window will then appear: 

Name your action and check "robot action" to modify the parameters: the new action is now available.

To save it for future use, click on File > Save > Save configuration.

Operating environment

We recommend that you use mBot in an AlphAI arena.

The absence of walls limits the activities you can carry out.
You can, however, simply make mBot evolve on a flat surface for certain activities.

To carry out all the activities on the software, mBot will need :

  • A very flat surface. Ideally, use a white tarpaulin.
  • Walls higher than the robot
  • One or more lines on the ground in a color that contrasts sharply with the tarpaulin (you can use black tape).

Download
Related courses
Robot connection
Robot connection

Connect the makeblock USB key to your computer

  1. Switch on the mBot robot
    (If you're connecting to the robot for the first time: press the Bluetooth logo on the key to pair the robot). Here's the guide provided by MAKEBLOCK for connecting to the mBot: https: //education.makeblock.com/help/mblock-block-based-makeblock-bluetooth-dongle-operation-guide/
  1. Launch AlphAI software
  2. From the Home screen, select the mBot robot model in the top right-hand corner.
  3. The robot appears on the screen, click on it and start the activities!

Download
Related courses
Robot maintenance
Robot maintenance

There are two scenarios, depending on whether you have a battery box or a lithium battery:

  • Replace or recharge batteries.
  • Charging the robot's lithium battery by cable (USB B to USB A)
    1. Battery recharge time 3-4h
    2. Battery operating time 1h
  • Recurring problems
    See FAQ
Download
Related courses
Setting up the arena
Setting up the arena

The use of an arena is recommended for all the activities available in the software.

If you own an AlphAI arena, please refer to this page to understand how to assemble it and the different possible layouts: 

link to AlphAI's resources page > Preparing the material > Setting up the arena

Download
Related courses
Activity: Obstacle avoidance
Activity: Obstacle avoidance

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Basic arena

Settings :

  • Supervised learning - Obstacle avoidance (simple)

Duration: 30 minutes

Age: 8+ years

The advantages of this activity :

  • Very few data points.
  • Quick to set up.
  • Easy for younger children to understand.
  • Introduces complex notions to further understanding.

Recommended for hands-on learning

This activity introduces AI perfectly, using the ultrasound sensor and explaining in detail how the robot makes a decision. The robot is first trained by the student with a very limited number of data points, then works perfectly, giving us a better understanding of the robot's decision-making.

Video + text content (step-by-step)

Introduction

Build your arena to form a square. We recommend using an arena designed by Learning Robots, but you can also build your own.

Configuration

The software can be configured manually or automatically.

To configure it automatically :

Parameters > Load example parameters > Supervised learning - Obstacle avoidance (simple)

Configuration can also be carried out manually by following the instructions opposite.

  • Sensors > Ultrasound
  • Actions > Advance , Turn
  • AI > Learning type "Supervised learning", Algorithm "Neural network", Learning speed "0.02",Intermediate neural layers: empty.
  • Visualization > Select: "animation", "connections", "synaptic activity", "input/output values".

Training

The mBot robot can be taught in just two steps:

Teach him to go straight ahead when there is no obstacle.
Teach him to turn (right or left) if there is an obstacle.


Forward :

Clear any objects in front of the robot and press the "⇧" arrow on your keyboard, or click on the "Forward" action on the right of the screen. 

Turn :

Place an object in front of the robot and press the "⇦ or ⇨" arrow on your keyboard, or click on the "Turn right" action on the right of the screen.

THIS IS IT!

Your robot is trained! Now press the space bar or click on "autonomous" at the bottom left of the screen and let the robot move freely, reacting to any obstacles in its path.

To remember: 

In supervised learning, the AI is trained using examples. The AI adapts its behavior to reproduce these examples.

Understanding

Part 1

How does the robot make decisions?

Deactivate the "Stand-alone" and "Learning" modes by pressing the corresponding buttons again:

Each small square represents a neuron. Note that on the input neuron (left), the value increases as the distance increases. (the value is equal to the distance in meters). The value of a neuron is called its activation level.

Screenshot - mBot - A1 - 3c

Screenshot - mBot - 3d presentation (non-existent)

Screenshot - mBot - A1 - 2b

As for the 3 output neurons (right), each obtains a calculated value. The action corresponding to the highest value is the one chosen. If there is no obstacle, the action we give the robot as an example when there is no obstacle obtains the highest value. In our case, this is the "Forward" action.

Unobstructed "Advance" = 6.39 "Turn" = -6.23:

Screenshot - mBot - A1 - 3g

With obstacle "Advance" = -0.24 "Turn" = 3.28:

Part 2

How are neuron activation levels calculated? 

Set software to advanced mode: Settings > Settings display > Advanced.

Then display the values we're interested in: View > Connection values.

Capture ecran - mBot - A1 - 3h

6 new values appear:

The 3 "weights" of connections between neurons. (in black, next to the * symbol)

Screenshot - mBot - A1 - 3i

The 3 "neuronal biases" or "resting values": placed on the connections next to each output neuron. (In brackets)

The highest output value will be chosen as the action by the robot. These values are calculated using the following formula:

Output = Input * Connection + Bias

Screenshot - mBot - A1 - 3j

4.00*2.50+(-0.79)=9.20

Part 3

Note that the above equation has the same form as the equation of a straight line:
y= a x + b.

y = Output, a = Connection weight, x = Input, b = Bias

By putting the formula in this form, we understand that modifying a, x or b will change the y result.

We can check the formula by modifying one of these values. Among these values, there is only one that we can modify.

This is the input(x). In effect, x represents the input neuron. In our case, the input neuron is the robot's ultrasonic sensor. To modify the value of x, simply move your hand or an object towards or away from the robot's ultrasonic sensor.

Very close obstacle

Putting your hand very close to the ultrasonic sensor reduces the value of the input x, since this is equal to the distance measured by the sensor.

When the input value x is small, the activation levels y of the output neurons approach the bias values b.

In this case, the Turn action wins, as it has the highest bias value.

Move the obstacle away

By moving your hand away from the sensor, you gradually increase the value of input x.

As the value of input x increases , the activation levels y of output neurons move away from neuronal bias b. The value of the Turn action decreases as its connection weight is negative, while the value of the Forward action increases as its connection weight is positive.

Above a certain value of x, the Advance action wins out because its value exceeds the others.

Part 4

Reset AI

When the AI is reset, the connection(a) and bias(b) values are replaced by random values. See for yourself!

When learning is in progress ("Learning" button active and "Experience memory" not empty), the weights of connections and biases evolve: this is automatic learning.



+ Experience memory : 36 = Variation of (+3.78)







On the other hand, when learning is stopped (white "Learn" button or empty "Experience memory"), the connection and bias values freeze.



‍OUExperience memory: empty = Fixation of (+3.78)





To remember:

Supervised learning is a machine learning method that enables a neural network to learn a behavior from examples given by humans.

As a neural network learns, its internal parameters (connection weights and bias values) evolve. They freeze when learning is complete.

Bonus

If you wish, you can add actions to the robot and improve its training to make its movements more complex, more natural, and so that it can get out of dead ends more easily.

In the "Actions" section, for example, add "Move back" and teach the robot to move back if it gets too close to an obstacle.

You can also set the degree of turn. In the "Actions" pane, activate the "Turn slightly" action. You can then train the robot to turn more or less sharply, depending on the distance to the obstacle.

Note: When the robot runs diagonally across an obstacle, the ultrasonic sensor doesn't detect it properly. Do you know why?

Screenshot - mBot - 3d presentation (non-existent)

To solve this problem, go to Activity 4 "Complex obstacle avoidance".

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Basic arena

Duration: 30 minutes

Age: 8+ years

Settings :

  • Supervised learning - Obstacle avoidance (simple)

The advantages of this activity :

  • Very few data points.
  • Quick to set up.
  • Easy for younger children to understand.
  • Introduces complex notions to further understanding.

Activity: Line tracking
Activity: Line tracking

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Settings :

  • Supervised learning - Line tracking

Duration: 1h30 (2*45min)

Age: 8+ years

Recommended for hands-on learning

Teach your robot to react to specific situations!

This activity will teach you how to set up the AlphAI software and its neural network to run mBot in a simple environment.

Video + text content (step-by-step)

Hardware

For this activity, you'll need a black line track on a white background.

You can print such a track on paper (the minimum recommended format is A2, i.e. 2 A3 pages or 4 A4 pages).

You can also make such a track using black tape on a wider variety of surfaces. Just make sure that the surface is detected as white by the robot, and that the tape can be removed without leaving a trace.

To create your own circuits, keep these rules in mind:

  • The tighter the curves, the greater the risk of the robot running off the track.
  • To add a little difficulty, make sure the track has left and right turns.
  • Intersections are points where the robot may not always make the desired decision! They add to the difficulty.

Configuration

The software can be configured manually or automatically.

To configure it automatically :

Parameters > Load example parameters > Supervised learning - Obstacle avoidance (simple)

Configuration can also be carried out manually by following the instructions opposite.

  • Sensors > Infrared
  • Actions > Advance , Rotate , Reverse
  • AI > Learning type "Supervised learning", Algorithm "Neural network", Learning speed "0.02",Intermediate neural layers: empty.
  • Visualization > Select: "animation", "connections", "synaptic activity", "input/output values".

Training

The mBot robot can be taught with just 4 actions:

Teach her to move on:

Place both infra-red sensors above the black line and press the "⇧" arrow on your keyboard, or click on the "Advance" action on the right of the screen.

Teach him to turn right:

Place the right sensor over the black line and the left sensor over white and press the "⇨" arrow on your keyboard or click on the "Turn right" action on the right of the screen.

Teach him to turn left:

Place the left sensor over the black line and the right sensor over white and press the ⇦ arrow on your keyboard or click on the "Turn left" action on the right of the screen.

Teach him to back off:

Position the two infra-red sensors above the white and press the ⇩ arrow on your keyboard or click on the "Advance" action on the right of the screen.

Your robot is trained!

Position it above the black line and press the space bar, or click on autonomous in the bottom left-hand corner of the screen and let the robot move freely.

Understanding

Part 1

How does the robot choose between moving forward and moving backward?

Disable autonomous and learning modes by clicking on the corresponding buttons.
In this activity, there are two input neurons (two squares on the left), each corresponding to an infra-red sensor under the robot.

When the sensors detect black, their neurons have a value of 0.00. 

The robot will then decide to go straight ahead to follow the line.

When the sensors detect white, their corresponding neuron is equal to 1.00.

The robot will then decide to move backwards to find the line.

 💡The LEDs above the sensors light up when the sensor detects white. They are off when black is detected.

Part 2

How does the robot know when to turn and in which direction?

One input neuron may receive different information from the other.

One of the two infrared sensors can detect white, while the other detects black.

This lets the robot know whether the line is on its right or left.

When the left sensor detects white and the right sensor detects black.

Which direction do you think the robot will turn?

When the right sensor detects white and the left sensor detects black.

Which direction do you think the robot will turn?

Bonus

Adjust robot speed to the track.

You can adjust the robot's speed to the track. To do this, go to the "Actions" tab and move the speed slider.

Be careful: if the speed is too low, the robot won't be able to move at all!

What happens when the speed is too high?

Find the optimum speed for your track! (This depends on the maximum curvature of the bends and the width of the line).

It's also possible to start from 0 to re-train your mBot. To do this, activate the learning mode and click on the reset AI button. The robot's memory is then erased and it's possible to start again.

During training, observe the evolution of connection weights!

Thumb up sign with plain fill

 To remember:

Unlike ultrasonic sensors, infrared sensors are binary: they can only detect black or white. The number of possible inputs is therefore very limited, and the potential for generalizing AI to new input values is not exploited in this activity.

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Duration: 1h30 (2*45min)

Age: 8+ years

Settings :

  • Supervised learning - Line tracking
Activity: Camera control
Activity: Camera control

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Settings :

  • Supervised learning - Camera

Duration: 1h30 (2*45 min)

Age: 8+ years

Recommended for hands-on learning

Teach your robot to react to specific situations!

This activity will teach you how to set up the AlphAI software and its neural network to run Mbot in a simple environment.

Video + text content (step-by-step)

Hardware

A computer with a webcam.

Post-it notes in 4 different colors or small sheets of paper with large colored arrows drawn on them. Examples below.

Configuration

The software can be configured manually or automatically.

To configure it automatically :

Parameters > Load example parameters > Supervised learning - Obstacle avoidance (simple)

Configuration can also be carried out manually by following the instructions opposite.

  • Sensors > 21*16 camera
  • Actions > Forward , Turn , Reverse , Stop
  • AI > Learning type "Supervised learning", Algorithm" neural network ", Learning speed" 0.02 ",Convolutional layers:empty,Intermediate neural layers: 50 50.

Level 1

Color recognition

For each action, go forward, backward, turn left or right:

  • Choose a color to assign to this action.
  • Place the Post-it in this color in front of the computer camera.
  • Press the corresponding action icon (or use the keyboard). The robot performs the requested action and memorizes the association of this image with this action.




=
Advance



‍=Reculer



=turn
left



‍=turn right

Stopping

Now you have to teach the robot to stop when it doesn't see any colored post-it notes in the image.

Click on the stop action (black square) when no post-it note is visible on the camera. The robot doesn't move, but memorizes the association of this image with the stop action.

You can check that the association has been memorized by consulting the size of the experience memory at the top of the screen.



‍=Stop


Now that the robot's training is complete, simply activate the autonomous mode by clicking on the corresponding button or pressing the space bar.

Take your colorful post-it notes and place them in front of the camera to control the robot!

Understanding

How does the robot make decisions?

Deactivate stand-alone mode by clicking on the button or pressing the space bar.

Each pixel in the image is broken down into 3 colors: red, green and blue. We therefore see 3 monochrome versions of the image on the screen, which, when superimposed, produce the full-color image.

Please note: this is additive color synthesis, not to be confused with primary colors in painting! (Which correspond to a subtractive synthesis).

Each pixel of a monochrome image is associated with an input neuron, whose value is used to calculate the activation levels of successive layers, up to the output layer.

How does the camera detect colors?

The color of the post-it note influences the pixels. Indeed, a yellow color will be detected by the darkening of the corresponding area in the blue image. In fact, yellow is a superposition of red and green, but does not contain any blue.

Blue channel for a yellow post-it note

For a blue post-it note 

The principle is the same for the other two color channels. The camera will therefore differentiate between the colors present on the post-it notes, enabling the robot to make a decision. 

Red channel for yellow post-it

For the blue post-it

When we hold a post-it note up to the camera, as shown in the photo below, we can see that the camera detects the colored area.

This affects the values of the input neurons, which will propagate this information to successive layers of neurons.

When the neural network is trained, the calculations it performs lead it to output the highest value for the action that best matches the data it has stored.

The choice to stop is based on the same principle. However, in this case there are no post-it notes! Instead, the neural network detects more specific details in the image (person, background, etc.). 

The calculations result in the highest value being given to the stop action when these details are detected.

⚠️L The only sensor present in this activity is the computer's camera. This means that the robot has no way of knowing if there's an obstacle in front of it. It's entirely up to you to guide it to avoid a blockage, bump or fall.

Level 2

Moving with the hand

To move the robot by hand, you'll need to be more rigorous when training your mBot. This means that, for optimal training, you'll need to perform several learning points for each of your robot's actions. 

When training, it's important to ensure that the background of the image (everything other than your hand) is sufficiently fixed: same framing, same lighting, same number of people present and in the same seats, etc. These rules must also be observed during the use phase! These rules must also be observed during the use phase!

Forward, backward, left turn, right turn

Place your hand in the foreground of the image.

Adapt the position of your hand to the action to be learned.

Record several examples for each action (e.g. 10 data points per action).







=Avancer






‍=Reculer







=Turn
left







‍= Turn right

Stopping

As in the previous section, we need to teach the robot to stop when it doesn't detect a hand in the foreground of the image.



‍=Stop

Now that the robot's training is complete, simply activate the autonomous mode by clicking on the corresponding button or pressing the space bar.

Place your hand in front of the camera as you did during training, and watch the robot's reactions!

Understanding

Camera operation is identical in both apprenticeships.

But this time, the neural network has to learn to detect the position of your hand in the image, rather than the color of a post-it note. This is a more complex task for a neural network, as there is no objective boundary between a central position and a position on the right, for example. The network will therefore have to determine for itself where to place the limits between the 4 possible positions.

What's more, there are many disruptive elements that can alter the network's decision-making. The network must learn that the size of your hand, its shape, the position of the fingers, its orientation, etc., are not important for decision-making: only the position of the hand must be taken into account. That's why you need to give several examples for each type of action.

The image background is also a major source of disturbance. That's why it's important to keep the background as fixed as possible.

This level will enable you to achieve a fluid result when moving the robot, and go hand in hand with a better understanding of how artificial intelligence works. 






‍Duringtraining






During autonomy

=OK

The camera is in the same position and returns the same information for both phases. The robot focuses on my hand, not the background.

💡Atip: If you're doing this activity alone, make sure you can observe the robot without moving your head during training and autonomy. 

Explicit bias

Today's AIs work by automatically learning from examples. These examples are called training data. The quality of the result obtained therefore depends first and foremost on the quality of the training data.

In machine learning, we seek to avoid the presence of two types of bias in the training data (i.e. errors, undesirable phenomena or, in general, deviations between the desired result and the result obtained).

The first type of bias is called explicit bias. It is a human error of classification when training the AI. Example: If the robot has been asked to move backwards when the camera sees the image below (for example, because the wrong key was inadvertently pressed). 

‍+







(Reverse)

=Explicit bias

In this case, the neural network will have difficulty making a decision when the camera observes a similar image, because of this contradiction in its training data.

To eliminate this type of bias, all you have to do is remove these errors from the data.

Implicit bias

Implicit biases are more difficult to detect, as they are not objective errors, but rather a lack of diversity in the data, which is not sufficient to cover all the cases encountered during use.

Here's a simple rule to remember: when the AI is faced with a situation that is too different from all its training data, then the AI's choice in the face of that situation is unpredictable!

To avoid this, during training, particular care must be taken to generate a diversity of examples representative of the situations the AI is likely to encounter in use.

Training data

Image for analysis

What decision will the AI make?

How can the training data be improved to ensure that this decision is the right one? (hint: 4 examples should be used).

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Duration: 1h30 (2*45 min)

Age: 8+ years

Settings :

  • Supervised learning - Camera
Activity: Avoiding complex obstacles
Activity: Avoiding complex obstacles

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Settings :

  • Supervised learning - Obstacle avoidance (complex)

Duration: 1h30 (2*45 min)

Age: 8+ years

Recommended for hands-on learning

Teach your robot to react to specific situations!

This activity will teach you how to set up the AlphAI software and its neural network to run Mbot in a simple environment.

Hardware

To complete this activity, you'll need to assemble a small square arena:

We recommend you use our individual arena, available on our website or from our distributors.
You can also create your own arena. You'll need a clean, flat surface (e.g. a table), surrounded by barriers of a different color from the ground, and strong enough to stop the robot.

Configuration

The software can be configured manually or automatically:Settings > Load example settings > Supervised learning - Obstacle avoidance (simple)Configuration can also be carried out manually by following the instructions opposite.

  • Sensors > Ultrasonic and motion detection
  • Actions > Advance , Turn , Reverse while turning
  • AI > Learning type "Supervised learning", Algorithm "Neural network", Learning speed "0.02", Intermediate neural layers: 15.
  • Visualization > Select: "animation", "connections", "synaptic activity", "input/output values".

Ultra-sonic sensor - Concept

During the first activity (simple obstacle avoidance), we noticed at the end that the robot didn't detect the wall in front of it when it was diagonally positioned. This is because the ultrasonic sensor transmitter works by sending out an ultrasonic wave which bounces off the wall and returns to the receiver.
The ultrasound then calculates the distance to the object in front of it according to the time it takes for the wave to reach the receiver.

But if the object is diagonal, the path of the emitted wave will be much greater, and the distance calculated will be absurd. The robot therefore finds itself stuck against the wall without being able to move forward, since the dominant action when it sees no obstacle is "Move forward".

‍Further information

‍Theultrasonic sensor measures the time it takes for the wave to return to the receiver. Speed is equal to distance divided by time V=d/t, so distance is speed times time d=V×t. The sensor knows how fast the wave is travelling (at the speed of sound ~330 m/s), and when it emitted the wave. All it has to do is divide this value by 2, as the ultrasonic wave travels twice between the transducer and the object, once from the transmitter to the object and a second time from the object to the receiver.

‍Distance calculationfor an ultrasonic sensor: (V×t)/2

Training

Robot training for this activity is slightly more complex

‍Avancer

Clear any objects in front of the robot and press the "⇧" arrow on your keyboard, or click on the "Forward" action on the right of the screen.















=Avancer



















Turn

Place an object in front of the robot and press the "⇦ or ⇨" arrow on your keyboard, or click on the "Turn right" action on the right of the screen.
Screenshot - mBot - A1 - 2b













=Turn













Turning back

Step 1: Activate the wheel lock sensor

Deactivate learning mode

Place the robot against the wall

Click forward several times until the wheel lock sensor activates

Step 2: Don't touch the robot again

Step 3: Activate learning mode

Fourth step: Click on Backspace to turn left or right

NB: You must take care to choose only 1 side, right or left, before pressing the "Back" button. If you don't, the robot won't know which side to choose, and this will compromise the clarity of the exercise.

‍ THIS ISIT!

‍Yourrobot is trained! Now press the space bar or click on "autonomous" at the bottom left of the screen and let the robot move freely around the arena, reacting to obstacles in its path.

Understanding

Motion detection

To solve the problem of the ultrasonic sensor, we've added a new sensor: a blocking detector. This sensor enables the software to determine whether or not the robot is blocked. To do this, the sensor analyzes the calculated distance of the ultrasound. If this remains the same over several actions, the sensor is activated and the robot understands that it is blocked.

The robot is not blocked:
The sensor displays "1".

The robot is blocked but the sensor still displays "1".

If after several actions the value calculated by the ultrasound is identical, the sensor displays "0".

Status graph

The first thing that jumps out at you when you launch this activity is the presence of what, at first glance, is a very complex graph. This graph is called the "state space". This graph shows the choices the robot makes according to its "state". 

Each of the sensors of this activity is represented in the graph :

Y-axis = ultrasonic sensor.

X-axis = blocking sensor.

The state of the robot is represented by a small square. To understand better, try moving your hand towards and away from the robot, the small square will move along the y-axis.

If you block the robot against an object and move it forward several times, the wheel lock sensor will light up and the square will move along the x-axis.

‍Finally, the colors represent each of the possible actions with the robot (yellow = move forward, green = turn right ...).

During training, you noticed that when you perform an action, the graph will change color. As colors represent actions, this means that the action the robot chooses will be defined by its "state" in the state graph.

‍Example

‍Icithe experiment memory is empty. The colors present in the graph have therefore been chosen randomly. 

In stand-alone mode, the robot would move backwards to the right until it locks, and then move backwards to the left until it unlocks.

Here we've taught him to move forward unhindered and to turn right at an obstacle.

In autonomous mode, the robot will move forward until it encounters an obstacle, then turn right until it is clear of the obstacle.

‍Challenge

In autonomy, how would the robot react in these different arrangements (without taking into account the robot's current state in state space)?

KNN algorithm

Deactivate the "Stand-alone" and "Learning" modes by pressing the corresponding buttons again:

The KNN (K nearest neighbors) algorithm, also known as the K nearest neighbors algorithm, is a simpler-to-understand artificial intelligence algorithm.

This activity takes place in the same way as the last one (obstacle avoidance - complex) and does the same thing, but in a different way. You'll have noticed that the state graph is not colored in the same way. Whereas the state graph took a little while to form, and the colors were not instantly fixed, here the coloring limit is drawn directly and at once as soon as you click on an action.

In this algorithm, the robot walks through a space...

And every data point learned by the robot is stored in this same space.

To make a decision, the robot simply chooses the data point closest to its position in space.

The K-nearest neighbor algorithm is much simpler to understand and allows us, the users, to deliver a smaller amount of data to run the AI, the margin of error is greatly reduced.

As mentioned above, the colors are formed instantaneously, and only represent the perimeter in which, in relation to other data points, the robot's position will be closer to that point.

Example: Here, the robot is closer to the square corresponding to the turn left action, so in autonomy it would turn left.

‍Remind: In the neural network algorithm for making a decision, the robot made this calculation

‍Output= Input * Connection + Bias

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Duration: 1h30 (2*45 min)

Age: 8+ years

Settings :

  • Supervised learning - Obstacle avoidance (complex)
Related courses
Activity: Reinforcement learning
Activity: Reinforcement learning

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Settings :

  • Supervised learning - Obstacle avoidance (complex)

Duration: 1h30 (2*45 min)

Age: 8+ years

Recommended for hands-on learning

Teach your robot to react to specific situations!

This activity will teach you how to set up the AlphAI software and its neural network to run mBot in a simple environment.

Hardware

To complete this activity, you'll need to assemble a small square arena:

We recommend you use our individual arena, available on our website or from our distributors.

You can also create your own arena. You'll need a clean, flat surface (e.g. a table), surrounded by barriers of a different color from the ground, and strong enough to stop the robot.

Configuration

The software can be configured either manually or automatically:Settings > Load example settings > Reinforcement learning - Obstacle avoidanceThe software can also be configured manually by following the instructions opposite.

  • Sensors > Ultrasonic, Motion detection, last action performed

  • Actions > Forward, Turn, Reverse while turning
  • Reward > "Obstacle avoidance
  • AI > Learning type "Reinforcement learning", Algorithm "deep Q-Learning", Intermediate neural layers: 300 100 50.

  • Visualization > Select: "neural network", "connections", "synaptic activity".

Concept

There is no training phase for this activity.

In reinforcement learning, the robot teaches itself by trial and error. Simply press the Autonomous button to start the activity and let the robot train itself.

Once you've pressed the button, all you have to do is watch the robot and let it train itself.

You can also see that the neural network is much larger, with several intermediate layers. Reinforcement AI is a much more complex form of AI, involving many more calculations than those used for supervised learning.

‍Theaim of this activity is to understand :

  • How the robot makes a decision.
  • How his decision evolves as he trains.
  • How the robot avoids obstacles and moves around the arena without touching the walls.

  1. Understanding reward systems

The big difference between supervised learning and reinforcement learning lies in the reward system. As you can see, there are now these two blocks "Reward" and "Level" at the bottom of the screen. But what do they correspond to?

Each action is assigned a reward ranging from -100 to 100. The level corresponds to the average of all the rewards.

Advance = +100

Turn right/left = +55

Turning back = -50

When the wheels lock, the robot takes a -50 reward.

Just like us humans, the robot likes to receive positive rewards and dislikes negative ones.

The robot will therefore try out the various actions it can perform, in a totally random fashion at first, but will soon realize that certain actions bring it greater rewards than others, and it will seek to maximize and then optimize them. The level represents the average of all accumulated rewards, and gives a good indication of the robot's overall level, i.e. its ability to move around the arena avoiding walls. By simulating a large number of trials, the level peaks at around 80-90. At this level, the robot receives almost no negative reward at all, and the average only increases over time.

The trick when programming artificial intelligence by reinforcement is to apply the highest rewards to the actions you want it to master.

For example, if you wanted an intelligence to learn to park in a particular space, you'd program it to apply an increasingly positive reward as it got closer to the space, and an increasingly negative one as it moved further away.

The reward system is the learning method that most closely resembles our own. In fact, our way of teaching also works with a reward system. To help students learn, we invented the grading system; we reward students who have learned their lesson well, and punish the others.

Equipment:

  • 1 robot minimum
  • 1 computer/robot
  • Flat environment

Duration: 1h30 (2*45 min)

Age: 8+ years

Settings :

  • Supervised learning - Obstacle avoidance (complex)
Related courses
Free activities
Free activities

Setup & backup

AlphAI software lets you fully customize the settings to suit your needs and objectives.

Choose a level of autonomy, an algorithm, the sensors and actions you want to use, ... and invent your own activity!
You can also start from an example configuration and then customize it.

Once you're happy with the settings you've chosen, you can save them on your computer for future use!

To learn more about the software's configuration, follow this link:
link to Software resources > Software overview > Window panel

Have you come up with an interesting, fun and educational activity? We'd love to try it out, and why not offer it to all software users!
Please fill in the form below to provide us with information about the activity you've invented: 

Activity proposal form : 

  • Your first and last name : 
  • Your function:

  • Activity title : 
  • Activity objective: 
  • Minimum age for participation : 
  • Estimated time required :

  • Arena size and layout : 
  • Type of robot used : 
  • Number of robots used :

  • Algorithm and training used : 
  • Robot sensors used : 
  • Robot actions used :

  • Activity description: 
  • Parameter file : 

Upload file (.json)

Download
Related courses
Curriculum proposals
Curriculum proposals

Elementary and middle school

(links)

A1 - Obstacle avoidance

A2 - Line tracking

A3 - Camera control

A4 - Avoiding complex obstacles

A5 - Reinforcement learning

Download
Related courses
Resources 1 Spike
Resources 1 Spike
Download
Related courses
Resources 2 Spike
Resources 2 Spike
Download
Related courses
Resources 3 Spike
Resources 3 Spike
Download
Related courses