The LEGO Remote Control System
Cheapness and their flexibility are placing LEGO MindStrom in the middle of many university research projects. The Robotic Inventor System allows you to create everything, from a simple robot that follows a light source to a complex robotic harm who plays chess. The only limit is represented by its hardware endowment ( a single RCX can manage only three motors and three sensors, the communication is provided by Infrared signals and 32 Kbs of RAM are very few keeping in mind that a tiny JVM have to run inside ).
Afterwards, thinking to develop complex algorithms in this environment it still seems an utopia. As a consequence, to solve this problem we develop a framework that allows the remote control of the RCX Brick. The leRCoS project ( lego Remote Control System ) moves the execution logic into PC side environment rising RCX Brick burden. leRCoS also abstract the RCX Brick into a standard Java Object that can execute in a full java environment taking advances of it.
The leRCoS project is a small middleware acting between LEGO RCX bricks and a J2SE environment.
With leRCoS, the robot logic can be moved inside a JRE in a very simple way. leRCoS is based on leJOS (in the RCX side) and exposes the same API on the server side; this makes very simple porting leJOS applications on leRCoS.
The leRCoS is also posted in the open source Java community Java.net. Source code and documentation can be found here.
Install on your RCX brick the leJOS firmware (usefull information about the procedure can be founded here). Unzip the rcxinterpreter.jar file using the command:
jar -xf rcxinterpreter.jar
lejos lercos.Main
java -jar rcxCommander.jar lercos.gui.GuiController
Using leRCoS is very simple, once your system is configured you can write your first program. leRCoS API structure is very similar to the leJOS one, this make easy porting old leJOS application upon the new framework.
Here it is an example of a NerdBot program running on leRCoS.
import java.io.IOException;
import lercos.remote.rcx.*;
public class NerdBot {
public static void main(String[] args){
RCX rcx = null;
try {
rcx = new RCX(); // instantiate RCX Object
} catch (IOException e) {
System.out.println("LEGO Tower - Access Denied");
return;
}
rcx.Motor.A.forward(); // start motor A
try {
Thread.sleep(2000); // wait 2 seconds
} catch (InterruptedException e1) {
e1.printStackTrace();
}
rcx.Motor.A.stop(); // stop motor A
rcx.Button.RUN.waitForPressAndRelease();
}
}
Compile this Java class using the javac compiler including the rcxCommander.jar in the classpath.
javac -cp rcxCommander.jar NerdBot.java
java -cp rcxCommander.jar NerdBot