 Hi, Robert Ford. I'm an IT instructor school of information technology at College of North Atlantic in Qatar One of the courses I teach several courses mostly to do with programming I am currently teaching the intro introduction to Java programming and in a way to help get the students into the idea of Programming we've introduced the use of Lego Mindstorm Robots as a computer preparatory program Okay, so this is one of the robots we actually have the students spend one or two classes at the beginning and actually build the robot from from scratch Even if the robot is partially assembled Sometimes the students will have made some modifications. This is a fully constructed robot with pretty much all the parts that come in the educational kit Uh, so the main the main body of the robot is the what we call the NXT brick, so this this robot is produced by Lego And of course this is this is the main brains of the operation so inside inside the brick you'll find a It's a small 32-bit microprocessor There's some RAM. I'm not sure how much and there's also some flash storage Okay, it is a very simple It's an embedded device and it works in the original way that You program on the pc you download your programs into the into the brick And then you select the program to run from from the actual user interface here Okay, now there are several inputs and outputs that are available with the robot This particular robot supports a total of three outputs when they're labeled abc Okay, and you'll see that there's only two of them that are connected right now And that's because somebody has incorrectly connected one of my wires here But the two motor the two things that are connected for outputs are the b and c motors And if you follow the wires down, you'll see that these are actually connected to the main driving motors So you'll see a standard configuration that we have our students build Involves a tail dragger configuration where there are two main driving motors plus the tail motor which can spin And by having full independent control of the two wheels, we can have the robot move forward move backwards Spin on the spot or make some slower turns if required Now I see here there's been a small modification. Somebody has taken this motor here, which is on this arm This should really be plugged in up here on at the top as motor control a So what what we can ask the robot to do is we can have the robot go up and find something and actually take a swing So maybe if it wants to play golf for some other sport, it could do something like that So it doesn't just move in a straight line or I mean, it doesn't just move on a flat surface. It can also do some actions Oh, of course. Yeah. Okay. Okay. So it just requires the extra motors to do this Unfortunately, there is only a total of a total of three outputs. So if there's additional things required You would actually have to take several of these robots and hope them together that that is possible But that starts becoming a little bit more difficult Now in order to interact with the surroundings, there are a bunch of Input values or sensors that can be that can be attached to the robot There are three three types of sensors four types of sensors actually I'm missing one type here that come with the basic kit although there are additional There are additional sensors that you can also buy On top of these and I'll try to remember to explain these in a second But these are the ones that come with it The one that I find is the most accurate and most predictable is what appears to be a pair of eyes at the top This is actually an ultrasonic sensor and it works the same way that sonar works A small pulse is sent out and it measures how far away certain objects are This one turns out to be very very useful It has a range of just over two meters and it's usually quite accurate within one one or two centimeters even at that range Also here on the side and there's what appears to be an arm This is a sound sensor. So this will measure how loud things are Unfortunately, I don't know whether or not it's possible or practical to do voice recognition through this I haven't explored this myself yet. Okay, and on the bottom There is a light sensor and light sensor can be used to detect whether or not There's a bright area or a dark area And one of the most popular things for this light sensor is actually have a pointed down at the ground So that it can follow lights So if it if you wanted to tape out a dark path showing a robot where the drive it could actually detect as it goes Okay And how do students interact with this? Do they do they like Uh The fact that they can really move robots by themselves or did they get frustrated at times? It's a little bit of both The the easy answer to this is Most students who interact with the robots have an awful lot of fun with it because When you make a mistake the robot will usually do something silly and it's it's usually quite entertaining So the robots may flip over we saw some examples here today The robots may crash into each other Sometimes something just may make a really strange sound It's so they do have a lot of fun with it. Okay. There are some frustrations with it because of course you're dealing with with real life Some of these things such as the sound sensor. This is an instantaneous measurement So if there's not sound going at exactly the time that you read the sound measurement You may not hear anything. So somebody's clapping one clap at a time If the if it reads when the person isn't clapping their hand because it's between claps, uh, they may not hear it Uh, when they're dealing with the light sensor, sometimes we use the light sensor to detect certain colors But it's simply a it's like watching a black and white television Uh, you have different shades of gray and sometimes green and blue might look almost exactly the same And sometimes the students get frustrated with this because they will run the program once and if the light is Just a little bit different. It may run differently the next time So it can take a little bit of explanation before the students start so that they uh, they don't become frustrated with this Okay, but for very basic movements and measuring distance of things Usually the robot is quite accurate and it's uh, it's well received. Okay. So can you show us a movement? Uh, sure. And tell us about the software you're using. Now There are several options for writing programs on the on the lego mindstorm robot. Okay People have developed environments for using Traditional programming languages such as java and c++ and other languages that are very similar to these What we are using in our current preparatory program is something called the nxtg programming Language and this is provided by lego. It comes with the kit and what it's what it Is it simulates the construction of programs using a flow chart? It's a very easy to use programming language But unfortunately as a result of being really easy to use it It is somewhat limited, especially when you start getting into things such as variables. Okay However, what we will do is I can show you some very simple movements here today In order to Get an idea of what's what's involved and what we'll do is we'll start off with Maybe we'll do two programs So, you know, we'll do a very simple program where the robot will go forward a certain distance And maybe we'll have it run some small pattern like turn left and right and then come back to where it starts Yeah, that would be great. And then afterwards we'll try using one of these Sensors. Yeah, so you can see how that would be really good. Okay. This is what the programming language looks like What the in programming environment looks like and you'll see here This is where the start begins. Okay, and simply all that we do is we drag over blocks as we require And they go from left to right just as the way how a Traditional flow chart would go from top to bottom. Okay. Okay. So what I'm going to do If we want the robot to say go forward turn 90 degrees go forward turn 90 degrees and go forward What we can do is we could bring over a Okay, and you'll see here if you want to move in a little bit closer so you can see what's happening. I'm zooming. Okay Uh, you'll see here that this move block is currently set up to operate both the c and b motors at the same time Yes, and if you recall that's what my that's what my robot is set up to is for both the c and b motors And what we'll do is we will let the motor We'll let the robot go forward for we can set how long the robot's going to turn on this motors for by the Number of rotations of the wheels. Okay, or we have some other options here We can say turn on the motors for so many seconds Or we can ask it to turn on the motors for so many degrees and of course 360 degrees being one full rotation Okay, so I think for fun this time what we'll do is we'll say we'll let it run for three rotations Okay, so that means that the row these wheels are going to turn on and they're going to turn completely around Three times and then stop. Okay, okay Great, so this will make the robot go forward some of the other options that we have We can also have the robot go backwards. We can use some steering to make it go to the left or right I found that these are not highly accurate It is possible to use it, but sometimes you won't get the robot going exactly where you want without a lot of fiddling around But we do have some options. We can make the speed of the robot change So I think what we'll do is we'll slow this down And of course, it's just like driving a car if you drive your car too fast, you're going to have difficulty stopping You're going to have difficulty making making corners, but of course you'll get there soon Okay, so it all has to do with accuracy and what we'll do is we'll try one at 25 We'll try one at 50 and we'll try one at 100. Okay, so what we're going to do is we're going to make the robot go forward three rotations And then what we're going to do is we're going to bring over another move block But this time rather than running both the b and c motors I'm going to run just the b motor and of course what will happen is if just the b motor turns The robot will turn now If I turn The robot if I turn on the b motor I'm going to run this at exactly the same speed at 25 If I was to make the b motor run for one full rotation I believe that this will give us very close to a 90 degree turn It won't be exact because it has a lot to do with the how far the wheels are spaced For example, if I move these wheels apart a little bit further Then suddenly the turning radius has changed very much But this will be very close to making a 90 degrees turn And even if not, we'll we'll have to move with this All right, so this will make a turn about 90 degrees And let's bring over another move block and again this time we'll use the c and b motors And we'll let this run for another three rotations Okay, this time we'll let the we'll let the motor run at seven. Well, we'll set it to 50 percent so half speed And then once we're finished this we'll just toss in another Maybe uh, well, maybe this time we'll turn on the c motor. So the robot should turn the other direction And again, we'll let it run one rotation And what this should do is this should now be pointing back roughly the same direction as where it was The same direction it started and then what we'll do is we will move the robot backwards So I'll select the backwards direction. We'll run both motors We'll run three rotations, but this time we'll try and see what full speed looks like. Okay, great That's all that's involved with rating very simple movement programs. It's just one after another So there is no coding required. There's no recording required. This is this is the coding Okay, now, of course, what happens is when you ask this program to be put onto the computer Uh, this program will be turned into machine code for for the interpreter to run on the brick Okay, but the actual programmer doesn't need to deal with doesn't need to deal with any of the syntax That is one of the positives of this language. So in order to download this what I will need to do is I need to start Up the nxt robot. So we'll switch this on this boot up Okay, so this is now booted up. So now downloading the program turns out to be very easy Here the program is called test three. So let's keep that in mind And we'll click on this button here to download And if all goes well Okay, it's great. One one beep is good Okay, now that we've downloaded the program now we can run the program as many times as we want So what I'll do is I'll take this off and we'll try running this one on the floor I think okay because I'm not sure how far this is going to go So we'll put it down onto the floor And we will simply run the program. So what I need to do is I need to find the program here So if you want to look at this first just to see what the screen looks like Okay, you'll see here. It says my file. So I'm going to select my files. These are the software files So select here and you'll see this is called test three. So that's the program that we just downloaded Okay, so I'll point it this way and I'll select this and I'll say yes I'd like to go ahead and run this so what this should do is you should go forward It should turn 90 degrees. Okay go forward to turn 90 degrees and you should come back All of that. Okay. That that's what we've put in here. Okay Yeah, that that should be what happens. So should we move it here first? Maybe move the chair Okay, so we'll let this run and see what happens Okay, so there's a there's our first movement. It's going to go with three rotations. It's going fairly slow That was at 25 of the maximum speed Okay, and there's one of the motors that was the b-motor only Here's our turn It's going to have three rotations. It will now make the final turn Oh and then back back. Okay There we go. And that's that's a basic basic maneuvering operation So what you could do with this is you could set up an obstacle course Have the have the students actually go try to avoid an object and what you could do is you can measure Let them know how much how much of how big the pathways are and actually have them follow There is some issues with this because unfortunately the robot Does have difficulty going in a straight line. It depends upon the quality of the build Um and also making a 90 degree turn can sometimes be somewhat difficult and everybody's Even two robots that are built By two different groups may behave just slightly differently because of the spacing of the wheels and how much drag is being added But as long as they know in advance, it's it's usually fine So this is typically one of the first programs that we would have the students do is provide them some kind of an Obstacle course to avoid an object at a known location Okay Now if we wanted to do something where we didn't know what the environment looks like Maybe we'll try using the ultrasonic sensor And I see I've got a box over on the table And what we'll do is this time we'll have the robot go forward until it gets a certain distance away from the From the box and maybe what we'll do for fun. We'll try spinning the arm around a couple of times. All right Yeah, that's okay. Okay, but of course what we're going to do is we're going to wait until we get up to the box And then we'll try hitting something. Okay. I wonder if I have I wonder if I dare try to hit something Maybe we wouldn't try to hit something, but we'll stop. We'll spin the arm around. Okay So maybe you can imagine that there would be a soccer ball at the That's most of the box. Okay. Okay. So this time what I'm going to do Is you just take all of this program and you erase it. Okay, it's gone And we'll start a new program from scratch This time it's almost the same idea. We're going to turn on the move box So that the robot can start going forward, but this time I don't know how far away the box is going to be So what I'm going to do is I'm going to use this option here called unlimited Turns the turns the motor on and it leaves it off. Okay. Okay, and 75 is a reasonable speed. It's somewhat controllable Okay, it could be a little bit slower, but okay, we'll have some fun and watch it go faster But then what we're going to do is I'm going to introduce this thing here called a weight block Because when you turn the motors on it immediately goes to the next block So you can imagine that before we said move the robot forward three rotations What it does is the program waits here until all three rotations are done then goes forward So this time what we're going to do is we're going to introduce this weight block So this first of all turns on the motors and then it waits here And of course, I'm not interested in waiting for somebody to touch the robot I'm waiting for something called the ultrasonic sensor, which is the thing that looks like a pair of eyes To measure a distance and we're going to set this up to 30 centimeters is is fairly reasonable So when the robot reaches 30 centimeters away from this point right here not here because this is where the sensor is Then the rest of the program will continue and what I'm going to do is I'm going to use a move block And I'm going to simply stop stop the motor. So this turns the motors off So once we reach 30 centimeters from the box, we're going to turn the motor off And well, let's do one more thing. Let's add another weight block But this time I'm going to wait on time So what we'll do is we'll wait for one second so that one one entire second elapsed And then what I'll do is I'll bring over another motor block here But this time we'll try the a motor block which if you recall I fixed the motor block earlier so that this arm is connected to the motor block a and I don't think we want to turn it on limited but let's turn it on for one rotation So this should cause this part here to turn A full rotation now, of course when this turns a full rotation This might actually cause The actual swinging arm to turn around several times. That's okay Okay, and you see it's also going to wait for completion And of course I can spin this as fast as we can well for trying to hit a For trying to hit a football we probably want to turn this up as fast as we can So we'll see how fast the thing can actually spin. I'm not sure. I don't think I've tried this before but let's let's do it This is entertaining and of course once this is finished, then that's the end of the program. Okay. Okay. Let's try downloading this Okay, again, that's a good sign Now of course comes the moment of truth that we actually managed to write the program so it will work Okay, so you see here remember that we had no idea how far away the robot was from the box So again, what we'll do is we'll start this up One of the problems of course is starting starting this when we're measuring the ultrasonic sensor is quite often a lot of people Students and participants Conference is we'll stick their hand in front of it But of course that measures the distance and meaning So unfortunately what I had to do is I had to stick my finger over here and decide so I don't get in front of the sensor Okay, so good so far now it stops There we go And that's it Yeah, yeah, so should we should we try that again? Yeah, okay, uh, well here See there is a A red ball. Okay. Okay So let's put the red ball Watch me that far away That one first Okay, so we say about 30 30 centimeters This would be a good test. Oh, that's going to be fairly close to 30 centimeters There's there's a 30 centimeters. There's what the ball is. Oh, uh, I'm gonna have a problem. I'm gonna run over this thing Maybe make me better at the back here Just a little bit So it's almost the same distance as before Okay, so that's about 30 centimeters out. We'll put the ball here And we'll see whether or not we can actually get it. Yeah, okay So this time we'll start it this way one of the most difficult things is actually getting the robot aligned So it goes forward in the right direction So we'll see You never know it might work, but at least we'll see it happen. Okay. We'll move it a little bit closer to show you that I haven't pre-programmed where the sensor for this is it's actually is using the uh using the distance sensor So we'll give this a try. All right Okay Oh, it bumped into it so it missed. Yeah, it didn't sense it then. Uh, it didn't sense that because you see where the Ultrasonic sensor is looking for the ultrasonic sensor is looking for this Right. So unfortunately it went a little too far So if you want to try again, we can back it up and try one one final time Maybe it'll stop soon enough Oh Yeah, not quite long enough, but that was better than last time. Yeah, it was better than last time. Yeah Thank you so much for this lovely demonstration. Yeah, and we hope people know more about robotics and We raise awareness about this issue. Thanks a lot. Okay. Thank you