Introduction to the Lego NXT Vasilis Spiliopoulos < - - PowerPoint PPT Presentation

introduction to the lego nxt
SMART_READER_LITE
LIVE PREVIEW

Introduction to the Lego NXT Vasilis Spiliopoulos < - - PowerPoint PPT Presentation

Introduction to the Lego NXT Vasilis Spiliopoulos < ssssts > (special thanks to Andreas Sandberg) What is Lego Mindstorm? A kit containing: A Lego NXT computer


slide-1
SLIDE 1

Introduction to the Lego NXT

Vasilis Spiliopoulos <✈❛s✐❧❡✐♦s✳s♣✐❧✐♦♣♦✉❧♦s❅✐t✳✉✉✳s❡> (special thanks to Andreas Sandberg)

slide-2
SLIDE 2

What is Lego Mindstorm?

A kit containing:

◮ A Lego NXT computer ◮ 3 motors ◮ Touch sensor ◮ Light sensor ◮ Sound sensor ◮ Ultrasonic range sensor ◮ Lots of Lego bricks ◮ . . . and plenty of fun!

slide-3
SLIDE 3

The NXT

Hardware overview

Main CPU Atmel ARM7 Sound IO Processor Atmel AVR Display Bluetooth JTAG JTAG USB IO connectors

slide-4
SLIDE 4

The NXT

CPUs

◮ The main CPU (AT91SAM7S256) is an ARM7TDMI based

µcontroller from Atmel.

◮ 32-bit RISC ◮ Running at 48 MHz ◮ 256 KiB Flash ◮ 64 KiB RAM

◮ IO coprocessor (Atmel ATmega 48)

◮ Running at 8 MHz ◮ 8-bit RISC (AVR) ◮ 4 KiB Flash ◮ 512 B RAM ◮ Samples analog sensors with @ 333 Hz ◮ Controls motors

slide-5
SLIDE 5

The NXT

CPUs

◮ The main CPU (AT91SAM7S256) is an ARM7TDMI based

µcontroller from Atmel.

◮ 32-bit RISC ◮ Running at 48 MHz ◮ 256 KiB Flash ◮ 64 KiB RAM

◮ IO coprocessor (Atmel ATmega 48)

◮ Running at 8 MHz ◮ 8-bit RISC (AVR) ◮ 4 KiB Flash ◮ 512 B RAM ◮ Samples analog sensors with @ 333 Hz ◮ Controls motors

slide-6
SLIDE 6

The NXT

External communication

◮ Bluetooth

◮ Only supports the serial profile (≈ 200 kb/s). ◮ Requires that devices have been paired. ◮ Useful for wireless debugging or robot cooperation. ◮ May sometimes be used to upload software to the NXT.

◮ USB

◮ Normally used for software upload ◮ Can be used for debugging ◮ Firmware uploading

◮ I2C

◮ Used for low-speed (9600 b/s) serial communication with

sensors.

◮ RS485

◮ High-speed (≈ 1 Mb/s) serial communication. ◮ Can be used for wired communication between robots. ◮ Not used in default firmware.

slide-7
SLIDE 7

The NXT

External communication

◮ Bluetooth

◮ Only supports the serial profile (≈ 200 kb/s). ◮ Requires that devices have been paired. ◮ Useful for wireless debugging or robot cooperation. ◮ May sometimes be used to upload software to the NXT.

◮ USB

◮ Normally used for software upload ◮ Can be used for debugging ◮ Firmware uploading

◮ I2C

◮ Used for low-speed (9600 b/s) serial communication with

sensors.

◮ RS485

◮ High-speed (≈ 1 Mb/s) serial communication. ◮ Can be used for wired communication between robots. ◮ Not used in default firmware.

slide-8
SLIDE 8

The NXT

External communication

◮ Bluetooth

◮ Only supports the serial profile (≈ 200 kb/s). ◮ Requires that devices have been paired. ◮ Useful for wireless debugging or robot cooperation. ◮ May sometimes be used to upload software to the NXT.

◮ USB

◮ Normally used for software upload ◮ Can be used for debugging ◮ Firmware uploading

◮ I2C

◮ Used for low-speed (9600 b/s) serial communication with

sensors.

◮ RS485

◮ High-speed (≈ 1 Mb/s) serial communication. ◮ Can be used for wired communication between robots. ◮ Not used in default firmware.

