Lego Robots by huangyuerongp4

VIEWS: 193 PAGES: 10

									Lego Robots
Introduction Designing, building, and testing are three important stages of engineering. All three of these stages will be explored in this project. Designing involves exploring ideas, keeping in mind the specifications of the project, to come up with a workable model for the project. Once the model is settled on, it must be built and tested. Building and testing often reveal design flaws which must be reworked. This process continues until a working prototype is developed. Each project will involve two design phases: the robot itself and the software that runs it. For the Roverbot, the goal is to produce a Lego robot that is capable of following a line and evading objects in its path,and finding the line again after evading the obstacle. For the Acrobot, the goal is to produce a robot that performs with unique moves in response to being tagged by a laser. The challenge for the Inventorbot is to write a program that allows the robot to toss an object to a target, based on a time interval or a sensor stimulus, and also allows the robot to modify its toss to the right or the left for successive tosses. Supplies Lego Mindstorms kit Computer 6 AA batteries Resources for Design Ideas Ideas for your robot can be found in the Lego instruction guide or on the internet. Here are some websites worth taking a look at for ideas: http://mindstorms.lego.com/eng/default.asp http://mindstorms.lego.com/eng/inventions/default.asp http://www.marioferrari.org/lego_mindstorm.html http://constructopedia.media.mit.edu/ ftp://cherupakha.media.mit.edu/pub/people/fredm/artoflego.pdf

Other things to consider There are two properties of motors relevant to this project: rotational velocity or turning speed, and torque which is the rotary force of the motor. Lego motors tend to have a high rotational velocity and a low torque. There are two ways to slow down the rotational velocity of the motor. One is by reducing the power; the other is by using gears. In any system such as this, the law of conservation of energy applies. Because of this, when the output of the motor is slowed by reducing power the torque is also reduced. However, when the output of the motor is slowed by using gears, the energy that went into the rotational velocity is conserved by increasing the torque. Gears can also be used in combination. Using different sizes of gears in combination can increase the torque. Using gears set at an angle to each other changes the direction of rotation, and using gears side-by-side transfers the output energy to another location. These can all be useful in robot design. The placement of the light sensor is also a design detail to consider. When used for following a line, would the light sensor be more effective in the front of the vehicle or in the back? Is there an ideal height for the sensor? A third thing to consider is the construction of the bumper. A bumper can be constructed with either one or two touch sensors. A bumper with only one touch sensor is easier to construct and easier to program, but it cannot distinguish between an obstacle on the left and an obstacle on the right. A bumper made with two touch sensors can make that distinction and be programmed to respond differently to each situation. What are the advantages and disadvantages of using gears to change the output of the motor? Using power settings?

Would it be better to place the light sensor at the front or the back of the robot? Why?

What are the advantages and disadvantages of a two-sensor bumper?

What ideas did your team consider and why?

Did you modify the design? How?

Programming Instructions The main menu of the Lego software looks like this:

The Tour takes about three minutes and shows some interesting ideas. Missions has three subcategories: Training missions, Challenges, and Pro Challenges. Training Missions is an animated programming tutorial. It is very good for those who have little or no programming experience. Challenges and Pro Challenges provide programming practice using specific robots from the instruction guide. Sample programs can be accessed at the end of the challenges.

Programs includes the subcategories: Pick A Robot, Freestyle, and Vault. Pick A Robot allows the user to write programs for specific robots from the instruction guide. Freestyle is an open work area for writing programs. Vault contains stored programs that can be opened and edited from there. Library contains the subcategories: Sample Programs, Programmopedia, and Building Tips. Sample Programs are a collection of sample programs. Programmopedia is a non-animated programming tutorial. For those with programming experience, this section provides some specifics of how to use this particular software for writing programs and may provide all the help that’s needed. Building Tips contains several categories of building tips including techniques for building strong robots, gear ratios, and some programming hints. The workspace for programming has a menu bar across the top, a tool bar along the side, and a large work area. The Menu Bar  File Menu o New o Open o Save o Save As o Exit  Edit Menu o Copy (actually both copy and paste functions in one) o Add a Variable o Delete a Variable o Add a Comment  Settings Menu o Download to Slot (Slots 2-5 are available to download programs into) o Switch to Freestyle o Smart Tasking o Show Smart Tasking o Edge Scrolling  Help Menu o What’s this? o Table of Contents o Troubleshooter o How to Learn More o About Robotics Invention System 2.0 The Tool Bar  Big Blocks – divided into categories based on type of robot o Roverbot

o

o

o o o o o o o

 Forward  Turn Left  Turn Right  Backward  Spin Left  Spin Right  Zig-Zag  Shake  Dance  Random Move  Find Light  Find Dark Acrobot  Forward  Turn Left  Turn Right  Backward  Spin Left  Spin Right  Zig-Zag  Shake  Dance  Random Move Inventorbot  Rotate Left  Rotate Right  Move Arm  Shake  Random Move Vault (The next 6 categories, Vault through Arm, contain similar blocks which probably won’t be needed for this class.) Fred Artbot Delivery Sorter Arm Global  Play Note  Play Tune  Motor Control  Stop Motors (set brake or allow to coast when stopped)



