Last part of the series. The final touch of the program makes sure that it works and is following the line with the LEGO Mindstorms EV3 Color Sensor in a smooth and fast way.
- # 177
- 01 Nov 2015
In the video the second math block is not correctly connected. Download the program from the Materials section to see the correct version.
The problem is that the output port from the sensor is connected to input "b" and should be connected to input "a".
This is the result that we currently have for the proportional following of a line. This is the result we want to have, very smooth program.
Finds the line very fast, follows it but this is the program that we currently have.
There is a difference in the program, especially the beginning and in this video we'll remove this jiggling in the beginning.
The secret here would be to somehow modify the values for the right and left motor so that they are larger and smaller but with a certain percentage. This would make the robot find the line much faster without so much movement and if we add one more value, right here, we multiply the result of subtracting 40 from the value of the sensor. We multiply this by 0,4 and this is 40% of the difference. We move with 40% of the difference and we add the same thing to the other Math block - 0,4. Download and run.
The robot finds the line and starts following it.
Let's return to the program for a minute. What you see here and the reason behind this 0,4 and multiplying by 0,4 is actually that we have the speed of the motor calculated from 2 things. The first is the constant speed that we would like the motor to have and then how fast we want the motor to rotate towards the line so how fast we want the robot to move to the line and we can experiment with these 2 values. We can experiment with the value 15 here and the value of 0,4. It is always a good practice when you have such constants to extract them in a new constant block, numeric and it will be 0,4.
We want to take this constant and pass it to the block as the variable c.
Then we want to multiply it not by 0,4 but by c.
This won't change the behavior of our program. Let's download and run it.
As you can see we've changed our program, the blocks but it behaves in the same way, which is great. There's one more thing we can improve in our program.
We have extracted the value c and it's equal to 0,4 as a constant and
with this constant we calculate how fast we want to turn to the line and we also have the constant speed which is 15 and I add another constant with the value of 15 and I take it to the Math block and it would be the d parameter.
We also change it in the other block.
This also won't change the behavior of our program but we can now customize these 2 parameters. What's the constant speed and how fast do we want to turn to the line. By modifying these to parameters you can customize this program for your particular robot. It depends of course what's the distance between the different sensors, what's the light in the room and how white is the line and what's the construction. By modifying these 2 constants we can modify our whole program. Let's just zoom out. This is the program for a proportional following that's very, very smooth.
Find the instructions for building this robot and doing this proportional line following algorithm below the video you can download and use the whole program in your programs.