Saturday, May 30, 2009

LeJOS Subversion Repository

LeJOS is a SourceForge project. As such it uses a sourceforge subversion repository.

The url is HERE.

https://lejos.svn.sourceforge.net/svnroot/lejos


Helpful article on SourceForge subversion is HERE.

Friday, May 29, 2009

Installing LeJOS using Macbook Pro




Installing LeJOS on Macbook Pro

I have been reacquainting myself with the LEGO Mindstorms NXT Platform. It is a great system for building robots and controlling them with software. The standard way to control the Mindstorms NXT is with the LEGO-provided firmware (the operating system) and running NXT-G programs developed using the LEGO-provided LEGO Mindstorms NXT Software (version 1.1).

I have been wanting to try out the LeJOS (a tiny Java Virtual Machine) for the NXT called NXJ.

To make things challenging I shall be attempting to install it using a MacBook Pro (not a PC). Here is my system configuration:
Processor: 2.93 GHz Intel Core 2 Duo
Memory: 8 GB 1067 MHz DDR3
Mac OS X: Version 1.5.7

Here is the process we will follow:
A. Establish a baseline functional Mindstorms NXT
B. Download the LeJOS software and setup the environment
C. Download the Fantom USB Driver
D. Install LeJOS
E. Test system
F. Wrap things up...conclusion.



A. Establish a baseline functional Mindstorms NXT

1. Install the LEGO provided software.



2. Install any updates for system from HERE.

  • Mac OS 10.5 (Leopard) Firmware Fix
  • LEGO MINDSTORMS NXT Firmware v1.05

3. Need something to work with so build the TriBot robot (minus the claws). This will give us something we can move around and demonstrate some external device functionality.



4. Connect the Intelligent Brick to your computer using the USB Cable.

5. Launch the Mindstorms NXT software and make sure we can communicate with the Brick:

The figure below shows that the system knows about an NXT named 'Walker' that is available on the USB.

By highlighting the Walker NXT that is available and clicking Connect button we get some more information:

The Memory tab shows some information about the connected NXT (programs and data installed):


6. Write a simple program. We want to verify that the software is installed properly and that we can download and run a program from the Mac successfully. The program selected includes a 3 nodes. Node 1 displays a picture, Node 2 moves the tri-bot in a circle and Node 3 has the NXT saying something.

Node 1: Display a smiley face on the LCD Screen of the Brick


Node 2: Move TriBot in a circle


Node 3: Play a sound file 'Game Over'


7. Download the program to the brick and run it. I did just that:



So we have established good connectivity and we can communicate with the Brick as wells as download and run programs using the LEGO Mindstorms NXT software!



B. Download the LeJOS software and setup the environment

1. Download software from HERE.

Since I am deploying on a Mac I am interested in the NXJ version for MacOSX. I pulled version 0.8 beta (lejos_NXJ_0_8_0beta.tar.gz) which comes in a g-zipped tar file which you download and unpack. It is about a 6.5MB file (20MB un-gzipped).

Here is the directory structure:


2. Setup the environment

a. Set environment variables. For me this meant making modifications to my .bash_profile file in my home directory of the Mac.
export NXJ_HOME=/Users/jkroub/software/dev/lejos_nxj
export DYLD_LIBRARY_PATH=${NXJ_HOME}/bin
export PATH=${NXJ_HOME}/bin:${PATH}


b. Setup Java version. The Macbook Pro ships with Java Version 1.5 but I had installed an additional Java Development Kit for 1.6. JDK 1.5 is a 32-bit and JDK 1.6 is a 64-bit build. I chose to make the 32-bit the default. To do this find the Java Preferences application in Finder.


c. You will notice there is a bin directory located under the main lejos_nxt directory. This directory has all the tools you will use to do LeJOS development. When they are first unzipped the files are not marked as executable. So you will have to put on your Unix hat and make them executable by opening a terminal window, traversing to the bin directory and changing the mode of these files:

