Discover our
resources
Equipment:
- 1 robot minimum
- 1 computer/robot
- Flat environment
Settings :
- Supervised learning - Line tracking
Duration :
1h30 (2*45min)
Age :
Ages 8 and up
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
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!





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.