Transcript CSCI 394

Week 2 Material

Install and Configure
 Mindstorms
NXT Software and User Guide
 LeJOS NXJ 0.1.0 Alpha

Java
 General
 Program
CSCI 394-02 Spring '07
examples
© 2007 JW Ryder
1
Install and Configure Mindstorms

Install Mindstorms NXT



Software – 1 CD – Take all defaults
User Guide – 1 CD on c:\ drive
Pass around while we talk
CSCI 394-02 Spring '07
© 2007 JW Ryder
2
Reload Mindstorms Firmware





Start up Mindstorms Software
Click Tools -> Update NXT Firmware
Select v1.03 then press download
Your brick must be in firmware reset mode for
this to work
When you turn the brick on, you should once
again see the Lego logo etc as before
CSCI 394-02 Spring '07
© 2007 JW Ryder
3
Create shortcuts Minstorms Stuff

Mindstorms NXT software


User Guide


C:\Program Files\LEGO Software\LEGO
MINDSTORMS Edu
NXT\MINDSTORMSNXT.exe
C:\NXT User Guide\winopen.exe
Start Mindstorms NXT Software

Download NXT firmware v1.3
CSCI 394-02 Spring '07
© 2007 JW Ryder
4
LeJOS NXJ 0.1.0 Alpha


Released Jan. 10, 2007
Specifically for the NXT


Missing support for Sound, Bluetooth, and
Ultrasonic Sensor (I2C)
Version: Alpha 0.1.0 lejos_NXJ_win32_0_1_0alpha.zip
CSCI 394-02 Spring '07
© 2007 JW Ryder
5
Install LeJOS NXJ 0.1.0 Alpha

Unzip LeJOS NXJ 0.1.0 Alpha software and
documentation to c:\

This will create a folder on c:\ called
c:\lejosnxj0_1_0alpha


Check to make sure it is there
LeJOS needs a special tool called LibUsb to be able
to download programs to the NXT

We must install
CSCI 394-02 Spring '07
© 2007 JW Ryder
6
Install LibUsb





Can be found at http://libusb-win32.sourceforge.net
Package Name: Snapshot: libusb-win32-filter-bin20060827.exe
Run the setup EXE program. Use all defaults
Installs under c:\Program Files\LibUSB-Win32
Find its bin directory then

execute install-filter.exe one time by
double-clicking on it
CSCI 394-02 Spring '07
© 2007 JW Ryder
7
Environment Variables



System -> Advanced -> Environment
Variables
Change in the ‘System Variables’ section
Always add to the end of the list if one exists

before adding separate the last one and your new
one with a semi-colon (;)
CSCI 394-02 Spring '07
© 2007 JW Ryder
8
PATH Environment Variable

PATH should contain:

.;c:\program files\java\jdk1.5.0_10\bin;c:\lejosnxj0_1_0alpha\bin
CSCI 394-02 Spring '07
© 2007 JW Ryder
9
CLASSPATH Environment Variable

CLASSPATH should contain:

.;c:\394robotics\javaprojects;c:\lejosnxj0_1_0alpha\lib\classes
.jar;c:\lejosnxj0_1_0alpha\lib\jtools.jar
CSCI 394-02 Spring '07
© 2007 JW Ryder
10
Other Environment Variables



LEJOS_HOME=c:\lejosnxj0_1_0alpha
JAVA_HOME=c:\Program Files\Java
You should now be done with install and
configure for a while
CSCI 394-02 Spring '07
© 2007 JW Ryder
11
LeJOS NXJ 0.1.0 Alpha Docs


Good docs in
c:\lejosnxj0_1_0alpha\docs\apidocs
Add a shortcut to the desktop for the API docs

index.html
CSCI 394-02 Spring '07
© 2007 JW Ryder
12
LeJOS NXJ 0.1.0 Alpha Samples



Good docs in c:\lejosnxj0_1_0alpha\samples
One sample per folder, just like you will write
your code
If you have not created a csci394projects
folder yet on the c:\ drive, do it now
CSCI 394-02 Spring '07
© 2007 JW Ryder
13
Important Notes about Using NXJ


http://comments.gmane.org/gmane.comp.java.
lejos/2976
To Upload/Download for NXJ

Press reset button on brick for at least 4 seconds
to put into firmware update mode
CSCI 394-02 Spring '07
© 2007 JW Ryder
14
Java

Note: It is best to have jdk-1_5_10 installed
on your system. That is what I am going to
refer to.



9 will work and probably 1.6 too.
You will need to make your environment
variables match the version of Java you have
on your system
Info about installing JDK 1.5.0_10 SDK next
CSCI 394-02 Spring '07
© 2007 JW Ryder
15
Java 1.5.0_10 SDK

Download jdk-1_5_10-windows-i586-p.exe
from the Sun web site


Allow default installation to:


java.sun.com
c:\program files\java\jdk1.5.0_10
Add environment variable values:


PATH: .;c:\program files\java\jdk1.5.0_10\bin
CLASSPATH: .
Note: A single period
CSCI 394-02 Spring '07
© 2007 JW Ryder
16
Java Runtime Environment


Allow the JRE 1.5.0_10 to be installed during
the normal installation
Installed in c:\program files\java\jre1.5.0_10
CSCI 394-02 Spring '07
© 2007 JW Ryder
17
Java 1.5.0 Documentation


jdk-1.5.0-doc.zip – Get from Sun web site
Unzip into c:\program files\java

Creates a ‘docs’ folder under ‘java’ folder
CSCI 394-02 Spring '07
© 2007 JW Ryder
18
Java New Folder Summary

Three new folders under c:\program files\java

docs, jdk1.5.0_10, and jre1.5.0_10
CSCI 394-02 Spring '07
© 2007 JW Ryder
19
LeJOS NXJ Java Education

The SAMPLES are your friends. Start with the
following order:







HelloWorld.java – let’s review and then try it
MemoryTest.java
TestButton.java
TestMotor.java
TestSensor.java
and so on ….
Copy HelloWord folder under your csci394projects
folder
CSCI 394-02 Spring '07
© 2007 JW Ryder
20
LeJOS NXJ Compile and Link




Open a command prompt window (DOS
window) and cd to the folder with your copy
of HelloWorld in it
Compile a program: lejosjc Test.java
Link a program: lejoslink Test -o Test.bin
Test.bin is now ready to download
CSCI 394-02 Spring '07
© 2007 JW Ryder
21
LeJOS NXJ Download

You must first

Reset the brick to “firmware reset” mode





Turn the brick on
On bottom of brick, press reset for at least 4 seconds
Do you have a blank screen? (yes = good)
Turn the brick on (do you hear a tick tick?)
(yes = good)
Download a program: lejosdl Test.bin
CSCI 394-02 Spring '07
© 2007 JW Ryder
22
HelloWorld.java Example






In c:\csci394projects\HelloWorld
lejosjc HelloWorld.java
 Input: HelloWorld.java, Output: HelloWorld.class
lojoslink HelloWorld –o HelloWorld.bin
 Input: HelloWorld.class, Output: HelloWorld.bin
Ensure brick in reset mode and turned on in that order
lejosdl HelloWorld.bin
Watch the NXT LCD screen. What happens?
CSCI 394-02 Spring '07
© 2007 JW Ryder
23