Robolab Tutorial Slides
Robolab Tutorial Slides
Introduction
Target audience
Coaches and parents of kids in the FIRST LEGO League program
Objectives
Overview of Robolab programming environment and concepts Some tips and tricks acquired over the years Help you so that you can better help your kids
Contents
Setting up Robolab
Administrator area, Robolab settings, RCX settings
Beginner Topics
Writing programs, Basic control blocks (motors, waits, modifiers), Conditionals (forks, resets)
Intermediate Topics
Flow control (jumps, loops), Variables (containers), LEGO MINDSTORMS Remote Control
Advanced Topics
Subroutines, Sub VIs, Data logging (Investigator)
Administrator Screen
Robolab Settings
RCX Settings
Select Program
New Program
Programming Strategy
Define what you want the program or robot to do Identify high-level tasks Write pseudo-code (in pseudo-English) Use pseudo-code as comments to define program skeleton Divide and conquer Program in pairs: pilot and co-pilot
Functions Palette
Use auto-wiring tool Connection point introspection Block arrangement commands Include Comments
Modifiers
Two types of modifiers
Reference Value-of
Reference modifiers specify the where Value-of modifiers specify the what Not very intuitive, but with practice and use of the online help choosing the right modifier gets easier. Can connect multiple blocks to same modifier
Modifiers Program
Reset the rotation sensor on port 1 Turn on motors on ports A and C Wait until touch sensor on port 2 is pressed Stop motors on ports A and C Display the value of port 2 on the RCX
This program demonstrates one way of using a single RCX program slot to run two different programs. Start with a robot containing a downward facing light sensor. Next, find a brick that is sufficiently different in color than the mat area in base. The blue container will contain 1 if you use the brick, 0 otherwise. In your main program you can use a fork that branches depending on the value in the blue container.
Flow Control
Robolab terms: jumps and loops Used to repeat a portion of your program Can be controlled with sensors, containers or other factors
Variables
Robolab term: containers Containers hold values that can change during the execution of a program 23 value containers, including 3 defaults:
0 = red container 1 = blue container 2 = yellow container
Advanced Containers
Formula container
Sets a container value based on a formula Supports basic arithmetic expressions and shorthand mnemonics for other values (containers, input ports, mail messages, etc.)
Containers container
Analogous to a pointer in traditional programming languages A modifier that specifies which container to use based on the value of another container
As noted in the comment this program can be used to show container values on the RCXs display. Container 22 holds the number of the container to display (0, 1 or 2). Container 21 holds a computed value that shows the container number followed by its value. The program uses the formula container to multiply the value in container 22 by 1000 to move it to the left three places on the display. Next it adds the value of the container whose container number is specified in container 22 (this is accomplished using the containers container). The last block before the red jump displays the computed container value on the RCXs display.
Subroutines
Analogous to subroutines in other programming languages Allow you to reuse code
Reduces program size Makes programs more robust
Define first then call as many times as youd like Another good tool for teaching abstraction
Subroutine Program
This program demonstrates how you can define two subroutines and call them from within your program based on the value in a container. By changing the value in the container you control which subroutine is called. This is a useful way to observe what your program is doing while it runs.
Sub VIs
VIs (Virtual Instruments) = programs Sub VIs are like program modules (libraries) Act like macros (code is repeated each time it is used) Improve readability
Can create your own icons for Sub VIs Only the Sub VI block appears in your main program
Data Logging
Robolab and the RCX are a form of embedded device programming
Download and run Difficult to monitor and debug interactively
Data logging captures values while a program runs on the RCX Analyze captured data in the Investigator area
Uploaded Data
Events
Monitor and respond to specific conditions
Direct mode
Another way to prototype
LASM
A hackers delight
More info
www.legoeducation.com/sharedimages/resources/Mindstorms_Quickstart.pdf www.ceeo.tufts.edu/robolabatceeo/ www.ceeo.tufts.edu/robolabatceeo/References/documentation/default.asp