On the right track

Let’s take a closer look at a new feature for the Leo Rover – line follower.

May 11, 2023

by

Aleksandra Szczepaniak

The Leo Rover's line follower

You surely already know there are brand new features available in stock Leo Rovers as a part of the Leo Examples package. And the major one is line follower. It’s free and available to everybody so don’t hesitate to run it on your robot. But first, let’s find out more about this feature :).

What is a line follower?

A line follower is a feature that makes a robot autonomously follow a visual line embedded on the surface using a feedback mechanism. 

Detecting the line and steering the robot to stick to the designated track, while repeatedly correcting erroneous movements with the feedback mechanism, ensures a simple and practical closed-loop system.

How does the Leo Rover’s line follower work?

Line followers can differ in hteir operating mechanisms. The one in the Leo Rover mobile robot operates based on a neural network. First, the network had to undergo training to ensure optimal performance in the end. During the training phase, the neural network uses an image from a Leo Rover, which is then preprocessed to meet the necessary requirements such as the right size, among other things, just to be suitable for the neural network. After that, the network processes the image to finally provide 2 values that denote the linear and angular velocities. These two values are then used to make a Twist message and send it to the right topic (cmd_vel). Once the whole node is activated, the neural network takes over and controls the robot. The rover drives on its own based on what it “sees”through the neural network.

Line follower's software scheme
A simplified scheme of the software

As mentioned above, not every line follower works the same way, but ultimately, the outcome is pretty much the same in any of them – guiding a robot to follow a line. In the case of the line follower example for the Leo Rover, though, the robot follows a track marked by two lines. We decided to go for two lines instead of one to increase reliability as it could be difficult for the rover's camera to detect a single line consistently under various lighting conditions and some other factors. If any disturbances were to occur, it could be challenging for the neural network to keep the rover on track. Thus, a two-line track seemed like a better solution.

The color mask of the Leo Rover’s line follower
The color mask of the Leo Rover’s line follower

The image preprocessing allows a Leo Rover to follow a track between two lines of any color (although it’s best if the lines’ color is different from the ground's). How does it work? From the image that is sent to the rover, the color is captured. Knowing that the line is, say, blue, it allows you to focus on this one particular color and, in the end, after the preprocessing, you get a black and white image in which everything that’s white, in the original image was blue. Thanks to a black and white image, it’s easier and faster to do some calculations.

What did we need?

Other than a Leo Rover itself, we needed an insulating tape and software uploaded to the robot. Sounds easy, doesn’t it? That’s because that’s the easy part. But there’s more to that. 

The hardest part while working on this feature was training the neural network. Doing it is quite computationally expensive and even a little bit time-consuming, depending on how much data one has. Not that we complain, though ;).

When it comes to the network architecture for the line follower feature, it could be designed to be either big or small. However, the smaller it is, the faster the calculations are done, meaning that both the training and then, the network operation time (uploading an image and getting an output) take much less time compared to a bigger network architecture.

There are libraries available on the Internet to run neural networks on them, with some converting the neural network into a "lighter" version, so that it performs better on specific devices. A library of this kind is, for example, TensorFlow Lite which we used to convert our neural network model.

Enjoy new features for your Leo Rover

To learn how to run line follower on your Leo Rover, go to this tutorial. And as mentioned, it’s not the only new feature we’ve added recently! Make sure to check out our other new integrations on object detection and ARTag follower. They’re all part of the Leo Examples package.

Want to see more posts like that?

Subscribe to stay informed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

See more blog posts:

<- get back to the Blog