A Lego-robot with camera controlled by Matlab

disclaimer

Setting up Matlab

My version of Matlab is 6.1, but I think the Java-interface works similarily with other version of Matlab as well. To use the java-classes in Matlab the directory of the classes must be added to Matlab's classpath. This can be easily done from Matlab by typing

edit classpath.txt
The directory to add is the root directory of the Java classes, for example c:\matlab_robot\java\classes, not the c:\matlab_robot\java\classes\robot2-directory. More information about Matlab's Java-interface can be found from the Matlab's help.

A bug and how to live with it

I had a weird bug in the system that prevented the java objects used from Matlab using the serial ports. I wrote a java program that lists the available ports and realized that running the PortTest program before changing from the default working directory to the directory where I had my robot programs made the bug disappear. The PortTest program is included in the distribution file, but without sources as I managed to delete them during some testing. :) The output of PortTest when everything is fine:

>> PortTest
List of available communication ports:
COM1 type:1 isOwned:false
COM2 type:1 isOwned:false
LPT1 type:2 isOwned:false
LPT2 type:2 isOwned:false

ans =

PortTest@75d726

>> 
I think the bug has something to do with the file javax.comm.properties that defines the communication ports, but I didn't find any way to fix it