slide-9
SLIDE 9

The NXT

External communication

◮ Bluetooth

◮ Only supports the serial profile (≈ 200 kb/s). ◮ Requires that devices have been paired. ◮ Useful for wireless debugging or robot cooperation. ◮ May sometimes be used to upload software to the NXT.

◮ USB

◮ Normally used for software upload ◮ Can be used for debugging ◮ Firmware uploading

◮ I2C

◮ Used for low-speed (9600 b/s) serial communication with

sensors.

◮ RS485

◮ High-speed (≈ 1 Mb/s) serial communication. ◮ Can be used for wired communication between robots. ◮ Not used in default firmware.

slide-10
SLIDE 10

Motors

◮ Included motors linear and not step motors.

◮ Speed is controlled using Pulse Width Modulation. ◮ The AVR µcontroller handles PWM generation.

◮ Feedback is provided by a quadrature encoder attached to

the motor.

◮ Allows detection of rotation direction and amount.

slide-11
SLIDE 11

Sensors

Light sensor

◮ Simple photo-sensor that detects the strength of the

incoming light.

◮ Has a LED mounted to provide illumination. ◮ Analog sensor

slide-12
SLIDE 12

Sensors

Touch sensor

◮ Just a button with some Lego extras for mounting. Nothing

fancy.

◮ Analog sensor

slide-13
SLIDE 13

Sensors

Sound sensor

◮ Measures sound intensity. ◮ Can be run in either DB or DBA mode. ◮ Analog sensor

slide-14
SLIDE 14

Sensors

Ultrasonic range sensor

◮ “Smart” sensor – uses I2C for communication. ◮ Detects distance to objects using sound pulses.

slide-15
SLIDE 15

Developing for the NXT

Overview

◮ NXT-G

◮ Bundled with the NXT. ◮ Graphical drag and drop flowchart programming. ◮ Doesn’t work for large applications, unstable. ◮ Requires Windows.

◮ RobotC

◮ Commercial, but the department has licenses. ◮ C-based language, but not “vanilla” C. ◮ Has an integrated development environment with

debugging.

◮ Requires Windows.

◮ Not eXactly C

◮ Has an IDE (Bricx Command Center) ◮ Debugger support ◮ Supports at least Windows and OSX ◮ No releases in a long time – development has stagnated?

slide-16
SLIDE 16

Developing for the NXT

Overview

◮ NXT-G

◮ Bundled with the NXT. ◮ Graphical drag and drop flowchart programming. ◮ Doesn’t work for large applications, unstable. ◮ Requires Windows.

◮ RobotC

◮ Commercial, but the department has licenses. ◮ C-based language, but not “vanilla” C. ◮ Has an integrated development environment with

debugging.

◮ Requires Windows.

◮ Not eXactly C

◮ Has an IDE (Bricx Command Center) ◮ Debugger support ◮ Supports at least Windows and OSX ◮ No releases in a long time – development has stagnated?

slide-17
SLIDE 17

Developing for the NXT

Overview

◮ NXT-G

◮ Bundled with the NXT. ◮ Graphical drag and drop flowchart programming. ◮ Doesn’t work for large applications, unstable. ◮ Requires Windows.

◮ RobotC

◮ Commercial, but the department has licenses. ◮ C-based language, but not “vanilla” C. ◮ Has an integrated development environment with

debugging.

◮ Requires Windows.

◮ Not eXactly C

◮ Has an IDE (Bricx Command Center) ◮ Debugger support ◮ Supports at least Windows and OSX ◮ No releases in a long time – development has stagnated?

slide-18
SLIDE 18

Developing for the NXT

Overview (contd.)

◮ nxtOSEK

◮ GCC development environment (real C!) ◮ Uses some Japanese embedded OS used in the

automotive industry.

◮ C/C++ library for accessing IO devices.

◮ LEJOS

◮ Mini-Java implementation. ◮ Uses the standard Java compiler, but a limited class library. ◮ Has a plugin for Eclipse. ◮ Works on most operating systems (even Solaris1) ◮ Somewhat limited debugging capabilities. 1Requires patching and a sacrifice to Cthulhu.

slide-19
SLIDE 19

Developing for the NXT

Overview (contd.)

◮ nxtOSEK

◮ GCC development environment (real C!) ◮ Uses some Japanese embedded OS used in the

automotive industry.

