Let's implement a more advanced program for this robot to learn how to use with motors in opposite directions - and this is to implement the Proportional Line Following algorithm.
- 13 Mar 2016
The algorithm controls the motors based on the sensors. But in this robot the motors are placed in opposite directions. We show how to modify the Proportional Line Following program to make it work for this robot.
We are also following not a black line, but a red line. Which is interesting because red should be a color close to white. This is how the color sensor should work. Or is it?
Find the complete short course at:
A course on proportional smooth line following can be found at:
Follow the line backwards. It shouldn`t be difficult at all. But you have to understand how the program works. Record a video, take a picture and share it with us in the comments section below.
Tasks description, submission and evaluation are available to subscribed users.
Subscribe now to access the full capacity and get feedback.
In this video we are using our very strange Frankenstein robot, that has the 2 motors in opposite directions. And we are going to implement the proportional line following algorithm so that we can customize it to work with this very strange robot.
First I'll go to fllcasts.com site and I'll find the playlist for proportional line following. It's in the playlist section and it's right here. Proportional Line Following with LEGO Mindstorms EV3. Then in the third video, we have a complete final solution in the materials section. This here is the video. And we have the section for proportional smooth line following. When you download the program, you'll get something that looks like this. This is the program for proportional line following from this episode. And there are a few modifications that we must do in this program. First, we'll use the third sensor, so the sensor on port 3. In our case this is our right sensor.
What I'm trying to do now is to show you how to modify this program, so that it works for your robots. Because we received a number of questions on how we can modify this program for your constructions and for the way you build your robots and this is what I would like to show you today. Using our very strange robot. So I change the port for the color sensor, then I change the motors, our left motor in our case is C and the right is B. These are the 2 motors. So left motor - C, right motor - B. And the sensor is on port 3. These are the first 2 modifications that you must do on your program. Then we must detect the value of the color sensor. When I'm over the table, I can see that we detect a value of 60, that's the value that currently the sensor detects and when I move over the red line, I move the robot over the red line, when I'm over the red line, the value is 38. So over the table - 60, over the red line - 40. The value between 40 and 60 is 50. Third modification to do is to change the threshold value to 50. This one here and this one here.
This should be all. Let's now download, run our program and see how it behaves. Starting the program . It moves, but it seems that the robot is not detecting the line. So something strange is happening here. What's strange is that we must take into account that the motors of this robot. are placed in opposite directions, so whenever we want to use the right motor - B, we must actually in order to turn left with this motor, we must turn the motor back, because of its position. If we turn the motor forward the robot will turn right. And if we move the motor backward the robot will turn left. and that's different for this robot compared to the other robots that we built in which the motors are in the same direction. I'll change this in the program, so that we have the opposite calculated value passed to the motor for turning right and left.
We have our left motor - C, that's placed in the correct way, so whenever we move forward with this motor, the robot moves forward, but motor B is place in reversed. This means that we must reverse the value for this motor. I'll take a math block, I'll take the value that we calculate for motor right, and I'll subtract this from 0. What would the subtraction do? If the value for the right motor is let's say 10, then the result will be -10 and if the value for this motor is -10, then the result will be 10. This means that by subtracting this from 0 we actually reverse the value of motor right. I'll pass this, right here. I think we are ready to download and run.
The robot searches for the line, detects it and starts following it.
I hope you understood how to modify the proportional line following program for your robot. And how to use this program, even for very strange robots, where the motors are place in different directions. Find the instructions below for building this robot along with the program. If you find it difficult to follow the instructions in the video just download the programs, they're below in the materials section and directly use them. If they are not working just drop us a comment and we'll get back to you and try to see why they're not working.
Lessons with this tutorial
This tutorial is used in the following lessons