p all i imck >Э1 N! w Ш i ш 1 I Vf I \ w,m; цриазд i IF 4 ifipm>v*' HUM V* %тл mk sioaoy DNicning
Contents Foreword Preface xxiii xxv Chapter 1 Understanding LEGO Geometry 1 Introduction 2 Expressing Sizes and Units 2 Squaring the LEGO World: Vertical Bracing 4 Tilting the LEGO World: Diagonal Bracing 6 TECHNIC Liftarms: Angles Built In 9 Summary 11 Chapter 2 Playing with Gears 13 Introduction 14 Counting Teeth 14 Gearing Up and Down 15 Riding That Train: The Geartrain 17 Worming Your Way:The Worm Gear 19 Limiting Strength with the Clutch Gear 20 Placing and Fitting Gears 23 Using Pulleys, Belts, and Chains 30 Pulleys and Belts 31 Chains 33 Making a Difference: The Differential 35 Summary 38 Chapter 3 Controlling Motors 41 Introduction 42 Pacing, Trotting, and Galloping 43 Internals of NXT Servo Motor 47 Mounting Motors 48 Wiring Motors 51 Using Power Function Motors with the NXT 52 Controlling Power 54 Detecting Motor Overload 55 Braking the Motor 56 xiii
xiv Contents Coupling Motors 57 Summary 59 Chapter 4 Reading Sensors 61 Introduction 62 Digital Sensor Ports with the PC (Inter-Integrated Circuit) Interface 62 The Touch Sensor 65 The Pight Sensor 71 Measuring Reflected Pight 73 Pine Following 74 The Ultrasonic Sensor 77 Proximity Detection 79 The Servo Motor Encoder (Rotation Sensor) 79 Sensor Tips and Tricks 83 Emulating a Rotation Sensor 84 Connecting Multiple Sensors to the Same Port Multiplexing 86 Other Sensors 88 The Passive Infrared Sensor 89 The Pressure Sensor 90 The Acceleration Sensor 92 The Compass Sensor 94 The NXT-to-RCX Communication Bridge 95 The Color Sensor 96 Summary 98 Chapter 5 What's New with the NXT? 99 Introduction 100 Notable Enhancements 100 Studless Construction 100 Electrical Connectors 100 Rechargeable Battery Pack 100 Flash Memory 101 Multiple Types of Sensors 101 The NXT File System 101 File-Handling Functions 102 Using File Space Efficiently 103 The PCD Screen 103
Contents xv Games 104 Digital Interfaces and Bluetooth 105 Bluetooth Communication 106 A Surveillance Robot Using NXT and Bluetooth....106 A Bluetooth-Based Remote Controller 107 Spatial Motion Controllers 108 PC for Spatial Motion Controllers 109 Future Possibilities 109 An NXT Robot Controlled from a Web Server 109 NXT Puppet Show 110 GPS and the NXT 110 Summary Ill Chapter 6 Building Strategies 113 Introduction 114 Studless Building Techniques 114 Maximizing Modularity 118 Loading the Structure 121 Putting It All Together: Chassis, Modularity, and Load 124 Hybrid Robots: Using Studless and Studded LEGO Pieces.129 Summary 131 Chapter 7 Programming the NXT 133 Introduction 134 What Is the NXT Programmable Brick? 134 MINDSTORMS:A Family of Programmable Bricks..136 Introduction to Programming the NXT Brick 137 How Does a Program Run? 138 Using NXT-G 139 Using RobotC 141 Using Other Programming Languages 142 Using NBC/NXC 143 Using pblua 144 Using LeJOS NXJ 144 Using Other Programming Tools and Environments...144 Code Samples 145 Code Sample: A Simple Clock 145 Code Sample: Following a Line 151 Running Independent Tasks 157
Summary 158 Chapter 8 Playing Sounds and Music 159 Introduction 160 Communicating through Tones 160 Playing Music 161 Converting Sound and Music Files 163 MIDI and MIDIBatch 163 WAV2RSO 165 The Sound Sensor 166 Summary 167 Chapter 9 Becoming Mobile 169 Introduction 170 Building the Simple Differential Drive 170 Keeping a Straight Path 172 Using Servo Motor Encoders to Go Straight 172 Using Gears to Go Straight 173 Using Casters to Go Straight 177 Building a Skid-Steer Drive 180 Building a Steering Drive 183 Building a Synchro Drive 187 Other Configurations 191 Summary 192 Chapter 10 Getting Pumped: Pneumatics 193 Introduction 194 Recalling Some Basic Science 194 Pumps and Cylinders 195 Controlling the Airflow 200 Building Air Compressors 202 Building a Pneumatic Engine 206 Summary 210 Chapter 11 Finding and Grabbing Objects 211 Introduction 212 Operating Hands and Grabbers 212 Using Pneumatics to Drive Your Grabber 218 Finding Objects 222 Positioning the Grabber 225 Distinguishing Objects and Obstacles 225
Summary 228 Chapter 12 Doing the Math 229 Introduction 230 Multiplying and Dividing 231 Averaging Data 233 Simple Averages 233 Weighted Averages 237 Using Interpolation 240 Understanding Hysteresis 243 Higher Math 245 Summary 248 Chapter 13 Knowing Where You Are 249 Introduction 250 Choosing Internal or External Guidance 250 Looking for Landmarks: Absolute Positioning 251 Following the Beam 255 Map Matching Using Ultrasonic Sensor 259 Combining Compass Sensor to Increase Precision 260 Measuring Movement: Relative Positioning 260 Measuring Movement: Acceleration Sensor 262 Summary 263 Chapter 14 Classic Projects 265 Introduction 266 Exploring Your Room 266 Detecting Edges 269 Variations on Obstacle Detection 270 Following a Line 271 Further Optimization of Line Following 277 Summary 278 Chapter 15 Building Robots That Walk 279 Introduction 280 The Theory behind Walking 280 Building Legs 286 Building a Four-Legged Robot 288 Building a Six-Legged Steering Robot 291 Designing Bipeds 296
Interlacing Legs 297 COG Shifting 300 Making Bipeds Turn 302 Summary 303 Chapter 16 Robotic Animals 305 Introduction 306 Creating a Monkey 306 Step 1: Center Motor Assembly 307 Step 2: Shoulder Assembly 308 Step 3: Shoulder/NXT Brick Bracing 309 Step 4: Shoulder-to-Arms Support 310 Step 5: Arm Motors 311 Step 6: Monkey Fingers 312 Step 7: NXT Brick Backbracing and Ultrasonic Sensor.313 The Final Step: Wiring Your Monkey 314 Programming Your Monkey 314 Creating a Mouse 316 Step 1: Mouse Frame and Motor Assembly 316 Step 2: Castor Bottom 318 Step 3: Tail Assembly 318 Step 4: The Mouse Head Frame 319 Step 5: Motorized Mouse Head Assembly 320 Step 6: Mounting the Mouse Head to the Body 321 Step 7: A Programming Example 322 Creating Other Animals 324 Summary 325 Chapter 17 Solving a Maze 327 Introduction 328 Finding the Way Out 328 Using the Left Side-Right Side Strategy 330 Applying Other Strategies 332 Building a Maze Runner 333 Constructing the Maze Runner 333 Programming the Runner 336 Creating the Maze 339 Building a Maze Solver 339 Constructing the Maze Solver 339
Contents Programming the Solver 341 Improving the Program 347 Summary 348 Chapter 18 Drawing and Writing 349 Introduction 350 Creating a Logo Turtle 350 Building the Turtle 350 Programming the Turtle 355 Tape Writer 361 Building the Writer 361 Programming the Writer 366 What to Write 369 Further Suggestions 369 Copying 369 Emulating Handwriting 370 Learning by Example 370 Summary 371 Chapter 19 Racing Against Time 373 Introduction 374 Hosting and Participating in Contests 374 Optimizing Speed 376 Drag Racing 376 Combining Speed with Precision 377 Line Following 378 Wall Following 379 Other Races 380 Summary 381 Chapter 20 Hand-to-Hand Combat 383 Introduction 384 Building a Robotic Sumo 384 Setting the Rules 385 Maximizing Strength and Traction 386 Attack Strategies 388 Finding the Enemy 388 Using Speed 389 Using a Transmission 390 \
xx Contents Other Sumo Tricks 391 Getting Defensive 391 Testing Your Sumo 392 Summary 393 Chapter 21 Searching for Precision 395 Introduction 396 Precise Positioning 396 Shooting -with Precision 397 Fine Motor Skills ofyour Robot 398 Removing the Bricks 398 Freeing the Magnets 399 Fire Fighting in a Maze 401 Playing Soccer 402 Summary 403 Appendix A Resources 405 Introduction 406 Bibliography 406 General Interest Sites 407 Chapter 1 Understanding LEGO Geometry 408 Chapter 2 Playing with Gears 408 Chapter 3 Controlling Motors 409 Chapter 4 Reading Sensors 409 Chapter 5 What's New with the NXT 411 Chapter 6 Building Strategies 412 Chapter 7 Programming the NXT 412 Chapter 8 Playing Sounds and Music 413 Chapter 9 Becoming Mobile 413 Chapter 10 Getting Pumped: Pneumatics 414 Chapter 11 Finding and Grabbing Objects 415 Chapter 12 Doing the Math 415 Chapter 13 Knowing Where You Are 416 Chapter 14 Classic Projects 417 Chapter 15 Building Robots that Walk 417 Chapter 16 Robotic Animals 417 Chapter 17 Solving a Maze 418 Chapter 18 Drawing and Writing 418 Chapter 19 Racing Against Time 419
Contents Chapter 20 Hand-to-Hand Combat 419 Chapter 21 Searching for Precision 420 Appendix В Matching Distances 421 Appendix С Note Frequencies 427 Appendix D Math Cheat Sheet 429 Sensors 430 Averages 430 Interpolation 430 Gears, Wheels, and Navigation 431 Index 433