◮ C/C++ library for accessing IO devices.

◮ LEJOS

◮ Mini-Java implementation. ◮ Uses the standard Java compiler, but a limited class library. ◮ Has a plugin for Eclipse. ◮ Works on most operating systems (even Solaris1) ◮ Somewhat limited debugging capabilities. 1Requires patching and a sacrifice to Cthulhu.

slide-20
SLIDE 20

Remote controlling

Overview

◮ The NXT can be controlled from a computer (or another

NXT!).

◮ Libraries exist for most common programming languages.

◮ Matlab ◮ Python ◮ Ruby ◮ Java ◮ . . .

slide-21
SLIDE 21

LEJOS

Overview

◮ Requires custom firmware with a small Java Virtual

Machine

◮ Supports standard Java threads ◮ Almost the same code can used both on the NXT and on a

computer controlling the NXT

◮ Supports Bluetooth and for all communication with the NXT

slide-22
SLIDE 22

LEJOS

Bluetooth – practical matters

◮ Bluetooth communication requires pairing to prevent

unauthorized access to wireless devices

◮ Process is OS dependent ◮ Requires a PIN code, the default one is ’1234’

◮ When communicating with the NXT you should normally

specify the name of the target device

◮ Unless your NXT has a ’good’ name, rename it to

something unique

slide-23
SLIDE 23

LEJOS

Bluetooth – practical matters

◮ Bluetooth communication requires pairing to prevent

unauthorized access to wireless devices

◮ Process is OS dependent ◮ Requires a PIN code, the default one is ’1234’

◮ When communicating with the NXT you should normally

specify the name of the target device

◮ Unless your NXT has a ’good’ name, rename it to

something unique

slide-24
SLIDE 24

Compiling and linking

nxjc RobotTest . java Compiles the RobotTest.java class and all its dependencies, similar to the javac command. n x j l i n k −o RobotTest . nxj RobotTest Packages the class RobotTest and all its dependencies, including the class library. Similar to the jar tool in some ways. nxjupload −b −r RobotTest . nxj Uploads the packages to the NXT using Bluetooth.

slide-25
SLIDE 25

Compiling and linking

nxjc RobotTest . java Compiles the RobotTest.java class and all its dependencies, similar to the javac command. n x j l i n k −o RobotTest . nxj RobotTest Packages the class RobotTest and all its dependencies, including the class library. Similar to the jar tool in some ways. nxjupload −b −r RobotTest . nxj Uploads the packages to the NXT using Bluetooth.

slide-26
SLIDE 26

Compiling and linking

nxjc RobotTest . java Compiles the RobotTest.java class and all its dependencies, similar to the javac command. n x j l i n k −o RobotTest . nxj RobotTest Packages the class RobotTest and all its dependencies, including the class library. Similar to the jar tool in some ways. nxjupload −b −r RobotTest . nxj Uploads the packages to the NXT using Bluetooth.

slide-27
SLIDE 27

Examples

Debug console

import l e j o s . nxt .comm. RConsole ; RConsole . openBluetooth ( 0 ) ; RConsole . p r i n t l n ( " Hello World ! " ) ; System . setErr (new PrintStream ( RConsole . openOutputStream ( ) ) ) ; System . err . p r i n t l n ( " This i s stde rr . " ) ;

slide-28
SLIDE 28

Examples

Motors

import l e j o s . nxt . Motor ; Motor motor = Motor .A; motor . setSpeed (360); motor . forward ( ) ; Thread . sleep (1000); motor . stop ( ) ;

slide-29
SLIDE 29

Examples

Light sensors

import l e j o s . nxt . SensorPort ; import l e j o s . nxt . LightSensor ; LightSensor sensor = new LightSensor ( SensorPort . S1 ) ; int value = sensor . readValue ( ) ;

slide-30
SLIDE 30

Get started!

◮ Checkout the course homepage - examples will be

uploaded soon: ❤tt♣✿✴✴✇✇✇✳✐t✳✉✉✳s❡✴❡❞✉✴❝♦✉rs❡✴❤♦♠❡♣❛❣❡✴ ♣r♦❥❡❦ts②st❡❦✴❤t✶✶

◮ software, tutorials etc.

❤tt♣✿✴✴❧❡❥♦s✳s♦✉r❝❡❢♦r❣❡✳♥❡t✴

◮ Checkout a kit ◮ Get started!