Program Mindstorms Nxt 2.0 Follow Line
HOWTO create a Line Following Robot using Mindstorms. The easy way of learning how to built your own Line follower Robot using a PID Controller without any of the mathematical expressions that you will find on most tutorials. Code included The first thing you have thought about after unboxing your LEGO Mindstorms was building the first robot, and just after that you would love to make it follow lines, isnt it Line following is one of the most common problems on industrial robots, and it is one of the most useful applications because it allows the robot to move from one point to another to do tasks. There are several ways of making a Line Follower, the one that I am going to explain you about is using the Light sensor. As you know, both Mindstorms and EV3 sets come with a little light sensor that it is able to get a reading of reflected light, apart of seeing colors. On this tutorial I will explain how to do line following with just one sensor. The more sensors you have the better and faster the robot will be able to follow it. Building the line follower robot. This is the Line Follower project for NXT 2. See free building instructions and programs at httpwww. NXT2line. So first thing is build yourself a little robot much like Track. You can download the instructions provided by LEGO. It is a simple construction. Or base it on one of the LEGO Education modelsWhatever you build, just try to keep the distance between wheels to a minimum because the bigger the distance, the harder for the robot to follow the turns on the line. Ok, ready Time to code. Let me explain how we get to the best solution with a serie of intermediate steps that will help you understand it better. Building your playground for line following. Ok, the robot is done. JuZ3jILyus/UhIw6oLPTuI/AAAAAAAABzQ/gmwg-nT2Of0/s1600/programev3nxt.png]];var lpix_1=pix_1.length;var p1_0= [[744' alt='Program Mindstorms Nxt 2.0 Follow Line' title='Program Mindstorms Nxt 2.0 Follow Line' />But before start coding, we need the line that the robot will follow. If you happen to have the Mindstorms NXT 2. Do you want to know how many bricks are produced per minute How many bricks have been produced in history Whats the bestselling set ever What has been the worstBut if you dont just do like me. I have used a black tape and with the finger I have sticked it to the floor creating a continuous path that the robot will follow. You dont need a closed loop although it is a good idea to do it in that way. My floor is done of marble that it is white and brown at times and even with that it works. So it may work too on yours unless it has even less contrast than mine. Line Following Problem definition. Program Mindstorms Nxt 2.0 Follow Line' title='Program Mindstorms Nxt 2.0 Follow Line' />It is quite important to understand the line following problem first. So lets describe the problem. We have a thick black line on a white surface and we want our robot to move along the line following it in the fastest possible way. Right Well, first thing that we need to understand is that we dont want to follow the line wtf No, serious, we dont follow the line but its border in what it is called left hand approach. We want to follow the line where there is a 5. So, next step is defining what it is black and what it is white. The interior of a 3D MEMS Gyroscope Sensor is intricate and tiny this structure is only about 0. My last two blog entries discussed demonstrations of. You now have access to all the elements in the WeDo 2. PF2 Hub, motor and sensors. The location of the elements is perfectly. We own the Worlds Largest Robot Collection and exhibit it Free of charge at schools, libraries, robot competitions and. We want to follow the line where there is a 50 of white and a 50 of black. So, next step is defining what it is black and what it is white. I hope you have a clear. Teachers looking to empower students, turning their natural curiosity into creative exploration, can use LEGO MINDSTORMS Education EV3 as an instant engagement tool. Resources. Save. Home corner furniture, dolls houses, play food, dress ups, role, play, block play, wooden railways, dolls and accessories. The registered jack standard has been around for some time for people to follow in wiring their telephone lines. It is abbreviated into RJ and is then followed by two. I hope you have a clear idea of what these two colors are, but unfortunatelly your robot dont. So the best thing you can do, before starting anything else is calibrate the robot. Light Sensor calibration. Ok, as you know Color sensor can also work as a Light sensor, so we choose the Measure reflected light mode and we are going to store in two variables the white and black colors. The reflected light value is just a number between 0 and 1. So the pseudocode would be. CALIBRATE. print WHITE. Wait for Touch Sensor to change. Read Light Sensor. BLACK. Wait for Touch Sensor to change. Read Light Sensor. Do you get the idea We add a Touch sensor to our Robot to record the light value, you can also do it using Brick buttons, as you prefer. Here is the EV3 code that I used for it. So the idea is that you place it on the white surface, press the touch sensor, place it now on the black surface and press the touch sensor again, now we have the white and black readings and can start working. I do it each time I start the robot but you can safely ignore it while light conditions keep stable. Line Following with OnOff Controller. Ok, we have the robot, we have the calibration data lets go code. Maaaaaaah. HH Bad Lets think first what we are going to do. Lets start with the simplest possible way and perhaps the worse of doing line following. We place the robot on the line, we get a reading if it below the middle black white we move to one side and if it is above we move to the other side. Simple Clever Lets see again the pseudo code. LINE FOLLOWING. white 0, black 0. Read Light Sensor. B set power 5. 0. C set power 2. 5. B set power 2. 5. C set power 5. 0. The idea is pretty simple just make one wheel turns faster than the other. Here it is how it works. Here is the EV3 program You can download all the source codes on the bottom of the page Does it works Well. If the corner is step enough the robot will miss it and as you can see it is missing the straight line and it starts oscillating around it. Why Because we have only two states, so the robot is either turning left or turning right. What can we do Exactly. So we have left, straight and right. So why not make the turn proportional to the error, the difference between the midpoint and the value read. Line Following with a P Controller. Do you like Maths I dont. I have a deep understanding of them but I really cant stand the complex way of explaining simple things. P Controller without any kind of mathematical notations. If you follow the reasoning of the OnOff controller with several states you may end up thinking of a controller with infinite states, each one of them with an value proportional to the error, the difference between where we want the robot to be and where it really is. If you want something to be proportional to a quantity you just multiply both factors so we have. Kp midpoint Light Sensor Reading. Where K is a constant that helps us tune the P controller. The bigger Kp is the higher will be the turning when there is an error, but if Kp is too big you may find that the robot overreacts and that it is uncontrollable. You can watch what happens when you change the value of Kp from 0 to 1. So start with 1. So our P Controller would be like this pseudo code. LINE FOLLOWING. white 0, black 0. Read Light Sensor. Download Quran Dan Artinya. Turn BC Motors by correction. If you are not using the EV3 module just move one motor a value correction and the other motor to value correction. It is pretty much the same. Here it is the EV3 program You can download all the source codes on the bottom of the page Tunning the Kp parameter. Start with Kp1 and run your robot. If the robot cant follow the turns on the line then increase Kp, if on the other hand your robot turns violently on the line, decrease the Kp value. The bigger the effect the bigger the change need on Kp. Cod4 Promod Bots. Just keep playing. The P Controller has two problem that can be easily fixed with a complete PID controller one is that it will oscilate after corrections and the other is that there is a small error that it is a direct result of the P Controller. So lets see the complete PID controller. Line Following with a PID Controller. A PID controller is basically a P controller with two other components, the integral part and the derivative part. Dont be scared. Let me explain the overall idea and we move to the pseudo code. Proportional part of the PID Controller. This is exactly the part that have just seen above. Integral part of the PID Controller. The idea behind the integral part is that the error must tend to zero over a period of time. I will avoid you a very ugly mathematical expression explaining this. So over a number of interation we want this to be zero.