LEGO MINDSTORMS - Building Robots part 4 potx

40 316 0
LEGO MINDSTORMS - Building Robots part 4 potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

88 Chapter 5 • Building Strategies RCXs, motors, and sensors are definitely not cheap, so your best option is to install them in a way that makes them easy to remove without having to break your robot down into single parts. NOTE One good reason to make your RCX easily detachable is that you must be able to change batteries when necessary. The most common solution is to keep the RCX at the very top of your robot—this way you can also easily access the push buttons and read the display. Loading the Structure Even the most minimal configuration of a mobile robot has to carry a load of about 300g (11 oz): the weight of one RCX (with batteries) and two motors. Adding cables, sensors, and other structural parts, can easily push you up to about 500g (18 oz). Should you worry about this mass? Is its position relevant? The first factor you need to consider is friction.You should take all possible precautions to minimize it.This is especially true where the structure attaches to the wheels, because it is there that you transfer all the weight to the wheels by way of the axles.The wheel acts as a lever: the greater the distance from its support, the greater the resulting force on the axle. Such forces tend to bend axles, twist beams, and produce plenty of friction between the axle and the beam itself. For this reason, it’s important you keep your wheel as close as possible to its supporting beam. Figure 5.5 shows three examples: a being the worst case, with c the best. www.syngress.com Figure 5.5 Keep a Wheel as Close as Possible to Its Supporting Beam 174_LEGO_05 10/25/01 3:15 PM Page 88 Building Strategies • Chapter 5 89 We suggest you also support the load-bearing axles with more than a single beam whenever possible.The three examples shown in Figure 5.6 are better than those in Figure 5.5, with 5.6c being the best among all the solutions shown so far.The use of two supports, one on either side of the wheel, like on a bicycle, avoids any lever-effect created by the axle on the support, thus reducing the fric- tion to a minimum. The position of the RCX has a strong influence on the behavior of mobile robots. It’s actually the shape and weight of the whole robot that determines how it reacts to motion, but the RCX (with batteries) is by far the heaviest element and thus the most relevant to balancing load.To explain why balancing load is important, we must recall the concept of inertia.We explained earlier in the chapter that any mass tends to resist a change in motion. In some cases, to resist acceleration.The greater the mass, the greater the force needed to achieve a given variation in speed. The Acrobot model shown in the MINDSTORMS Constructopedia works under this same principle. If you have already built and tried it, did you wonder why it turns upside down instead of moving forward? This happens because the inertia of the robot keeps it in its present condition—which is stationary. Once power is supplied to the motor, the wheels try to convert that power into motion, accelerating the robot. But the inertia is so great that the force resorts to the path with least resistance, turning the body of the robot instead of the www.syngress.com Figure 5.6 Two Supporting Beams Are Better than One 174_LEGO_05 10/25/01 3:15 PM Page 89 90 Chapter 5 • Building Strategies wheels.After having turned upside down, the robot has the undriven wheels in front of it, preventing it from turning again, and now can’t do anything other than accelerate. You probably don’t want your robots to behave like Acrobot. More likely, you’re looking for stable robots that don’t lose contact with the ground.You can use gravity to counteract this unwanted effect, putting most of the weight further from the driving axles.There’s no need for complex calculations, simply experi- ment with your robot, running a simple program that starts, stops, reverses, and turns the robot to see what happens. Place the RCX in various positions until you’re satisfied with the result. Putting It All Together: Chassis, Modularity, and Load The following example summarizes all the concepts discussed so far in this chapter. Using only parts from the MINDSTORMS kit, we built the chassis shown in Figure 5.7. Its apparent simplicity actually conceals some trickiness. Let’s explore this together. www.syngress.com Figure 5.7 A Complete Platform 174_LEGO_05 10/25/01 3:15 PM Page 90 Building Strategies • Chapter 5 91 It’s built like a sandwich, with two layers of beams that contain a level of plates. It’s robust, because vertical beams lock the layers together. Notice that for the inner part of the robot, we used 1 x 3 liftarms instead of 1 x 4 beams.This way the top results in a smooth surface where one can easily place the RCX or other components. The load-bearing axles are two #8 axles that support both the outer and inner beams (#8 means that the axle is 8 studs long), while the wheels are as close as possible to their supports. The motors have been mounted with the 1 x 2 plates with rail, as explained in Chapter 3 (look back to Figure 3.4).They are kept in place by two 2 x 4 plates on their bottom (Figure 5.8), but by removing those plates you can quickly and easily take out the motors without altering the structure (Figure 5.9). You can also remove the pivoting wheel and the two main wheels in a matter of seconds to reuse them for another project (Figure 5.10).We should mention here that the pivoting wheel is quite special, since it’s what makes a two-wheeled robot stable and capable of smooth turns.The technique of making a good pivoting wheel has its own design challenges, of course, which we’ll explore in Chapter 8. The truth is that if you own only the Robotic Invention System, you prob- ably won’t have enough parts to build another robot unless you dismantle the whole structure. If you have more LEGO TECHNIC parts, however, you can leave your platform intact and reuse wheels and motors in a new project. www.syngress.com Figure 5.8 Bottom View 174_LEGO_05 10/25/01 3:15 PM Page 91 92 Chapter 5 • Building Strategies www.syngress.com Figure 5.10 …and the Wheels Figure 5.9 Removing the Motors 174_LEGO_05 10/25/01 3:15 PM Page 92 Building Strategies • Chapter 5 93 Now we can experiment with load and inertia. If you have the LEGO remote control, you don’t need to write any code. If not, we suggest you write a very short program that moves and turns the robot.You don’t need anything more complex than the following pseudo-code example, which will drive your robot briefly forward then backward, and make it turn in place: start left & right motors forward wait 2 seconds stop left & right motors wait 2 seconds start left & right motors reverse wait 2 seconds stop left & right motors wait 2 seconds start left motors forward start right motors reverse wait 2 seconds stop left & right motors Place your RCX in different locations and test what happens.When it is just over the main wheel axles (Figure 5.11), the robots tend to behave like the Acrobot and overturn easily. www.syngress.com Figure 5.11 Poor Positioning of the Load RCX Makes This Robot Unstable 174_LEGO_05 10/25/01 3:15 PM Page 93 94 Chapter 5 • Building Strategies As you move the RCX toward the pivoting wheel, the robot becomes more stable (Figure 5.12). It still jumps a bit on sudden starts and stops, but it doesn’t flip over anymore. Summary The content of this chapter may be summarized in three words: layering, modu- larity, and balancing.These are the ingredients for optimal structural results. Thinking of your robot in terms of layers will help you in building solid, well-organized structures. Recall the lessons you learned in Chapter 1 about lay- ering beams and plates and bracing them with vertical beams to get a solid but lightweight structure. A robust chassis comes more from a good design than from using a large number of parts. Modularity can save you time, allowing you to reuse components for other projects.This is especially important when it comes to the “noble” parts of your MINDSTORMS system—the sensors, motors and, obviously, the RCX— because they are more difficult and expensive to replicate.You should put this concept into operation not only for single parts, but for whole subsystems (for example, a pivoting wheel), which you can transfer from one robot to another. Balancing is the key to stable vehicles. Keep the overall mass of your mobile robots as low as possible to reduce inertia and its poor effects on stability. Experiment with different placements of the load, mainly in regards to the RCX, to optimize your robot’s response to both acceleration and deceleration.We will www.syngress.com Figure 5.12 Better Positioning Improves Stability 174_LEGO_05 10/25/01 3:15 PM Page 94 Building Strategies • Chapter 5 95 look more deeply into this matter in Chapter 15, when we learn how to build walking robots (where management of balance is a strict necessity). Unfortunately, these goals are not always reachable; sometimes other factors force you to compromise. Compactness, for example, doesn’t mesh well with modularity. Certain imposed shapes, like those used in the movie-inspired droids of Chapter 18, can force you to bypass some of the rules stated here.We aren’t saying they can’t be violated. Use them as a guide, but feel free to abandon the main road whenever your imagination tells you to do so. www.syngress.com 174_LEGO_05 10/25/01 3:15 PM Page 95 174_LEGO_05 10/25/01 3:15 PM Page 96 Programming the RCX Solutions in this chapter: ■ What Is the RCX? ■ Using LEGO RCX Code ■ Using the NQC Language ■ Using Other Programming Languages ■ Divide and Conquer: Keeping Your Code Organized ■ Running Independent Tasks Chapter 6 97 174_LEGO_06 10/26/01 1:47 PM Page 97 [...]... pioneering hacking of the RCX Kekoa patiently disassembled the LEGO firmware and documented all the routines and their calls, thus laying the foundations for the subsequent alternative firmware versions www.syngress.com 103 1 74 _LEGO_ 06 1 04 10/26/01 1 :47 PM Page 1 04 Chapter 6 • Programming the RCX Using legOS In 1999, Markus Noga started The legOS Project, the first attempt to write a replacement firmware... Follow_Line task to suspend line following, and communicate again when it can be resumed www.syngress.com 113 1 74 _LEGO_ 06 1 14 10/26/01 1 :47 PM Page 1 14 Chapter 6 • Programming the RCX In designing a multitasking application, you are required to move from a sequential, step-by-step flow to an event-driven scheme, which usually requires additional work to keep the processes coordinated.While sequential programming... www.syngress.com 1 74 _LEGO_ 06 10/26/01 1 :47 PM Page 103 Programming the RCX • Chapter 6 LEGO firmware NQC supported the new RCX 2 firmware version well before it was officially released in any LEGO product s It is multiplatform, both on the host side (it runs on PC, Mac, and Linux machines) and on the target side (it supports all the LEGO programmable bricks: RCX, Scout, Cybermaster) s It is self-contained.To... the readability, reusability, and testability of your code www.syngress.com 115 1 74 _LEGO_ 06 10/26/01 1 :47 PM Page 116 1 74 _LEGO_ 07 10/25/01 3:19 PM Page 117 Chapter 7 Playing Sounds and Music Solutions in this chapter: s Communicating through Tones s Playing Music s Converting MIDI Files s Converting WAV Files 117 1 74 _LEGO_ 07 118 10/25/01 3:19 PM Page 118 Chapter 7 • Playing Sounds and Music Introduction... making our code more readable: #define BEAT 50 #define A3 220 #define A4 44 0 PlayTone(A3, BEAT); Wait(BEAT); PlayTone(A4, 2*BEAT); Wait(2*BEAT); You can also patiently define a table of constants for all the notes, so you can reuse it in many different programs: #define C1 33 #define Cs1 35 #define D1 37 #define Ds1 39 // #define C4 262 #define Cs4 277 // #define B8 7902 We coded, for example, the D# note as Ds... the program execute A Small Family of Programmable Bricks The RCX belongs to a small LEGO family of programmable bricks.The first to appear on the scene was the Cybermaster, a unit that incorporates two motors, three input ports, and one output port It shares with the MINDSTORMS www.syngress.com 1 74 _LEGO_ 06 10/26/01 1 :47 PM Page 101 Programming the RCX • Chapter 6 devices the ability to be programmed... graph the status of the input ports, and more www.syngress.com 105 1 74 _LEGO_ 06 106 10/26/01 1 :47 PM Page 106 Chapter 6 • Programming the RCX Divide and Conquer: Keeping Your Code Organized Up to this point the few programming examples you met were written in a sort of pseudo-code very close to plain natural language.The use of pseudo-code allows the programmer to “play computer” and understand what the... MINDSTORMS fans and professionals at the Massachusetts Institute of Technology (MIT), we built a Tic-Tac-Toe-playing robot—a version of which you’ll see in Chapter 20—that used different musical themes to inform its human opponent about the result of the game Playing Music Sometimes a sound pattern can give your creatures a specific character Could you imagine a silent reproduction of the famous R2-D2... Chapter 4, explaining that keeping your program independent from particular cases is a good general programming practice In this example, it means you should not write the light sensor thresholds into the code, but rather give your robot the possibility to read them from the environment, and this is what you have declared the floor and line variables for www.syngress.com 1 74 _LEGO_ 06 10/26/01 1 :47 PM Page... write your code on the PC, then send it to the RCX through the infrared interface.The MINDSTORMS software on the PC side, called RCX Code, translates your program (made of graphical code blocks) into a compact form called bytecode.The RCX receives this bytecode via the IR www.syngress.com 99 1 74 _LEGO_ 06 100 10/26/01 1 :47 PM Page 100 Chapter 6 • Programming the RCX interface and stores it in its RAM.When . View 1 74 _LEGO_ 05 10/25/01 3:15 PM Page 91 92 Chapter 5 • Building Strategies www.syngress.com Figure 5.10 …and the Wheels Figure 5.9 Removing the Motors 1 74 _LEGO_ 05 10/25/01 3:15 PM Page 92 Building. Improves Stability 1 74 _LEGO_ 05 10/25/01 3:15 PM Page 94 Building Strategies • Chapter 5 95 look more deeply into this matter in Chapter 15, when we learn how to build walking robots (where management. so. www.syngress.com 1 74 _LEGO_ 05 10/25/01 3:15 PM Page 95 1 74 _LEGO_ 05 10/25/01 3:15 PM Page 96 Programming the RCX Solutions in this chapter: ■ What Is the RCX? ■ Using LEGO RCX Code ■ Using

Ngày đăng: 10/08/2014, 04:22

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan