In this lab, you will prepare the development environment you'll need to be able to create a Java application that can remotely control a Lego Mindstorm robot. There are several aspects involved:
The instructions below will guide you in the steps required to complete each of these parts
When you are finished, you will be required to individually demonstrate that your development environment is configured correctly by executing the sample application and controlling the robot.
You might have an older version of Eclipse (e.g. Galileo or Indigo) on your computer. There are also several variants of Eclipse, such as "Eclipse Classic", "Eclipse J2EE", or "Eclipse IDE". If you don't already have it, you really should install the latest version (Juno) of the Eclipse IDE, which you can download from www.eclipse.org/downloads. Note that you do not need to uninstall any existing version of Eclipse that you may already have on your computer - you can have multiple versions installed simultaneously without problems.
Since there are various versions of Eclipse listed on the above site, be sure to select Eclipse IDE for Java Developers. You may choose either the 32-bit or 64-bit version, but it makes most sense to choose the 64-bit version since you (likely) have (as an MSOE student) a 64-bit laptop. If you have a different laptop, choose the version of the Eclipse IDE that is appropriate for your computer. Note that Mac and Linux packages are also available, both in 32-bit and 64-bit versions.
Whether you installed the 32-bit or 64-bit version of Eclipse IDE, you need a 32-bit version of the Java JDK, because in the next step, you'll be installing the Lejos SDK libraries, which are only compatible with the 32-bit versions of the Java JDK. The 64-bit versions of the JDK are incompatible with the Lejos 32-bit NXJ libraries and will not work!!
Note that there are several versions of the 32-bit JDK available; at the time of this writing, most students use either version 1.6 or 1.7 - either version is OK.
You can download the 1.6 JDK from this Oracle site. First select Java SE Development Kit 6u37, and then select the 32-bit package. For Windows, this is named Windows x86, and the filename is jdk-6u37-windows-i586.exe. Run the setup program after you download it.
Next, you need to install Lejos NXJ, the Java libraries for Mindstorm, from this Sourceforge site. (Although there may be newer versions available, you should download the 0.9.1beta version.) If you are running Windows, select leJOS_NXJ_0.9.1beta-3_win32_setup.exe from the list that appears when you browse to that site. Run the setup program after you download it.
Moving on, you next need to install the Lejos plugin for Eclipse. This plugin adds a wizard to Eclipse that makes it easy to create Java applications for Mindstorm programming, along with a few tools for downloading software to the Mindstorm controller.
Select the Install New Software... item from Eclipse's Help menu. In the Install dialog that appears, click the Add.. button, and then enter the Name and Location shown in the Add Repository dialog below.
After pressing the OK button in the Add Repository dialog, press the Next> button in the Install dialog to complete the installation of the plugin.
Once the plugin installation is completed, you may have to restart Eclipse. Once restarted, select About Eclipse SDK from the Eclipse Help menu. The About Eclipse SDK dialog should appear as shown below, including the Lejos icon indicated in the red circle. Note that you may not have all of the other icons shown.
You should see a new item in the main Eclipse menu called LeJOS NXJ. The Upload Firmware command is the single command that appears in this menu, and it is used to flash - or reprogram - the Mindstorm controller with different firmware (software that is semi-permanent) used for communicating with your laptop.
You can flash the controller before you assemble the complete robot, but first you need to charge the controller and connect it to your laptop via the USB cable supplied with the Mindstorm kit. To flash the firmware, turn the controller on by pressing the orange button on the face of the controller. Note that the controller has an automatic power-off feature that will cause it to power off after a minute or so (this timeout is adjustable). Once powered-up, execute the Upload Firmware command. A dialog titled Install LeJOS NXJ Firmware in NXT should appear. Press the Flash leJOS firmware button, and the flashing process should begin. If successful, you should see a message to that effect appear within the dialog. If unsuccessful, reseat the USB cable on both ends and repeat the process.
You need to build a robot using the parts in the Mindstorm kit. You can use the instructions found on this site to build an Express-Bot, a version that is relatively simple and quick to assemble.
In this final step, you'll be making certain that all parts of your development environment are correctly configured such that you can create a Java program that allows you to control the robot from your laptop. The Lejos NXJ libraries you installed earlier constitute the API (Application Program Interface), a set of classes that implements the functionality for controlling and communicating with the robot. This library supports communication between the laptop and the robot via either the USB cable or a wireless Bluetooth connection (if your laptop supports Bluetooth).
From within Eclipse, create a new project by selecting New, followed by Other... from the File menu. In the dialog that displays the various types of projects you can create, you should see a LeJOS folder. Expand this folder, select LeJOS PC Project, and press the Next> button. On the page that follows, enter a name for the project (e.g. SE2800Demo). Be sure to select the 32-bit JavaSE-1.6 as the execution environment, since the Lejos NXJ libraries are not compatible with other JDK's.
In Eclipse's Package Explorer, the project you just created should appear, containing an empty src folder. In addition, you should see two libraries included in the project: one should be the JavaSE-1.6 system library, and the other should be the LeJOS PC Libraries.
Download this sample zipfile and import the .java files contained within it to your project; you should be able to run the sample application as-is. Note you'll need to have your robot connected to your laptop via the USB cable.
Demonstrate the running application/robot to your instructor.
The steps are: