Today you are coding in Scratch. You will build an autonomous car that senses the track and steers by itself.
You can already make sprites move and respond to events. Today you will use sensing and decisions so the car follows a track without you steering every turn.
Before you run anything, think: what might the car need to notice so it can stay on the road?
Keep the start short. Devices open on Scratch, students logged in. Optional predict: before anyone builds, ask what the car might need to notice to stay on a road. Do not spend long here; time belongs on the build. Work in pairs once the hook is clear.
What is an autonomous car?
An autonomous car (also known as a driverless car, self-driving car or robotic car) is a car that is capable of sensing what is around it and navigating without a person driving.
How does it work?
Autonomous cars use a variety of techniques to detect their surroundings, such as radar, laser light, GPS, odometry and computer vision. They have advanced control systems that interpret sensory information to identify appropriate navigation paths, as well as obstacles and relevant signage.
The following 2 minute video shows some of the different cameras that a Tesla autonomous car uses to sense where the road is and all the different objects that it comes close to such as people and other cars.
Play only enough of the video to show real cars using cameras and sensors to read the road. Link it to today's idea: sense the surroundings, then decide. No need to finish the full clip. Check understanding with one quick question: what is the car noticing?
Let's program our own autonomous car! First, create a new Scratch project and delete the cat sprite.
Model creating a new project and deleting the cat on the board. Circulate to confirm every pair has a blank project before the car sprite is added.
Included with this step is a car picture that we're going to upload into our Scratch project. First download the picture file onto your computer and then upload it into your project.
Ensure every pair can download and upload the car image. Point out the red, blue and orange ellipses on the front; these will act as sensors. Watch for upload failures or the wrong file type.
As the car sprite is very large, we'll need to shrink it so that it has room to move around. We're going to shrink it to 10% of it's original size.
Add the following code to the car sprite:
when green flag clicked
set size to (10) %
Model adding the when-green-flag and set-size blocks. Common bug: size left at 100 percent so the car cannot fit the track. Click the flag once to confirm it shrinks before moving on.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.