Top Banner
Robolab Tutorial Steve Dakin Hacienda Robotics [email protected]
33
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: RobolabTutorialSlides

Robolab Tutorial

Steve Dakin

Hacienda Robotics

[email protected]

Page 2: RobolabTutorialSlides

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

Page 3: RobolabTutorialSlides

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)

Page 4: RobolabTutorialSlides

Robolab Main Menu

Page 5: RobolabTutorialSlides

Administrator Screen

Page 6: RobolabTutorialSlides

Robolab Settings

Page 7: RobolabTutorialSlides

RCX Settings

Page 8: RobolabTutorialSlides

Select Program

Page 9: RobolabTutorialSlides

New Program

Page 10: RobolabTutorialSlides

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

Page 11: RobolabTutorialSlides

Functions Palette

Page 12: RobolabTutorialSlides

Function Sub-palettes and the Tools Palette

Page 13: RobolabTutorialSlides

Writing Robolab Programs

• Four ways to add blocks to a program:– Functions palette

– Context menu

– Insert command

– Replace command

• Use auto-wiring tool

• Connection point introspection

• Block arrangement commands

• Include Comments

Page 14: RobolabTutorialSlides

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

Page 15: RobolabTutorialSlides

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

Page 16: RobolabTutorialSlides

Conditionals and Resets

• Robolab term: forks• Used to branch the flow of

execution in your program• Usually associated with sensors• Every fork must have a corresponding merge• Nested forks can be tricky• In some situations you may

need to reset sensors before using them

Page 17: RobolabTutorialSlides

Conditional and Reset Program

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.

Page 18: RobolabTutorialSlides

Flow Control

• Robolab terms: jumps and loops

• Used to repeat a portion of your program

• Can be controlled with sensors, containers or other factors

Page 19: RobolabTutorialSlides

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

• 25 Task containers

• Good tool for teaching abstraction

Page 20: RobolabTutorialSlides

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.)

• Container’s container– Analogous to a pointer in traditional

programming languages– A modifier that specifies which container to use

based on the value of another container

Page 21: RobolabTutorialSlides

Advanced Container Program

As noted in the comment this program can be used to show container values on the RCX’s 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 container’s container). The last block before the red jump displays the computed container value on the RCX’s display.

Page 22: RobolabTutorialSlides

LEGO Remote Control

• Amazingly useful prototyping tool

• Send motor (output) commands to RCX

• Start and stop programs easily

• Send mail messages to RCX

• Best $20 you can spend on equipment

Page 23: RobolabTutorialSlides

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 you’d like

• Another good tool for teaching abstraction

Page 24: RobolabTutorialSlides

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.

Page 25: RobolabTutorialSlides

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

Page 26: RobolabTutorialSlides

How to Create Sub VIs

• Select the blocks you want in the Sub VI (to make input parameters to the Sub VI exclude modifiers)

• Select the Edit Createmenu command

• Tidy up the Sub VI and include it in your programs

Page 27: RobolabTutorialSlides

FLL Program (Two Missions)

Page 28: RobolabTutorialSlides

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

Page 29: RobolabTutorialSlides

Data Logging in Robolab

• Change Inventor level to Program Level 4 (adds an Investigator palette and specialized modifiers to the modifiers palette)

• Include blocks to initialize, start and stop data logging

• Run the program on the RCX

• Upload data to Robolab and analyze it in the Investigator area

Page 30: RobolabTutorialSlides

Data Logging Program

• Data logging modifiers

• Sample program– Initializes the red data set

to capture data from the light sensor connected to port one

– Starts data logging and captures 1 data point every second until 10 data points are collected

– Stops data logging

Page 31: RobolabTutorialSlides

Uploaded Data

Page 32: RobolabTutorialSlides

Other Advanced Topics

• Tasks– Enable your program to do multiple things at the

same time

• Events– Monitor and respond to specific conditions

• Direct mode– Another way to prototype

• LASM– A hacker’s delight

Page 33: RobolabTutorialSlides

Questions and Comments

• Please let me know what you think– Email: [email protected]

– Web: www.haciendarobotics.com/resources

– Tip: use Adobe Reader 7’s commenting support

• More info– www.legoeducation.com/sharedimages/resources/Mindstorms_Quickstart.pdf

– www.ceeo.tufts.edu/robolabatceeo/

– www.ceeo.tufts.edu/robolabatceeo/References/documentation/default.asp