Notes for Lego Mindstorm NXT Developers

From Intrument Element Wiki

Jump to: navigation, search

This is a guide for setting up a Lego Mindstorm NXT to be used with the Instrument Element framework. The very first step is to install LeJOS in the NXT brick. Please follow this link to see how it is done:

How to install LeJOS

Once LeJOS is installed, the code that has been written for the robot has to be ported into the NXT brick. This enables the robot to be controlled remotely using the Instrument Element service. The code is available in the following link in the T1RobotTools project folder:

Develop Instrument Element

Note that, this code has been developed specifically for the T1 robot model shown in the T1 Robot Documentation. However, any other Lego model built in the similar way (2 individual motors for each side, sensors connected in same way, etc.) should also work. Please refer to the following list of motors and sensors connected to the specified ports of the NXT brick.

Left wheel motor => Motor Port A
right wheel motor => Motor Port C
Touch sensor => Sensor Port 1
Ultrasonic sensor => Sensor Port 2
Light Sensor => Sensor Port 3

There is file inside the ch.usi.nxt.setting Java package in the T1RobotTools project folder. This files contains all the configuration settings. For the T1 model, the motors works in the opposite direction, i.e. "Forward" command turns the motor actually in reverse direction but robot moves forward. This can be easily modified just by changing the value of PILOT_REVERSE to false in the file.

After uploading the code into the NXT Brick, the Main.nxj file should be visible inside the Files menu of the LeJOS. This file has to be executed first before the PC side code is executed.

Code Structure description

Project and Code structure
Project and Code structure
  • ieT1 folder(instrumentelem/NxtServer/ieT1):
  • T1RobotTools(instrumentelem/T1RobotTools): his is the program that is uploaded to Lego Mindstorm.
    T It includes a file which is the main file that has to be compiled using
    • the Lejos NXJ ecplise plugin: right click on the and choose Lejos NXJ->Upload Program to NXT Brick.
    • Or using the command line utility in the Lejos Folder, use the "nxjc" command to compile file. Use the -verbose with nxjc to monitor the compilation process. For example, use ./nxjc -verbose
    • compilation creates a class file. You can upload the class file to Lego using "nxj" command. For example, "nxj -b -n NXT Main". -b is used for bluetooth. -n NXT means to upload the program to a Lego with the name NXT.

  • T1ServerTools(instrumentelem/NxtServer/T1ServerTools):
Personal tools