lego robotics(programming)

19
Stage 2: Programming Robotics: Lego Mindstorm NXT

Upload: slewell

Post on 18-Dec-2014

15.115 views

Category:

Sports


0 download

DESCRIPTION

Programming NXT Robots

TRANSCRIPT

Page 1: Lego Robotics(Programming)

Stage 2: Programming

Robotics: Lego Mindstorm NXT

Page 2: Lego Robotics(Programming)

Time to Program!

You just built your starting robot! Congrats, now it’s ready for action. Oh wait, it’s just sitting there isn’t it…

That’s because you didn’t give it a program yet, therefore, it doesn’t know what to do yet!

So let’s learn how to program!

Page 3: Lego Robotics(Programming)

Change How You ThinkRemember when I told you the most important

thing you have to do it change how you think? Well now is when you learn why.

To program, you have to understand how to think like a computer. And that’s to be able to think with algorithms, which is the computers thought process. You take for granted how easy it comes for people to be able to think and then act off that impulse, so we’re going to make you do an exercise to learn how to think like a programmed robot.

Page 4: Lego Robotics(Programming)

Stop and get programmedWe are going to put you in groups of two. One

volunteer to be the robot, the other is the programmer.

Now blindfold the volunteered robot, arrange an obstacle course in our room, and the programmer verbally direct the “robot” through it. (i.e.“Take 3 steps, stop, turn left 90 degrees, stop, take 4 steps, stop, etc.”)

And the robot can’t feel around, keep arms to the side.

Page 5: Lego Robotics(Programming)

What did you learn?You probably noticed that it was harder to get

around when you couldn’t think for yourself as the robot. And if you were the programmer, you must have had to think pretty detailed on what directions to give and how.

That’s the point. Robots can’t think for themselves, they need exact directions. When you program your robot you are going to need to know where you want it to go, how far, what direction, when to turn, when to stop, etc.

Page 6: Lego Robotics(Programming)

Programming with NXT

Now that your mindset is in programmer mode, let’s Mindstorm! (corny pun)

Lucky for you, NXT programming is not that complicated.

Page 7: Lego Robotics(Programming)

BasicsThe goal of this week is for you to learn how to

program on your own and be as creative with it as you want. So we aren’t going to give a strict guideline on how to program your robots, the goal is to learn the basics and program your robot anyway you see best!

Once you start learning the basics you might discover better ways to program than the other teams or the instructors, don’t hesitate to be creative.

Page 8: Lego Robotics(Programming)

MovementYou make NXT

programs like you are putting Lego blocks together.

Movement blocks are one of the most used actions in programming. You can decide what servo to activate with them, direction, and for what duration. (Duration will be important later)

Page 9: Lego Robotics(Programming)

Sound Blocks

When you activate these blocks you can make your robot play a sound from the files in the NXT programer

Page 10: Lego Robotics(Programming)

SwitchWhen you need to program

a function for a sensor, you use the switch function. It allows you to program exactly what the robot should do if a sensor is tripped.

Example: Touch sensor trips, program to move back 2 rotations, then turn right, continue to next function.

Page 11: Lego Robotics(Programming)

Wait buttonThe wait function

is necessary for when you want your robot to act until it trips a sensor. So if you want the robot to act a certain way when it trips a certain sensor, you will use the wait botton.

Page 12: Lego Robotics(Programming)

Loopty Loop

Loops are very handy, they contain a program you want to repeat. It can repeat once until forever if you like.

Page 13: Lego Robotics(Programming)

Stop: It has to at some point!The most important thing you need to learn in

programming is how to stop! We don’t get paid enough to do this forever!

You will want to program your robot to stop at some point.

Remember that you can program the stop function into a loop or sensor action.

Page 14: Lego Robotics(Programming)

Making the DistanceRemember the movement blocks? When you

want to program your robot to go a certain distance, how do you know how long to make it run?

Well, you don’t. The fact that any robot you make can move different than other robots means that you have to find out how far it will go on your own.

We have a handout ready to help you write down your data.

Page 15: Lego Robotics(Programming)

The reason we suggest using “rotations” instead of “seconds” to run the movement blocks is because it is easier to figure out how many rotations it takes to go a certain distance. Basic math will figure out longer distances.

Let’s go to the Programming Handout

Page 16: Lego Robotics(Programming)

Stage 3Now that you have

collected your data on distance, you can accurately program your robotic system around our obstacle course. The course floor plan will vary depending on what location you are in, but it will look something like this.

Start

Finish

(Obstacle1)

(Obstacle2)

(Obstacle3)

Page 17: Lego Robotics(Programming)

Competition We will have a friendly competition to see what

team has programmed their robot with more skill. The team that completes our course with the best time wins.

However, when the competition is complete, you can readily get back into teams and begin to create more robotic creations.

The point of all three stages was to teach you how to create and program NXT robots, so be creative and have fun!

Page 18: Lego Robotics(Programming)

Additional DesignsThere are some additional designs in the

Lego NXT program, but if you want to find designs off the internet go to the following sites:

www.nxtprograms.com

http://www.thenxtstep.blogspot.com/

http://www.nxtasy.org/

Page 19: Lego Robotics(Programming)

Hope You Have Fun!Good Luck!