Tuesday, June 9, 2015

Transcript - Hands-On Robotics (cont.)

Class: Informatics, Computing, and the Future
Instructor: Dan Berleant
Transcriber: Brooke Yu
Date: Tuesday, April 16, 2013

Professor:  Here's a diagram reminding you how to plug those in with the arrow facing outward, just so you know.  So you weren't here to see it before Collin.  Did you get it working? 

Male Student:  I mean, the lights are on. 

Professor:  Alright, great.  Just go ahead and grab a robot.  Also, robots are fun, maybe not as much fun as your next homework.  But they're becoming less time consuming so you can work on your project. 

So take a look at the homework to see if you have any questions. 

Alright, so those who weren't here last time might have to rely on your neighbors or ask for help in this exercise, but I think you'll be able to pick up the essentials from last time. 

So any questions on the next homework?  Anything?  Projects?  Anything?  Let's take a look at what we have going on.  Next time we already have four people signed up for presentations, so next time we'll just have presentations. 

The date after that, there's two people who have to give presentations.  If we have time left over, we might talk more about robots.  We might not use the real robots because of time, but we'll talk about them.  This is Thursday [On board.]  

Next Tuesday, a week from today.  Then a week from Thursday, three presentations.  Then way off on the 30th, three more presentations.  There's two people in the class with the initials "R.M."  On the last day of class, two more presentations are scheduled. 

There will not be a final exam, and you don't have to show up unless you're making up assignments.  You can hand in your project via email.  If you're behind on the homeworks, you have to come the day of the final to make up assignments.  Any questions?  We're getting close to the end now, so I want everyone to be reasonably clear on things. 

To review a couple of things- you've already got your robots hooked up.   Does anyone remember what the first number that you send to the robot is?

Male Student:  121? 

Professor:  Close, 128.  And what does it mean? 

Male Student:  Like "recognize me" or something like that. 

Professor:  Yeah, it's like the start command.  Okay, so the first one is 128.  The second is 131 or 132.  131 gives the robot some control over its fate, so if you tell it to roll over the edge the table it'll stop.  132 gives you full control over the robot's fate.  We're going to deal more with 131 today. 

If you want to run a program, you first type 128 131 or 132. 

128 is start.  131 means "take partial command."  And 132 is "take full Command."  Any time you tell the robot to do anything, you have to preface it with these. 

Male Student:  Do you do these individually or put them all on the same line?

Professor:  You can put them all on the same and it should be fine. 

So if you try it now- try 131 this time.  The little light should go off meaning that you haven't told any lights to be on, okay? 

So everybody send these numbers and make the light go off. 

Is everybody's little light off?  Okay. 

So last time we controlled the lights.  Last time we made it do music and stuff too.  So let's focus on motion today

What makes a robot a robot?  It can move!  Once you set the initialization and take partial command, you can tell it to move.  Here's a movement command.  Alright, someone made it work.  Be ready to grab it because it'll break the cord or mess something up if you make it go too far because the wheels grip pretty well. 

Try this command- it's five different numbers which I'll explain after you get it working. 

And help your neighbored out if they weren't here last time. 

If you run into problems and it doesn't work, just raise your hand. 

It'll break your computer if you're not careful. 

Male Student:  It doesn't work with 131 for some reason. 

Professor:  Okay, let's check it. 

Male Student:  Oh, it was turned off. 

Professor:  Aha.  That's easy to do.  Power cycle it if it doesn't work.  Turn it off and turn it back on. 

Okay, let's see what's going on here with that motion command.  As you know from last time, you know, as a programming language it's not very user friendly.  So 137 is the command for going- or driving.  It has four arguments to it which is why this line has five numbers- the command and its four arguments. 

So 137 says drive.  The next two numbers are two parts of one argument- 0 100 says go 100 mm/sec.  So this is the one's place and this is the 256th place so if you have 100 here, that's 100, so 0 100 says go 0 times 256 + 100 mm/sec. 

And then there's two more bytes.  This is the direction, except it's a special direction.  This is very arbitrary.  128 0 means go straight. 

