RoboLab Tutorials

Lesson 1

Objective

This lesson focuses on introducing the Lego Mindstorms and RoboLab. Very basic definitions of the Lego robotics and the RoboLab programming environment are developed in this first tutorial.

Outline

Instruction

RCX

The Robotic Command Explorer (RCX) is the heart of a relatively new Lego initiative into the creation of an inexpensive robotics toolkit for both education and entertainment. This large yellow Lego brick contains within it a miniature computer of sorts that is capable of powering output devices like motors and lamps as well as reading data from input devices like buttons, rotation sensors, and light sensors. Most importantly, the RCX has the ability to communicate with a standard computer like a PC or a Mac through its infra-red (IR) port.

Figure 1
Figure 1: The RCX brick with some attached input and output devices.

Creating programs for the RCX takes place on a traditional computer. Once a program has been written it is downloaded to the RCX through an IR tower attached to the computer. The program is sent from the computer's IR tower to the IR port on the RCX. The RCX stores the program in one of its five program slots and later executes it when its run button is pressed. The computer can also send instructions to the RCX that are run immediately, but to do this, the RCX must always be close to and facing the computer's IR tower.

Figure 2
Figure 2: The computer's IR tower.

Just like a regular computer, the RCX can be programmed using a variety of languages. The RCX is sold in many toy stores as part of the Robotics Invention System which contains a language for constructing RCX programs graphically. This language is easy to use because its structure is reminiscent of Lego building activities, but it lacks some of the power seen in normal programming languages.

Fortunately, many other RCX programming environments are available for free or for minimal cost. Many of these RCX languages mimic or are derivatives of traditional text-based programming languages such as C, Java, or Visual Basic. These languages are much more powerful than the one bundled with the toy-store RCX, but can be overwhelming for those without a programming background.

Another option is available for programming the RCX that retains the ease of use of graphical programming while providing all of the powerful programming structures available in the text-based languages. The use of this programming environment, called RoboLab, will be the focus of the remainder of these tutorials.

RoboLab

RoboLab is a set of programming functionalities built by Tufts University to be run in a long-standing graphical programming environment called LabVIEW developed by National Instruments. In this language, programs for the RCX are created by wiring together blocks of instructions called VIs. The programs can then be downloaded to the RCX from within RoboLab.

When RoboLab first starts up, three options are presented to the user. Most if not all of the programming exercisers in this tutorial will be done in the Programmer section of RoboLab. When the Programmer button is clicked, another screen appears showing the various levels within RoboLab.

Figure 3
Figure 3: The opening screen of RoboLab.
Figure 4
Figure 4: The levels within the Programmer section of RoboLab.

The first levels of programming, the Pilot levels, are listed at the top of this screen. These simplistic levels are generally used in introducing young children to RoboLab. Programs are constructed in the Pilot levels by simply selecting instructions from a limited set of menus. Moving from Pilot 1 through Pilot 4 increases the total number of menus and variety of instructions. However, the structure of any program created using the Pilot levels is fixed, thus severely limiting what a programmer can accomplish.

Figure 5
Figure 5: A simple example of a Pilot level program that turns on a motor for 4 seconds.

These tutorials will focus on the second set of programming levels called Inventor. The Inventor programming section presents a blank program slate that can be filled in with any size program containing any variety of instruction VIs. Moving from Inventor 1 through Inventor 4 increases the range of VIs available for use in RCX programs. The levels may be useful in gradually introducing one to the programming environment, but these tutorials accomplish that in their own right. The highest level of Inventor, level 4, will be used for all of the following examples.

When a new Inventor 4 program is started, four windows appear on the screen. The bluish-purple window, called the block diagram, is the programming window. It starts off with two VIs, the green light and the red light, showing the start and the end of the yet-to-be-built program. The tall gray window, the function palette, contains all of the VIs that are available to be inserted into the RoboLab program. These VIs either appear directly on the function palette as it stands or are sorted into submenus. The small gray window, the tool palette, contains a number of tools useful in moving VIs, wiring VIs, and making text comments. The black and bluish-purple window, the front panel, is normally unused in RoboLab and just provides some helpful hints.

Figure 6
Figure 6: The initial state of an Inventor 4 program. The four main windows starting the bottom and proceeding clockwise are the block diagram, the tools palette, the front panel, and the function palette.

These windows are all that are needed to create programs in RoboLab. Programmers pick up VIs from the function palette, drop them on the block diagram, and then wire them together to make their programs. The following lessons introduce this procedure and make use of it repeatedly while demonstrating the common uses of the RoboLab VIs.

Getting help

One of the most important features of RoboLab is its help system. The number of VIs available for use in programs is substantial, and the number of ways they can be wired together on the block diagram is even greater. As a result, having a reference built into RoboLab that is capable of showing what each VI does and how to use it is invaluable.

When the block diagram or function palette is visible, the RoboLab context help window can be accessed by pressing Ctrl-H on the PC or Apple-H on the Mac. When these keys are pressed, a small window appears that provides information about each VI. This information typical includes what action the VI performs and what other VIs can be wired to it. Some help screens also provide additional information in the form of examples accessible through a hyperlink in the small help window. Clicking such a link opens a larger window in which an example is provided.

Figure 7
Figure 7: The context help window. Information about a VI is given including what action it performs, what can be wired to it, and how it is used.
Figure 8
Figure 8: The additional help window. More information about a VI is provided along with a simple example that can be opened and modified.