Lesson Modules
Teaching Tips:
Teacher Demo
Run this code on a robot (or simulation) for the students to see.
If you’re having trouble, think about these:
What external factors can contribute to how humans react to a potential collision?
The distance to the obstacle
The speed of the vehicles nearby
How well the human is paying attention
Question 1: And which of these factors can be sensed on the Altino?
The distance to the obstacle
An autonomous car should have the ability to stop before running into an obstacle in the road. That feature is commonly called collision avoidance. It’s useful to keep passengers and pedestrians safe when traveling at high speeds, and reduce fender benders and cosmetic damage at low speeds.
How does automatic collision avoidance work? To answer this question, it is helpful first analyze how humans control cars to avoid collisions. Sometimes drivers stop when they hear a horn or an ambulance siren, but most often we stop when we see something in the road blocking our path. We do this with the amazing sensors humans come equipped with called our eyes.
What kind of sensor is the human eye? What can it detect? The human eye does the work of many mechanical sensors. Think of some of the things you can detect with your eye.
Which one would be most useful for our goal, making collision avoidance for the RobotLAB Autonomous car?
If you’re having trouble, think about this:
What external factors can contribute to how humans react to a potential collision?
Teaching Tips:
In order to move on to the simulation, answer these questions:
Question 1: Speed is different from velocity in what way?
Average speed - distance traveled/ time taken
Average velocity - position change/ time taken
If you run in a circle and stop in the same place you started, you changed your average speed for that time, but your average velocity was 0.
Question 2: Leena biked for 30 minutes at a rate of 12 miles per hour. What was her average speed?
12/0.5 = 24 miles per hour
or
6/30 = 0.2 miles per minute
Your RobotLAB autonomous car drives around the track above. It takes 24 seconds.
Question 3: What is the average speed?
30m/24s = 1.25 meters per second
Question 4: What is the average velocity?
0 meters per second
Let's begin by reviewing the definitions of the terms we learned in the last module:
Newton's Laws
An object in motion tends to remain in motion, and an object at rest tends to remain at rest.
Force equals mass times acceleration.
For every action there is an equal and opposite reaction.
Our Physics topic for this lesson is Speed vs Velocity. When we talk about movement, speed and velocity are often used interchangeably, but they actually mean two very different things. Speed is the rate at which an object moves or travels. An object moving quickly back and forth has a high speed. An object staying still has a speed of zero.
Average speed is calculated by distance traveled / time taken, and is generally measured in miles per hour or meters per second.
Velocity is the rate at which an object changes its position. At first glance it just looks like a rewording of the definition of speed, but the choice of the word "position" is important. An object moving quickly back and forth has a high speed and no velocity. an object moving quickly in one direction away from its starting position has a high speed and a high velocity.
Average velocity is calculated by displacement / time, and is generally measured in meters per second.
In order to move on to the simulation, answer these questions:
5m |
10m
Your RobotLAB autonomous car drives around the track above. It takes 24 seconds.
Teaching Tips:
The full code is provided here for teachers:
For this lesson, we will go through the code step-by-step.
(You may find it helpful to use this as a template to solve coding problems in the future.)
1. Recall the AltinoRobot Service from lesson 0. It is necessary for every program we will create.
2. Find it in your services toolbox. Double click it and it will appear in your workspace.
3. Click the block and you will see its properties appear in the Property panel to the right.
SerialPort | find yours in your bluetooth settings |
Baudrate | always 115200 |
Feel free to skip this section if you already understand.
4. Now that you have created a connection you can use the other services to control your robot.
Think back to pseudo code you wrote, and the algorithms module to complete this code.
What service do you need for this lesson?
This service can get the distance measurement from any of the car's six distance sensors.
5. To get the distance measurement you need, you have to connect AltinoIR to the Calculate activity then connect the Calculate activity to the Log activity.
Why is that?
The Calculate activity does more than just arithmetic. It can also take an IRNotification from the IRSensor and translate it into a usable number.
The code for that looks like this:
6. A word about the distance sensors
DistanceMeasurements[0] - front left |
DistanceMeasurements[1] - front center |
DistanceMeasurements[2] - front right |
DistanceMeasurements[3] - right |
DistanceMeasurements[4] - left |
DistanceMeasurements[5] - back |
7. Log the result of the Calculate activity and see what happens!
8. Time to do some experimentation! Hold the Altino, run your current program, and watch the Log print the distance measurement. Choose the distance from the wall where you'd like the Altino to stop.
The Altino drives pretty quickly, so you will need to choose a range of numbers in case your exact choice is not logged as it drives.
I chose these numbers. You may choose differently.
9. Now add this code to the first merge:
a. The Altino has 10 speeds (0.1 to 1.0)
b. Put the speed you want in the data blocks
c. Left and right represent the left and right sides of the car
d. connect it to AltinoDrive
As you can probably tell, this code makes the Altino drive forward.
In the end, your code will look like this:
- Distance
- Displacement
- Both
Teaching Tips:
Question 1: What was the coolest thing you learned today? Write your answer in the box, and see it appear which your classmates answers!
Discuss answers with students if time permits.
Self-check
Question 2: Check the concepts you understand. Don’t worry, this isn’t for a grade, it’s just so your teacher can check the classes’ understanding
IR sensor
Calculate
Newton’s Laws
Speed
Velocity
Question 3: What are Newton’s Laws of motion?
1. An object at rest tends to remain at rest, and an object in motion tends to remain in motion
2. Force = mass x acceleration
3. For every action there is an equal and opposite reaction.
Question 4: How do you connect your computer to the car?
1. Turn on the car
2. Use AltinoRobot Service
3. Set Baudrate and port