Male Student:  If you put 100 100, it likes to go fast. 

Professor:  Yeah.  If you put 100 here and 100 here, it should be 100 times 256 + 100 mm/sec.  But there is a maximum speed. 

Male Student:  What's the max speed? 

Professor:  Well, I don't know.  I have a document that says.  It's not outrageous.  Okay, so play around with that.  Try to find not the fastest- well, you can if you want.  But try to figure out the slowest speed- you'll be able to notice when it won't go at all.  Try to figure out the slowest speed to make it go. 

So while you're figuring that out, I'll circulate and help make sure everyone is on the right track. 

Professor:  Yes, you can go backwards. 

How about you?  How are things going? 

Alright. 

Professor:  Okay, so someone got it to go in circles.  How did you do that?

Male Student:  Change 128 to 0. 

Professor:  Since you mentioned it, I'll try it here.  I don't know what the numbers are for going backwards.  How slow could you make it go? 

Female Student:  10

Professor:  What happens when you put a 9 here? 

Male Student:  8 works for me. 

Professor:  Alright, so your robot would handle 8 mm/sec, and others wouldn't even handle 9.  I guess that's because the motors have manufacturing variability.  Anyone get it below 8? 

Female Student:  Mine goes on 8, but it won't go on 7. 

Professor:  What else?  How many people have tried the 158 command?  A couple people did.  Let's talk a little about that so it'd be nice to make so you could send the go command and not have it go until you're ready for it to go.  One way to do that is the 158 command which is a "wait Command."  It tells it to wait for something.  There are several options for this. 

Option 5 is a bump on the bumper.  If you type 158 5, then the robot will not do anything until you tap it on the bumper.  The bumper is right here, so if you send the 158 5 command, it'll wait until you bump it. 

So here, I've strung this together with a go command.  158 5 says wait until you bump it, then 137 says go.  So this robot won't do anything until you tap the bumper.  When you tap it, it'll start going. 

At the end of class today, it'd like to have everyone bring their robots down here and tap the bumper without the cord attached then have it do something. 

Male Student:  So the program will be there until you turn it off? 

Professor:  Right, it'll be there until you turn it off. 

Male Student:  So you can write something to it, unplug it, put it on the ground, and it'll do it? 

Professor:  Yes.  You can also pull the plug out while it's doing it and it'll keep going, but please don't do that. 

Questions? 

Okay.  So give this a shot and we'll go on from there. 

While you're experimenting, I'm going to make a note on the board. 

How are things going over here? 

Female Student:  Good. 

Professor:  Things working out? 

Male Student:  Yep. 

Male Student:  Mine says "battery current 0." 

Professor:  I don't think so, because the light is on. 

Male Student:  Okay. 

Professor:  A lot of people are realizing that if the robot is a little bit off the table, this cliff sensor will be activated and it won't go.  The robot will be afraid to go. 

Good?  Alright. 

Professor:  Okay, let's see what else we've got here. 

Alright, well, things get even more complicated then this.  So here's a small example of a complete program.  Let's analyze what it does. 

Actually, here's a new command, 156, which I'll explain, and 157 and 152.  Let's see what they do. 

152 is a script defining command.  This just means we're going to define a longer program.  And how long is it going to be?  It's going to be 17 bytes.  So the first number after 152 is the length of the program. 

So it's 17 bytes, and here are the 17 bytes.  It's 17 bytes long. 

Okay, so what is in these 17 bytes?  The first five bites are our go command.  It says drive 44 mm/sec and drive straight . if there was a 1 here instead of 0, it'd be 3 meters per second. 

After the go command, there's a 156 command, which has 2 arguments.  It says wait until you go a certain distance- until you go 144 millimeters.  This is basically going to drive until it goes 144 millimeters and then it'll go on to the next part of the program.  So go 144 millimeters, then go again... notice instead of 128 0, we have... sorry, instead of 128 0, we've got 0 1 for the last two arguments. 

128 0 means go straight.  0 1 means spin counterclockwise.  So it'll go 144 millimeters, then it's going to go again, but this time with a 0 1, so it'll spin counter clockwise. 

