Introduction
We need to patrol the planet to keep it safe, but don't have time to do it ourselves. Learn how to get your robot to steer itself automatically!
-
-
Autonomous robots are very important in advanced factories!
-
Watch the video to see some of Amazon's autonomous transport robots moving products around the warehouse.
-
Think how many people would be required to do the job of the robots!
-
-
-
We're going to make our own autonomous robot to patrol the outside of the planet.
-
Assemble your robot like the picture!
-
You will need the line sensor module for this lesson. For best results, mount your line sensor in the position shown.
-
Connect the left sensor to P1, and the right sensor to P0.
-
-
-
How does the line sensor work? Let's write a test program to find out.
-
Build the test program in the picture - you can find all of the line sensor blocks in the Invent menu. Can you guess what it will do?
-
Program your robot and place it on the activity mat, with the sensor right on the edge of the planet. This is very important - the calibrate line sensors block spins the robot before starting the program, to calibrate the sensor on the surface.
-
Whenever you use the line sensor module, you must always have a calibrate block in the on start of your program.
-
Once the calibration has finished, try moving the robot by hand on and off the planet - the display should show a tick when it is on the planet, and a cross when it isn't!
-
-
-
Turn the robot over and look at the bottom of the line sensor. You should see 3 LEDs.
-
The centre LED is an infrared emitter - just like on your TV remote control! It shines infrared light downwards all the time.
-
The two outer LEDs are infrared receivers - they can sense infrared light.
-
When the robot is on a black surface, infrared light is not reflected and so the receivers give a 0 signal.
-
On a white surface, the light is reflected and so the receivers give a 1 signal.
-
Using the signal from the sensors (1 or 0), we can detect what colour surface to robot is on!
-
-
-
Let's use the line sensor to stop the robot from driving off the planet.
-
Don't forget - the sensor is 1 on white backgrounds, and 0 on black backgrounds.
-
Put the code blocks in the picture into a program that makes the robot:
-
Drive forward
-
Stop If it drives off the planet (when the background is black)
-
There are some hint blocks if you need them.
-
-
-
Now we have everything we need to drive around the edge of the planet automatically!
-
To do this, your program needs to:
-
Check the left sensor
-
If the sensor is 0, we are about to drive off the planet! Turn slightly right towards the middle of the planet
-
Else, we are still on the planet - just drive forwards
-
Your robot should drive around the edge of the planet, without getting lost. There is a hint of the blocks you need in the picture if you need help!
-
Try and make your robot drive around the planet as smoothly as you can.
-
Don't forget to place the robot on the edge of the planet at the start, for the calibration!
-
-
-
Currently, the robot tries to stay on the white and avoid the black.
-
Can you change the code so the robot orbits the planet by staying on the black, and turning away from the white?
-
Hint: instead of normally going forwards, you will need to normally be turning towards the centre of the planet.
-