1 / 42

LEGO Mindstorms NXT

LEGO Mindstorms NXT. SOURCES:. Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar miha.stajdohar@fri.uni-lj.si. Principles of Robotics. Integrity . Robots hold together throughout the competition (no small task when you are talking about robots built out of Legos).

Download Presentation

LEGO Mindstorms NXT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LEGO Mindstorms NXT SOURCES: Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdoharmiha.stajdohar@fri.uni-lj.si

  2. Principles of Robotics Integrity. Robots hold together throughout the competition (no small task when you are talking about robots built out of Legos). Accuracy. The robot's mechanical outputs and its location acquisition and feedback to the RCX and subsequent programming provide the intelligence for precise performance. Execution. The robot performs the tasks it was designed to accomplish. Repeatability. The robot can perform the exact routine time and time again. Ergonomics. The robot is easy to handle, reconfigure, and change batteries or reprogram if necessary. Efficiency. The robot's design makes optimal use of its parts to execute tasks, minimize friction, and use power.

  3. Why students learn more when they participate in a real challenge?

  4. Sophisticated robots can be build Accuracy of mapping program and NXT Draw letter “E” Circle Program Light Following on simulation More videos at http://www.youtube.com/ece191nxt

  5. Examples of mobile and humanoid robots Motivation Project Overview Hardware Specification Lego Robot Programming Environments NXC RobotC Method and Approach Ideas Design

  6. Mindstorms NXT • mindstorms.lego.com

  7. Mindstorms NXT • mindstorms.lego.com

  8. Ideas • youtube.com • ...

  9. Brick • 4 sensor inputs • 3 sensor inputs / motor outputs • Programmable

  10. Purchasing NXT Kits • Two options (same price; $250/kit) • Standard commercial kit • Lego Education kit • http://www.lego.com/eng/education/mindstorms/ • Advantages of education kit • Includes rechargeable battery ($50 value) • Plastic box superior to cardboard • Extra touch sensor (2 total) • Standard commercial kit • Includes NXT-G visual language

  11. From Idea to Pseudo-Code to software to robot behavior

  12. Thinking about Programming Creating a successful robot takes a team effort between humans and machines. Role of the Robot The robot follows the instructions it is given, thereby carrying out the plan.

  13. Human/Machine Communication Because humans and robots don’t normally speak the same language, a special language must be used to translate the necessary instructions from human to robot. These human-to-robot languages are called programming languages. Instructions written in them are called programs. ROBOTC is just one of many such programming languages that humans use to talk to machines.

  14. Think about “Behaviors” Behaviors are a convenient way to talk about what a robot is doing and what it must do. Moving forward, stopping, turning, looking for an obstacle… these are all behaviors. • Basic or Simple Behavior • Some behaviors are small, like “go forward for 3 seconds.” • Big behaviors are actually made up of these smaller ones. Complex Behavior Some behaviors are big, like “solve the maze.”

  15. Planning the Behaviors

  16. The main principle is braking large behaviors into hierarchies of smaller and smaller behaviors. You have to understand every piece of input-output behavior of a robot

  17. PSEUDOCODE As the programmer becomes more experienced, the organization of the behaviors in English will start to include important techniques from the programming language itself, like if-else statements and loops. This hybrid language, halfway between English and the programming language, is called pseudocode. It is an important tool in helping to keep larger programs understandable.

  18. ROBOTC is text based! Commands to the robot are first written as text on the screen. They are then processed by the ROBOTC compiler into a machine language file that the robot can understand. Finally, they are loaded onto the robot, where they can be run.

  19. Software development options • Onboard programs • RobotC • leJOS • NXC/NBC • Remote control • iCommand • NXT_Python

  20. NXT Brick Features • 64K RAM, 256K Flash • 32-bit ARM7 microcontroller • 100 x 64 pixel LCD graphical display • Sound channel with 8-bit resolution • Bluetooth radio • Stores multiple programs • Programs selectable using buttons

  21. Programming languages IDE – interactive development environment • NBC, NXC • NXT Python, .NET http://www.teamhassenplug.org/NXT/NXTSoftware.html

  22. Programming Environments NXC A High-level language Similar to C Stand-alone language (No plug-ins or add-ons) The program runs in the robot itself. NXC On Bot More Robust language Takes and uses values Robust language can Graphically represent Desired input and results

  23. NXT Python • http://home.comcast.net/~dplau/nxt_python/index.html • demo • bluetooth • remote control

  24. Python Programming Environments Python 2.4.4 Scripted Programming Language Plug ins PyGame: “Simulated World” PyODE: Shapes, vectors PyBluez: Bluetooth communication Python NXT: Python Libraries for NXT Programs Light Sensor Ultrasound Sonar Sound Sensor Python IDE PyGame PyODE Python NXT PyBluez

  25. Mapping Program Generate movement on NXT robot, record movement and plot robot’s path in real time in a simulated world. Python + Simulator Thread function, lock on global objects NXC + Simulator Separate program activates robot, simulator polls output values Method and Approach Moves Robot Starts Pygames Draws readings on Pygames Sends motor readings

  26. ROBOTC • firmware • tasks, program loop • Sensors, motors • data • bluetooth, messages www.robotc.net

  27. RobotC • Commercially supported • http://www.robotc.net/ • Not entirely free of bugs • Poor static type checking • Nice IDE • Custom firmware • Costly • $50 single license • $250/12 classroom computers

  28. Bluetooth • PyBluez • http://org.csail.mit.edu/pybluez/

  29. Motors • Configured in terms of percentage of available power • Built-in rotation sensors • 360 counts/rotation • No rotation sensors in old Lego

  30. Working with Motors • Selecting Your Hardware Platform • RobotC supports a variety of different hardware platforms. • For these exercises we will configure RobotC to include support for the Tetrix/FTC robots as well as pure LEGO robots. • The “FIRST Tech Challenge (NXT)” platform is a superset of the “NXT” platform. • Whether your robot is using LEGO motors or the Tetrix 12V motors, you can control them with nearly identical code.

  31. On the Robot / Platform Type menu make sure that you have “FIRST Tech Challenge (NXT)” selected. • Click on the New icon on the RobotC toolbar to start a new program.

  32. Configuring your Motors • You need to tell RobotC how your motors are attached to your NXT. • On the Robot menu, open the Motors and Sensors Setup wizard and select the FTC Servo/Motor Ctrl tab. • A. Using LEGO NXT Motors • If your robot is using LEGO NXT motors for the drive wheels, select “No controllers configured”:

  33. Using pragmas • Two #pragma statements and a comment line should have been inserted into your program looking something like this: #pragma config(Motor, motorA, motorLeft, tmotorNormal, PIDControl)#pragma config(Motor, motorB, motorRight, tmotorNormal, PIDControl) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// • A #pragma is an instruction to the RobotC compiler to change something about how your program gets compiled. • The config() pragma tells RobotC to automatically include the necessary prefix code to configure your program to use the motor and sensor portsyou specified in the wizard.

  34. Important recommendations to Robot C programmer • You should not modify these lines of code by hand. • If the configuration of your robot changes, go back into the Motor and Sensor Setup wizard and change the values there. • When you exit the wizard it will update the #pragmas to reflect the changes you made. • Comment lines in RobotC begin with “//”. • Everything that follows a double-slash to the end of the line is ingored by the compiler. • The comment inserted by the wizard is a reminder that the #pragmas preceeding it were automatically created for you.

  35. Using Tetrix 12 Volt Motors

  36. Using Tetrix 12 Volt Motors

  37. Using Tetrix 12 Volt Motors • Three #pragma statements and a comment line should have been inserted into your program looking something like this: • #pragma config(Hubs, S1, HTMotor, HTServo, none, none)#pragma config(Motor, mtr_S1_C1_1, motorRight, tmotorNormal, PIDControl, reversed)#pragma config(Motor, mtr_S1_C1_2, motorLeft, tmotorNormal, PIDControl)//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// • A #pragma is an instruction to the RobotC compiler to change something about how your program gets compiled. • The config() pragma tells RobotC to automatically include the necessary prefix code to configure your program to use the motor and sensor ports you specified in the wizard.

  38. Using Tetrix 12 Volt Motors • You should not modify these lines of code by hand. • If the configuration of your robot changes, go back into the Motor and Sensor Setup wizard and change the values there. • When you exit the wizard it will update the #pragmas to reflect the changes you made.

  39. Using Tetrix 12 Volt Motors • Comment lines in RobotC begin with “//”. • Everything that follows a double-slash to the end of the line is ingored by the compiler. • The comment inserted by the wizard is a reminder that the #pragmas preceeding it were automatically created for you.

  40. First example of Programming Motors

More Related