Then it's going to execute a 157 command which is another wait command, which says "wait until you've gone 90 degrees."  Then 153 says "repeat the Script."  So 153 is a loop command.  Let's review

It goes 44 mm/sec.  It waits until it goes 144 millimeters, then it'll spin counterclockwise until it has gone 90 degrees, then it will go back to the beginning so it goes straight again for 144 millimeters.  

So it'll go for 144 millimeters, then it'll spin counterclockwise 90 degrees, go another 44 millimeters, spin counterclockwise 90 degrees, and it'll go in a square.  If 144 millimeters is too much for your table, you can make it go 10 millimeters.  If you knew how to do the math, you could make it go in a triangle or a pentagon or whatever you wanted to do. 

152 says define a script, 153 says run a script.  In essence, that's the script- go and turn, then it repeats by going back to the beginning. 

To start it out, you have to do your 128 131.  You might have to put it on the floor for this, or use a really small square- make it go 10 millimeters instead of 144.  But you can experiment with it. 

You have to run the script the first time.  All this does is define the script with the 152 command.  To run it the first time, you have to send a 153 to run the script.  So there's a 153 here which says to run it again, but you can't repeat it unless you've already run it once so you have to use 153.  If you want, you can wait for a bump and then run the script. 

I know this is a lot.  Just experiment with it and see what you can do. 

If the cord is getting really twisted, you might want to unplug it and untwist it, then plug it back in. 

While you're experimenting, I'm going to write the commands we've been using on the board for reference. 

I've written all the commands we've looked at so far on the board. 

Questions?  Raise your hand if you have a question and I'll try to come by and help you.  No questions? 

The next step them is for you to connect all of these commands together.  Make a script so that you can bump the bumper to run your program so we can bring them to the front of the class.  

If you remember from last time, you can make it go with script, make it play music....

How are this going over here? 

Female Student:  I don't think mine is working. 

Professor:  How are things going with you?  If you're sending a 131 command, you should make it stop by just picking up the side of it.  Are you using 131 or 132? 

Okay, yeah.  So if you just pick up the side the cliff sensor will activate. 

If anyone wants to see what other commands are available, raise your hand and I'll bring the document around.  We only have 25 minutes left.  So work on a script you can show the class at the end.   Try experimenting to make it do something after you push the bumper.  We'll spend the last 7 or 8 minutes of class doing that.  So you have about 17 minutes left to develop your script. 

Be really careful the those cables because they bend really easily.   We've already had a couple bend. 

Male Student:  So to add more bits, does that have to match the rest of numbers? 

Professor:  The 17?  Yes. 

Male Student:  Does that count spaces or just numbers? 

Professor:  Just numbers.  If you put an 18 there but you only have 17 bytes, it won't go until it gets the 18th number. 

Professor:  Not really.  There's no actual stop command.  You just have to pick up the edge or something. 

Male Student:  Like the song thing.  Can you not just add to the front of this and then whatever you already have? 

Professor:  Yeah, you could run the song and then do a 153. 

Male Student:  Well, can you look at this? 

Professor:  I guess now is a god time to make sure you can test whatever you have it to do so you can bring it up to the front and it'll work.  Make sure you can tap the bumper and it'll do something.  Then in a couple of minutes we'll do the demos. 

Alright, if you're ready to demo it, put it up here. I realize that just spending a few minutes in one class is not enough to get it to water your plants, but that's okay. 

Are you ready?

Female Student:  One more try. 

Professor:  Haha, okay. 

If you're using a 131 command, I don't think it'll let you move it or pick it up, so you might have to use a 132 command maybe we should just demo them at our seats

Alright, let's demo them at our seats. 

Do you want to get up and watch each others demos? 

Male Student:  I'm working on mine. 

Professor:  Okay, just show me then. 

Once you've shown your demo you can put them back and you can go. 

Female Student:  I got it to go at one angle, but I couldn't figure out how to turn it. 

Okay.  Oh, it went fast and then slow. 

So how did you make it- did you have a wait? 

I see.  Cool, okay. 



No comments:

Post a Comment