Robotics Invention System 2.0 .

22
Robotics Invention System 2.0 http://shop.lego.com/product.asp?p=3804

Transcript of Robotics Invention System 2.0 .

Page 1: Robotics Invention System 2.0 .

Robotics Invention System 2.0

http://shop.lego.com/product.asp?p=3804

Page 2: Robotics Invention System 2.0 .

RCX Programming cycle

Program Mindstorm PC-side software, i.e. RCX code or Robolab

RCX code translates your code to “Bytecode”

Use IR tower between PC & RCX to put your program in RCX RAM

Firmware interprests bytecode to m/c code

RCX processor executes machine code

Page 3: Robotics Invention System 2.0 .

InfraRed receiver must face IR Tower

Page 4: Robotics Invention System 2.0 .

This is a sensor port, NOT a motor port.

Page 5: Robotics Invention System 2.0 .

Sensor ports

Motor ports

Page 6: Robotics Invention System 2.0 .

Logical Structure

Page 7: Robotics Invention System 2.0 .

RCX: The Robot’s Brain

Page 8: Robotics Invention System 2.0 .

What is sensing?

Page 9: Robotics Invention System 2.0 .

Why do robots need sensors?

Page 10: Robotics Invention System 2.0 .

PC side Software

Lego RCX codeRoboLabNQC (Not Quite C)Java 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

Page 11: Robotics Invention System 2.0 .

Firmware

legOS (C/C++)pbForth (Forth)leJOS (LEGO Java OS)

Page 12: Robotics Invention System 2.0 .

Programming Legos with Java

http://www3.ltu.edu/~chung/os/Lego-leJOS.htm

Page 13: Robotics Invention System 2.0 .

HelloRCX

C:\>lejosfirmdlUse --help for options.Transferring "/Apps/lejos/bin/../bin/lejos.srec" to RCX...100%

C:\>

Page 14: Robotics Invention System 2.0 .

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();  }}

Page 15: Robotics Invention System 2.0 .

Compilation

C:\>lejosc HelloRCX.java

C:\>

Page 16: Robotics Invention System 2.0 .

Running

C:\>set RCXTTY=COM2

C:\>lejos HelloRCX

C:\>

Page 17: Robotics Invention System 2.0 .

RCX

Transfer & run on RCX Use a PC-side emulator

Page 18: Robotics Invention System 2.0 .

Line Follower Robot

Line is darker than the floorRobot will follow the left border of

the line (e.g. it turna right to go toward the line, left to go away from line)

O/P port A, C to control wheel (motors)

O/P port B to ocntrol the arm

Page 19: Robotics Invention System 2.0 .

Main methd

Int floor, line;Task Main(){

initialize();Calibrate();Go_Straight();

While (true){Check_Bumper();Follow_Line();}

}

Page 20: Robotics Invention System 2.0 .

Programming concepts

MutlitaskingStep-By-Step event driven schemePriority

Page 21: Robotics Invention System 2.0 .

Java Programming Concepts

Threads and TimingMemory usage:

MinLCD, LCD, TextLCD Sound MinSound

Garbage Collection

Page 22: Robotics Invention System 2.0 .

Debugging

EmulatorLCD (5 c/c)Play SoundsleJOS displays uncaught exception