

Simple Line Following with SPIKE Prime
Line following is a very common competition category. Here's how you can get started with it!
- #2316
- 31 Jul 2024
How to follow a line using Lego MINDSTORMS
Line following is a very common competition category. Here's how you can get started with it!
When you hear the task “program the robot to follow a black line,” you’ll most likely imagine a program that works like this:
So far, we’ve explored a line-following algorithm commonly referred to as duck walking. Let’s take a closer look at how it works and consider how many distinct states it actually involves.
"What is the light in the room?" - should it even matter. You can use one program for all lighting conditions by calibrating the color/light sensor of the LEGO Mindstorms EV3/NXT robots.
In this video tutorial we demonstrate the classic algorithm for following a line with robots. It is widely used in FIRST LEGO League competition and could be applied to LEGO Education SPIKE Prime and to other robots also. The algorithm follows a line by moving to the left and to the right and trying to stay at the edge of a black line.
On the topic of following lines with a robot there is a way to make the robot follow the line a little more precisely. This method is called "Multi-states" program. Or at least we call it like this. In this tutorial you will see how we program 5 state for the robot line following program. This could be particularly important with FIRST LEGO League competitions where we must build consistent and reliable robots.
In this video tutorial we follow a line 10 consecutive times. In this way we demonstrate whats the consistency that you could expect from the robot when following a line with a multi-states algorithm.
With this 10 runs we demonstrate the consistency and reliability that could be achieved with a LEGO Education SPIKE Prime robot and a 2-states simple line following algorithm. It is not bad. Still there are some things you should consider when using this program and one of the things is the use of the timers
In this video tutorial we run the robot for 10 times and we demonstrate the consistency of the robot behavior with our advanced algorithm for smooth line following. What you will get from it is an understanding and demonstration of what can you expect from the robot.
We follow a line. We start from the Smooth Proportional Line Following program and modify it a little for this program. We follow the line with the middle sensor attached on port 2.
In this video tutorial we demonstrate a really important concept for FIRST LEGO League competitions - you position the robot on the field with depending on timers and rotations. The issue with moving the robot for 10 seconds and then stopping is that every time it is in a different location. Same for rotations. The wheels will slip, the battery will change, something will happen and the robot will not be in the same place every time. This is not consistent and reliable.
Looking at the field we must first think of a strategy of solving this line following problem. There are rules that the robot must follow and these rules should be programmed in the robot.
In this video tutorial we show how you can build robots that position on the field consistently and reliably by following and line and then aligning to a line. We also demonstrate the concept of "double align" which is quite powerful and even if there were some mistakes they will be handled.
In this tutorial we introduce the basic algorithm for following a line with one sensor and review the algorithm for quickly followwing a black line with one sensor, implementing both with the Mindstorms EV3 robotics kit.
This video lesson is a revised version of Episode #1. Matt Gipson requested it in a comment. Using the EV3-G software we have developed a very simple program for following a line with two LEGO MINDSTORMS color/light sensors.