Lesson Modules
Teaching Tips:
Teacher Demo
Run this code on a robot (or simulation) for the students to see. Take a screenshot of the log starting when the car begins to drive, and ending when the log goes down to zero.
Your graph will look something like this:
Before we begin, let’s try this experiment:
Start by opening your code from the last lesson and running it the same way you did last time.
Try changing the speed from 0.3 to 0.8
Run your code again and note what happens
Take this time to have a discussion about what happened to their cars/simulations and why they think that was the case. If none of the students guess correctly, explain that when the car is driving too fast, by the time the IR sensor reads a value that causes the car to stop, the car has already moved too far, and maybe even hit something.
Before we begin, let’s try this experiment:
Start by opening your code from the last lesson and running it the same way you did last time.
Try changing the speed from 0.3 to 0.8
Run your code again and note what happens
Imagine you're driving along and you see an obstacle in the distance (like a road block, debris, or even a stop light). Would you slowly come to a stop or slam on the breaks?
How about when you're driving along and a puppy darts in front of your car?
Or when you're driving along the road and see a little old lady driving under the speed limit?
We encounter all kinds of scenarios while driving, and successful drivers can quickly determine how to react by assessing their situation. So far, our autonomous car has only one speed and only one possible reaction, i.e. stop when it senses an obstacle nearby.
In this lesson we will try to make our RobotLAB Autonomous Cars behave more like human drivers by making them more responsive to their environment.
Teaching Tips:
Question 1: When you set the car to drive faster, did your code still work as intended? Why do you think that happened?
Students will likely find that their code didn't work and the car ran into a wall.
Question 2: How could you solve this problem?
This question is open-ended, but one possible solution is to increase the distance from an obstacle at which the car stops.
Question 3: If you were designing a real autonomous car, would you design it to only drive at the legal speed limit?
This question is open-ended
Here is a quick review of the Physics module from the last lesson.
Speed is the rate at which an object moves or travels.
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.
Average velocity is calculated by displacement / time, and is generally measured in meters per second.
This time we will finish up with the Physics of Motion by talking about Acceleration. The word accelerate is commonly used as a way to describe someone going fast, but it isn't a synonym with speed or even velocity. Acceleration is the rate at which an object changes its velocity.
Average acceleration is calculated by distance traveled / time taken, and is generally measured in meters per second squared (m/s 2).
For example, if your RobotLAB autonomous car is driving at a constant speed of 0.3 then it has an acceleration of 0. If it takes 3 seconds for your car to go from 0.3 to 0.9, then it is accelerating at a rate of 0.2 per second.
Teaching Tips:
Now it's time to translate the pseudocode into real code!
Here's something to get you started:
Here is the code solution for the teacher:
s:
Sometimes beginning to write a program can feel daunting, and you don't know where to begin. During those times it's always helpful to describe what you want to accomplish.
Determine how long it takes for the car to accelerate to the speed you set it.
Determine how long it takes for the car to deccelerate down to zero after you apply the brakes.
Based on that data, decide on a safe maximum speed for your car
Based on what you need to do, what tools do you think you’ll need? Look at these blocks and choose the ones you think you’ll need to put in your code.
It may also be helpful to look at your code from the last lesson:
What will you need to add to:
- Determine how long it takes for the car to accelerate to the speed you set it.
- Determine how long it takes for the car to deccelerate down to zero after you apply the brakes.
Try your code out on the simulation and see how it works!
Now it's time to translate the pseudocode into real code!
Here's something to get you started:
Remember, writing code is like writing a poem, there are many correct answers. Maybe you answered differently. If so, I encourage you to convert your pseudocode into code and see how it works!
Hint:
In order to
Determine how long it takes for the car to accelerate to the speed you set it.
Determine how long it takes for the car to deccelerate down to zero after you apply the brakes.
Make a graph like your teacher did at the beginning of class and calculate the average acceleration.
Teaching Tips:
Question 1: Based on the code you wrote and the experiments you ran, decide on a safe maximum speed for your car.
Answers will vary. Somewhere between 0.3 and 0.5 makes sense.
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
This is the students' self-assessment of their understanding of the material. You will see a bar graph once all the poll answers are submitted.
Question 3: Take a screenshot of the values you get from the AltinoAccelerationSensor when you run your code. Graph 20 of those values here:
Answers will vary
Question 4: What does that graph show?
The acceleration is positive when the car starts to move, but levels out the zero when the car reaches the speed you set.
Question 5: What was the average acceleration of your car when going from 0 to 0.3?
Answers will vary