The aim of this challenge is to create a robot vehicle that follows a line and avoids collisions with obstacles – including other vehicles!
All you need for the most basic version of this challenge is a simple two-wheel robot, such as the Robot Educator Model with a Colour Sensor (referred to, and used as, a Light Sensor throughout this post), positioned at the front of the robot, pointing down.
Instructions for the Robot Educator Model are in the booklet that comes with the core set and in the EV3 Software.
Control theory is a branch of engineering and mathematics that is particularly important in robotics. It deals with how a dynamic system with inputs (e.g. a robot) responds to feedback to modify its behaviour.
This challenge provides a very basic introduction to controls, including simple bang-bang controls and proportional controls.
Here is a selection of challenge ideas and sample solutions…
1. A gentle stop
Can you create a robot that slows to a gentle stop when it sees an obstacle?
2. Safe following distance
What if you want the robot to stop short of the obstacle (or follow another vehicle at a safe distance)?
Note: The multiplier of “2” in this example is the proportional gain. You will need to experiment with this value. If it is set too small, the robot will not consistently reach the target distance (because of friction and/or stalling of the motors at low power). Too high and the robot will overshoot the target and may end up oscillating around the target distance.
Once you get this working, it’s fun to have a line of robots following each other…
It’s clear that the robots aren’t really following each other, and it doesn’t take long before they start breaking formation. This is particularly obvious towards the end of the clip.
What we really need is a better way to keep the robots in line…
3. Basic line following
How can you make a robot follow a line using a single light sensor?
Here is a sample program for a single Light Sensor using a bang-bang control.
The idea is that the robot will follow the edge of the line, by deliberately driving off it one way, and then driving the other way back onto it.
- The Switch is set to Colour Sensor > Compare > Reflected Light Intensity. Why?
- You may need to adjust the Threshold Value of the Switch to find a value between the light background and the dark line. Use Port View on the brick or in the EV3 Software to help with this.
- If your robot is struggling around the tightest corners, how can you adjust the Move Tank > Power Left / Power Right settings to make even tighter turns?
4. Smooth line following
What about making the robot follow a line more smoothly?
Here is a sample program for a single Light Sensor using a proportional control.
- This program uses a Colour Sensor block set to Measure > Reflected Light Intensity to take a light reading and then feeds this value into the Math blocks.
- The Math Blocks are configured to evaluate these formulas:
- Left motor = a + b x (c – d)
- Right motor = a – b x (c – d)
- a = default motor power
- b = gain
- c = target value
- d = sensor reading
- The difference between the target value and the sensor reading, (c – d) in our formula, is known as the error.
5. Intelligent highway
Can you modify your proportional line following robot so that it maintains a safe following distance behind the robot ahead of it?
Here is an example that combines a bang-bang approach to prevent driving into an obstacle with a proportional line follow. It is, however, also possible to combine two proportional controls.
The result is something like this…
Here is a possible approach to assessing this challenge.
|A+||Your car is the safest. You’re a defensive driving superstar.|
|A||Your car follows the line and other cars reliably and smoothly.|
|B||Your car reliably follows the line and stops when it sees another car or obstacle.|
|C||Your car reliably follows the line or stops when it sees another car or obstacle.|
|t||You have something resembling a vehicle.|