Robotics Invention System 2.0
RCX Programming cycle zProgram Mindstorm PC-side software, i.e. RCX code or Robolab zRCX code translates your code to “Bytecode” zUse IR tower between PC & RCX to put your program in RCX RAM zFirmware interprests bytecode to m/c code zRCX processor executes machine code
InfraRed receiver must face IR Tower
This is a sensor port, NOT a motor port.
Sensor ports Motor ports
Logical Structure
RCX: The Robot’s Brain
What is sensing?
Why do robots need sensors?
PC side Software zLego RCX code zRoboLab zNQC (Not Quite C) zJava APIs (Application Programming Interfaces) It is a set of command libraries allow user to use JVM-equipped computer to communicate with RCX using original firmware
Firmware zlegOS (C/C++) zpbForth (Forth) zleJOS (LEGO Java OS)
Programming Legos with Java zhttp://www3.ltu.edu/~chung/os/Lego- leJOS.htm
HelloRCX C:\>lejosfirmdl Use --help for options. Transferring "/Apps/lejos/bin/../bin/lejos.srec" to RCX % C:\>
HelloRCX.java import josx.platform.rcx.*; public class HelloRCX { public static void main(String[] args) { Motor.A.forward(); Motor.C.forward(); try { Thread.sleep(2000); } catch (InterruptedException ie) {} Motor.A.stop(); Motor.C.stop(); } }
Compilation C:\>lejosc HelloRCX.java C:\>
Running C:\>set RCXTTY=COM2 C:\>lejos HelloRCX C:\>
RCX zTransfer & run on RCX zUse a PC-side emulator
Line Follower Robot zLine is darker than the floor zRobot will follow the left border of the line (e.g. it turna right to go toward the line, left to go away from line) zO/P port A, C to control wheel (motors) zO/P port B to ocntrol the arm
Main methd Int floor, line; Task Main() { initialize(); Calibrate(); Go_Straight(); While (true){ Check_Bumper(); Follow_Line(); }
Programming concepts zMutlitasking zStep-By-Step event driven scheme zPriority
Java Programming Concepts zThreads and Timing zMemory usage: yMinLCD, LCD, TextLCD ySound yMinSound zGarbage Collection
Debugging zEmulator zLCD (5 c/c) zPlay Sounds zleJOS displays uncaught exception