A Lego-robot with camera controlled by Matlab

disclaimer

The legOS program

I wrote the legOS program in C and compiled it with the compiler that came with WinLegOS. Both the source code (robot2.c) and the legOS-binary (robot2.lx) are in the distribution file, under the directory legos. The program can be downloaded to the robot using the dll-tool of the legOS (assuming that you have legOS installed to the robot and the robot is on):

dll robot3.lx
The program for legOS is really simple. It just sets up the function to handle the integrity messages using
lnp_integrity_set_handler(my_integrity_handler);
After this the function my_integrity_handler is called when a message is received, and it sets the motor levels and directions according to the messages received. The main method runs all the time and shows the number of messages reveived on the lcd. This number can be used to make sure that every message sent by the PC is received, as the PC's Java-interface shows the number of messages sent.