Updated with new code (bug fixes and 1.1 compatibility) on Dec 27, 2000
I recently bought the Lego Mindstorms Robotics Kit, and decided that it would make a cool demo if I could interact with it from Java code. So using the information available on the Lego Mindstorms Internals sight describing the RCX Op Codes and the RCX communication interface, I put together this Java interface for interacting with the RCX from a JVM.
Specifically, I wanted to allow my replicated object system (ROAPI) to interact with the RCX. Using the ROAPI for code distribution and concurrency control, it's easy to do stuff like have multiple simultaneous remote users of the RCX (e.g. from within a multi-user application like a chat), allow code from remote participants to interact with the RCX, and even allow two remote RCX's to interact with one another in a real-time shared virtual space.
The RCXPort interface sends requests and commands to the RCX via its IR interface. The RCX IR interface plugs into the computer's serial port, and my code uses the Java Comm API to send commands out to the serial port to the RCX via the IR interface. My code should work with any machine that has a serial port and is running the JVM (it's not platform specific).
To use this code you must have the Mindstorms kit itself, and you must have the Java Comm API to communicate with the computer's serial port from Java. This code works on both the 1.1 VM and the Java 2 VM.
Click here to get a zip file (~110k) with the class files, the java src, and the api javadocs.
The license is open source (GPL), the source is contained in a jar file as part of the package. If you find bugs or use this code for something please let me know...I would be interested to hear what you've done with it.
Documentation (javadocs) for the interface is available online here. To download the docs, click here.
Put the rcxport.jar file in your classpath, and make sure that the Java Comm API is also in your classpath.
See the usage for the test program in rcxport.RCXPort by typing 'java rcxport.RCXPort'. Also see the javadocs for the rcxport.RCXPort entry class.
I intend to add a language parser sometime, so that I can parse and compile a high-level language for programming the RCX, and then use the RCXPort code to download the byte codes to the RCX. The obvious language choice for this is 'Not Quite C' (nqc), a nice high-level language for programming the RCX by Dave Baum. Hopefully I'll have a chance to add a nqc parser sometime soon.
For the time being, the easiest way to generate valid byte codes for the RCX is to use nqc itself with the -L parameter, and then remove everything except for the hex byte codes themselves, which are included in the file generated by the -L parameter. See the docs on nqc.
Site Owned By: Scott Lewis
[ Skip Prev | Prev | Next | Skip Next ]
[ Prev 5 | Random | Next 5 ]
Copyrightę Scott B. Lewis, 1999