$ cd $NXJ_HOME/bin
$ ls -tlr
total 288
-rw-r--r--@ 1 jkroub staff 1284 May 21 07:57 nxjupload
-rw-r--r--@ 1 jkroub staff 1286 May 21 07:57 nxjsocketproxy
-rw-r--r--@ 1 jkroub staff 1235 May 21 07:57 nxjpccomm
-rw-r--r--@ 1 jkroub staff 1285 May 21 07:57 nxjmonitor
-rw-r--r--@ 1 jkroub staff 1340 May 21 07:57 nxjlink
-rw-r--r--@ 1 jkroub staff 1284 May 21 07:57 nxjflashg
-rw-r--r--@ 1 jkroub staff 1283 May 21 07:57 nxjflash
-rw-r--r--@ 1 jkroub staff 1285 May 21 07:57 nxjdataviewer
-rw-r--r--@ 1 jkroub staff 1285 May 21 07:57 nxjcontrol
-rw-r--r--@ 1 jkroub staff 1288 May 21 07:57 nxjconsoleviewer
-rw-r--r--@ 1 jkroub staff 1282 May 21 07:57 nxjconsole
-rw-r--r--@ 1 jkroub staff 1179 May 21 07:57 nxjc
-rw-r--r--@ 1 jkroub staff 1285 May 21 07:57 nxjbrowse
-rw-r--r--@ 1 jkroub staff 1355 May 21 07:57 nxj
-rw-r--r--@ 1 jkroub staff 52352 May 21 07:57 lejos_nxt_rom.bin
-rw-r--r--@ 1 jkroub staff 34651 May 21 07:57 StartUpText.bin
$ chmod a+x *
$ ls -tlr
total 288
-rwxr-xr-x@ 1 jkroub staff 1284 May 21 07:57 nxjupload
-rwxr-xr-x@ 1 jkroub staff 1286 May 21 07:57 nxjsocketproxy
-rwxr-xr-x@ 1 jkroub staff 1235 May 21 07:57 nxjpccomm
-rwxr-xr-x@ 1 jkroub staff 1285 May 21 07:57 nxjmonitor
-rwxr-xr-x@ 1 jkroub staff 1340 May 21 07:57 nxjlink
-rwxr-xr-x@ 1 jkroub staff 1284 May 21 07:57 nxjflashg
-rwxr-xr-x@ 1 jkroub staff 1283 May 21 07:57 nxjflash
-rwxr-xr-x@ 1 jkroub staff 1285 May 21 07:57 nxjdataviewer
-rwxr-xr-x@ 1 jkroub staff 1285 May 21 07:57 nxjcontrol
-rwxr-xr-x@ 1 jkroub staff 1288 May 21 07:57 nxjconsoleviewer
-rwxr-xr-x@ 1 jkroub staff 1282 May 21 07:57 nxjconsole
-rwxr-xr-x@ 1 jkroub staff 1179 May 21 07:57 nxjc
-rwxr-xr-x@ 1 jkroub staff 1285 May 21 07:57 nxjbrowse
-rwxr-xr-x@ 1 jkroub staff 1355 May 21 07:57 nxj
-rwxr-xr-x@ 1 jkroub staff 52352 May 21 07:57 lejos_nxt_rom.bin
-rwxr-xr-x@ 1 jkroub staff 34651 May 21 07:57 StartUpText.bin


Now the files are in an executable state.



C. Download the Fantom USB Driver

1. Download the Fantom driver from HERE.  I downloaded fantom_driver_0.7.zip (39.8 KB dated Thu, 05 Mar 2009 10:17:03 GMT)
2. Unzip the file.

D. Install LeJOS
Here are some video and images of the NXT running LeJOS on my LEGO Mindstorms NXT:



Tour the LeJOS Menus:











E. Test system

1. Running nxjbrowse
Starts as unconnected:


NOTE: if your NXT is not connected via USB or it is not turned on when you run nxjbrowse you will see the following:
$ nxjbrowse
leJOS NXJ> Searching for any NXT using Bluetooth inquiry
BlueCove version 2.1.0 on mac
leJOS NXJ> Failed to find any NXTs
No NXT found - is it switched on and plugged in (for USB)?
BlueCove stack shutdown completed


After you click the Connect button:


Click the 'Set Name' button:


Uh-oh...Houston, we've got a problem!


nxjconsoleviewer:


nxjconsoleviewer: after clicking the 'Connect' button on USB:


nxjconsoleviewer: after clicking the 'Connect' button on BlueTooth:


F. Wrap things up...conclusion.

Wednesday, May 27, 2009

Mindstorms NXT Display Repair




Can children under 10 learn to use the LEGO Mindstorms NXT? I think so. So this summer we will be putting this theory to the test. We have 2 volunteers. One is 8 years old, the other 5 years old.

Will keep you posted.

Tuesday, May 26, 2009

LEGO Mindstorms NXT

1-Touch Sensor
2-Sound Sensor
3-Light Sensor
4-Ultrasonic
B/C-Left/Right Motors
A-?

FW 1.05
AVR 1.01
BC4 1.01
Build 1304071100
ID 00165303D596

Sunday, May 24, 2009

JFLL 2009: Smart Move



From the FIRST Site:
"Can FIRST LEGO League teams transform the way we look at transportation? The key to the 2009 “Smart Move” Challenge is accessing people, places, goods and services in the safest, most efficient way possible. In this journey, teams will consider many modes of transportation beyond their daily routine and streamline their options by making smart moves!"

Friday, May 15, 2009

Parleys

A colleague reminded me of a great site for tech talks (in addition to INFOQ) called PARLEYS.

Josh Bloch's Talk

Wrapped up Season 2009