Robotics Invention System 2.0 .

Post on 16-Dec-2015

215 views 1 download

Tags:

Transcript of Robotics Invention System 2.0 .

Robotics Invention System 2.0

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

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

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

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

Firmware

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

Programming Legos with Java

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

HelloRCX

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

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

Transfer & run on RCX Use a PC-side emulator

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

Main methd

Int floor, line;Task Main(){

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

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

}

Programming concepts

MutlitaskingStep-By-Step event driven schemePriority

Java Programming Concepts

Threads and TimingMemory usage:

MinLCD, LCD, TextLCD Sound MinSound

Garbage Collection

Debugging

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