Robofest 2005
RCX code
Workshop
Jan 29, 2005
CJ Chung
chung
1
Agenda
• Comparison of RCX code and RoboLab
•
•
•
•
chung
programming languages (Chung, 15 min)
RIS RCX code programming tutorial
(Shvartsman, 70 min)
Break – 10 min
RIS RCX code programming tutorial 2
(Shvartsman, 70 min)
RCX code tips (Chung, 15 min)
2
Assistants
• Warren Beard
• Steven Kryskalla
chung
3
Why Icon based Visual
Programming Languages?
chung
4
Right
Lane
Ends
chung
5
chung
6
Go forward for 2 sec. and stop
chung
program test {
#include <RCX2.h>
#include <RCX2MLT.h>
#include <RCX2Sounds.h>
#include <RCX2Def.h>
main {
ext InterfaceType "kFreestyle"
rcx_ClearTimers
bbs_GlobalReset([A B C])
try {
on [ A C ]
} retry on fail
wait 200
try {
off [ A C ]
} retry on fail
}
}
7
Go forward for 2 sec. and stop
chung
8
RCX code vs RoboLab
Comparison Table
Product Name
Computer Platform
Age group
Programming level
Object Oriented
Structured?
chung
RoboLab
LEGO Mindstorms
for Schools
PC Compatibles,
Apple Macintosh
8 - 16+
Easy to difficult
levels
No
No. Becomes
spaghetti code
RCX code
LEGO Mindstorms,
retail version
PC Compatibles
only
12+
One level
No
Yes
9
Control structure
representation
Synchronization of
multi tasks
Variable operations
Arrays
Floating-point
numbers
Data logging &
visualization
Site License
Printing
Icon manipulation
chung
Version upgrade
Test-based
structured
Flow-chart like
programming like
Introduced some
Kill-restart method ideas, but not
possible
working…
Better than
Limited
RoboLab
No
No
No
No
Yes
Available
Yes
Hard to “wire”
icons
Based on LabView
and upgraded by
Tufts Univ
No
Not available.
No
Easy to connect
icons
Stopped
10
Robofest Statistics: Programming
Language Used by Teams in
Robofest 2004
7%
6%
9%
25%
Java
NQC
RCX code
RoboLab
other
Data from 85 teams
chung
53%
11
RoboLab vs. RCX code
Follow a line and stop when
the bumper is hit.
chung
12
RCX code hands-on workshop
by
Andrey Shvartsman
(See another slide: intro2RCX.ppt)
chung
13
Robotic
Invention
System
RCX code
2.0
Use them
Block Types
chung
14
Avoid using them.
They are for a
specific robot.
They won’t work
on your robot.
Avoid using
Sensors unless
you have
independent tasks
chung
15
Power Commands
• On
• On For
• Off
 Coast
 Brake
• Set Power: Min 1, Max 8
• Set Direction
• Reverse Direction: Not
recommended to use. Use Set
Direction instead.
chung
16
Can you simplify this program?
chung
17
Wait Commands
• Wait For
• Wait Until
chung
18
Remember!
• Cover your robot and IR tower
when you download programs
• Save your programs
• File Names should be meaningful
• Use logbook and comment
chung
19
Repeat
•
•
•
•
chung
Repeat For
Repeat Forever
Repeat While
Repeat Until: sensor watcher
20
Difference between Repeat Until
and Repeat While
• Repeat Until command constantly
monitors the sensor or variable and
interrupts the repeated set of commands
as soon as the condition is true.
• Repeat While: repeat a stack of
commands as long as a condition is true;
command only tests the sensor or variable
at the end of each repeat.
chung
21
Structured Programming in
RCX code
• Use My Blocks
• No parameters
• Macros, not subroutines
chung
22
My Blocks
chung
23
Opening a saved program
• Never use File | Open! There is a bug
involving MyCommands
• Use Main Menu | Program | Vault
chung
24
Line following - Zigzag methods
chung
25
chung
26
Zigzag without
Sensor
Watchers
chung
27
What will happen if the robot
starts here…
here
chung
28
Line following with 2 light
sensors
chung
29
Line following with 2 light
sensors II
chung
30
Line following with 2 light
sensors III
chung
31
End Program
• Without “End Program”, you need to press
Green button to stop the program
chung
32
Comments
• Comment Block
• Log book
chung
33
Useful Techniques
• End Program
• LCD View
• Display Value




Timers
Variables
Sensors
IR Messages
• Beeps and Tones to debug by hearing
chung
34
Question:
Move forward until
the robot reaches a
black line (area) or
hit a wall (detected
by a touch sensor)
chung
35
Solution using sensor watchers
chung
36
Solution without using
Sensor watchers
Move forward until
the robot reaches a
black line (area) or
hit a wall (detected
by a touch sensor)
chung
37
Solution without using
Sensor watchers with
using a variable
Move forward until
the robot reaches a
black line (area) or
hit a wall (detected
by a touch sensor)
chung
?
38
RIS 2.0 XP Patch
will stop the Robotics Invention
System 2.0 launcher window from
appearing when Windows XP is
started.
Now available for download at
www.legomindstorms.com
chung
39
Epilog
•
•
•
•
•
chung
Read Robofest 2005 Rules
Control vs. Speed
Exhibition
FAQ
LTU is planning Robofest Playing Field
Sale: Please contact [email protected]
40
Descargar

Robofest Info Meeting