Small Blocks – allows fine-tuning of the program o Power  On  On For

  

 

 Off  Set Power  Set Direction  Reverse Direction o Sound  Beep  Tone  Mute Sounds  Un-Mute Sounds o Comm  Send IR Message  Clear IR Message  Display Value  Display Clock o Variable  Set  Add  Subtract  Multiply  Divide  Make Positive  Make Negative o Reset  Reset Light  Reset Timer o Advanced  Set Priority (used if two sensors are triggered at the same time)  Global Reverse  Global Set Direction  Connect Power  Disconnect Power  End Program My Blocks – create and save your own blocks Wait o Wait For (a controlled pause) o Wait Until (until a specific sensor event) Repeat o Repeat For (specify number of repetitions) o Repeat Forever o Repeat While (while sensor event is true) o Repeat Until (until sensor event is true) Yes or No – branch function, if sensor event is true do something, if false do something else Sensors o Touch o Light

o o o o o

Temperature (not included) Rotation (not included) IR Message Timer Variable

Like the Legos themselves, the program consists of “blocks” of instructions that are fastened together. Every program will start with a main program block. This block will have the name of your program and allow you to take a look at motor direction, power level, and the status of the light sensor, if used. Other blocks of program instructions are attached beneath or beside this block. To add a block simply click on it on the tool bar, drag it to the proper place, and click to attach it there. The tab on the right side of the block allows adjustments to be made to the settings of the block. For example, the

Forward block has a default setting of 1.0 seconds. It can be increased or decreased by clicking the right tab and making the appropriate adjustments. Once the program is ready to test, make sure the robot is turned on and in position to receive data from the IR tower. Then click on Download. To run either click on Run on the screen, or the green button labeled “run” on the RCX. To stop either click on Stop on the screen, or click the green “run” button on the RCX again. If the program needs adjustments, make the adjustments, download it, and test it again.

Suggestions for Testing Test as many different variables as you can think of in an increasing order of complexity. Does the robot follow the line? Can it evade obstacles on the straightaway? Can it evade obstacles on the curves? Can it find the line again after going around an obstacle? Would it be better to always turn to the inside of the track so it is easy to find the line again, or turn right or left based on where the obstacle is located? Are there any other possible problems you could run into that should be tested? These are some of the things to consider when testing your robot. What kinds of tests did your team run?

Did you encounter any problems?

What solutions did you come up with?

Describe the performance of your robot on the day of testing.

Programming Concepts In a simplified way, Lego programming contains many of the basic programming structures common to all programming languages. Repeat For is the equivalent of a For loop. Repeat Forever is an infinite loop. Repeat While is the equivalent of a Do-While loop. Yes or No is a branch function. It is equivalent to an If-Else statement. Wait For is comparable to an algorithm used to pause the program. It does nothing for a given amount of time, then continues the program. Lego programming in many ways is a simplification of Object Oriented Programming. Object Oriented Programming is a type of programming that emphasizes reuse. Algorithms are written in packages called classes. If an algorithm needs to be used in more than one place in a program, the class can be called and the code does not need to be rewritten. Calling a class creates an object. When an object is created space in memory is allocated for it according to the format defined in the class. A class is like a template from which multiple copies can be made. An object is one of those copies. Object Oriented Programming also makes use of inheritance. Similar classes can be created using older classes without having to rewrite blocks of code. The older code is used with only the changes having to be coded. In this way, the functions of the older class get inherited by the new class without having to rewrite the code.

In Lego programming, the Big Blocks, Small Blocks, and My Blocks represent classes. Inside each of these blocks is a series of programming instructions needed to perform the desired task. When one of these blocks is attached to a program, it creates an object. A copy of that set of instructions is placed in the program to perform that task when the program is run. Sensor input allows for user interface and event handling. Event handling is a set of instructions within the program that tells it how to respond to an outside event, such as a touch sensor being pressed or a light sensor sensing light. On a computer, an event handler might respond to a mouse click on a button or a keyboard input. Wait Until is also an event handler. It does nothing until a specified event occurs, then it responds to it. Classes and event handling are two ways Lego programming is similar to Object Oriented Programming. The following illustration shows a Lego program. It doesn’t do anything significant, however it does illustrate basic programming concepts.

Written in a simple programming format, this program would look like this: Forward (1.0); Turn Left (1.0); If (Touch 1) { While (Touch 3) { Dance (1); } end While; } If Pressed (Touch 1) { // Creates an object of the class Forward, sets seconds = 1.0 // Creates an object of the class Turn Left, sets seconds=1.0 // If Touch sensor on port 1 is pressed, then … // While Touch sensor on port 3 is pressed, do … // Dance one time.

// If the touch sensor on port 1 is pressed …

Wait (1.0); // Wait 1.0 second For x = 1 to 3 // Beeps 3 times { Beep (1); X = x + 1; } If (Bright 2) // If Light sensor on port 2 is Bright … { Zig-Zag (1); // Zig-Zag one time } Else // If Light sensor on port 2 is not Bright … { Spin Right (1.0); // Spin Right one time } }


								
To top