the Lego RCX kit - Tufts University

advertisement
CHERP programming language for LEGO™ Mindstorms® RCX
CHERP (Creative Hybrid Environment for Robotic Programming) is a hybrid tangible/graphical
computer language designed to provide an engaging introduction to computer programming and
robotics for children in both formal and informal educational settings. With CHERP you can create
programs for robots like the LEGO™ Mindstorms® RCX. CHERP was funded by a National
Science Foundation grant (DRL-0735657)
CHERP was designed and implemented by many students working in the DevTech research
group at Tufts University directed by Prof. Marina Bers: Michael Horn, Jordan Crouser, David
Kiger. This project, which evolved through several iteration, was initially possible through a
collaboration between the DevTech Research Group and the Human Computer Interaction Lab at
Tufts University
Overview
Tangible/Graphical Programming
CHERP enables you to create both physical and graphical computer programs to control your
robot with icons that represent actions for your robot to perform. You can create physical
programs using labeled interlocking blocks or onscreen programs using graphical versions of the
icons. The shape of the interlocking blocks and icons creates a physical syntax that prevents the
creation of invalid programs. CHERP programs can be downloaded to the robots in a matter of
seconds.
How It Works
CHERP's physical blocks contain no embedded electronics or power supplies. Instead CHERP
uses a standard webcam connected to a desktop or laptop computer to take a picture of your
program, which it then converts into digital code using the circular bar-code-like TopCodes on
each block.
In the lab, we use specially made interlocking wooden cubes as our physical blocks, and we’ve
included instructions for how to make your own later in this document. However, you don’t need
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
to use blocks at all to get started! You can use the graphical interface as a stand-alone, or you
can simply print out the icons and use them for tangible interaction.
Installation (LEGO™ Mindstorms® RCX version)
Supported Platforms: Windows XP or later – Note: Windows 7 is trickier but still works (see
below)
System Requirements: Two or more USB 2.0 ports
Required Equipment:

2 Megapixel Logitech QuickCam Pro 9000

LEGO™ Mindstorms® RCX USB Tower
Required Software (included with CHERP installer):

Java 6 Development Kit (http://download.java.net/jdk6)

Java 6 Runtime Environment (**not included) (http://www.java.com/en/)

Logitech QuickCam Pro 9000 drivers (http://www.logitech.com/en-us/435/6333)

LEGO™ Mindstorms® RCX USB Tower drivers
Quick Instructions (Windows XP)
1. Download and run the installer attached to the CHERP webpage.
2. When prompted by the Logitech installer, select custom install, then select only the drivers.
*You may need to download and install these drivers directly from the website or installation CD.*
3. In the LEGO™Tower installer, choose “No, not this time” for connecting to the internet, then
“Install software automatically.”
4. (Optional) Label which ports were used for the Tower and webcam when installing the drivers
or plus in the Tower to each port and reinstall the drivers, which it needs installed per port.
Windows 7 Instructions
1. Download and run the installer attached to the CHERP webpage.
2. Install CHERP to the Desktop.
3. Install the Logitech drivers directly from the website (http://www.logitech.com/en-us/435/6333).
4. To install the LEGO™ USB Tower drivers, plug in the tower to a USB port. You will be promted
to install drivers. Select “Find drivers manually.” They are in the CHERP folder, in the
RCXTowerDrivers folder. Plug the Tower into the other USB ports and install the drivers again.
5. Move the CHERP folder to Program Files (click Okay to give permission to do so), and create a
new folder in Program Files called “tern_logs” (no quotes).
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
Testing the CHERP Interface
1. Make sure that the webcam and LEGO™ USB Tower drivers are installed, and that the
webcam and Tower are both plugged in before you start CHERP. *If they are plugged into
different USB ports than when the drivers were installed, you will have to reinstall the drivers for
those ports or switch which ports they are plugged into.*
2. Place the webcam on a table aimed along the tabletop or on the table’s edge looking down at
the floor. Leave at least 18 inches to two feet between the tangible icons/blocks and the webcam.
3. Double-click the CHERP desktop icon to open it. You will be promted to intall Java if you don’t
already have it. (http://www.java.com/en/)
4. Click the icon showing three colored blocks (the Tangible Download button). This should
capture an image from the webcam and display it on the right hand side of the screen.
a. If you get an error message indicating that the webcam is not plugged in, double-check
the connection and the webcam driver installation (you may need to unplug and re-plug
the webcam (perhaps to a different port) and/or restart CHERP.
b. If you get an error message indicating that you need a Begin block, the webcam is
working and you can test the Tower.
5. Create a short Graphical program (e.g. Begin-End) and click the Graphical Download button. If
you get an error to plug in the Tower, check the Tower’s driver installation/connection (you may
need to unplug and re-plug the webcam (perhaps to a different port) and/or restart CHERP. If you
get an error to turn your RCX on, the Tower is working.
Left: Graphical (“screen program”) Download button.
Right: Tangible (“block program”) Download button.
Interface Control
You may want to utilize full-screen mode to minimize distractions.

To enter and exit full-screen mode, hit Enter and Esc, respectively on your keyboard.
The system begins with only the first row of blocks (actions) showing. The second row contains
REPEATS and their parameters and the third row contains IFS and their parameters.

Typing Ctrl+(1 or 2 or 3) when out of full-screen mode shows that number of rows.
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
Programming with CHERP: Syntax
You can use either the Graphical Interface with the mouse or the Tangible Interface and printed
icons to create your program. The standard CHERP syntax is as follows:

Every program must start with a BEGIN block and end with and END block:

Control flow blocks such as IF, IF NOT, and REPEAT must be paired with their associated
END block, with the action(s) to be controlled in between. IF NOT blocks can only be used
after IF blocks.

REPEAT and IF blocks have a space for parameters. The coloring of the parameter icons
matches that of their control flow block. For REPEAT blocks, adding a parameter is optional
since the default is to REPEAT FOREVER. For IF blocks, the user must add a parameter.

In the Tangible Interface, the parameters’ TopCodes must align with those of the other blocks
and be visible to the camera to download the program to a robot.
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
Programming with CHERP: Build and Download a Program to a Robot
1. Plug in the LEGO™ USB Tower and webcam before starting CHERP. Make sure CHERP is
installed on your PC.
2. Open CHERP and build a program (see syntax guidelines above).
a. Graphical icons will ONLY connect to a BEGIN block or to an already connected
sequence of blocks. Unconnected graphical blocks will appear pale. Attach new
blocks to the end or middle of a program by dragging and dropping the new block
where you want to place it.
b. Icons will be read by the computer and the robot in sequential order starting with the
BEGIN block. Any icons not attached to a program chain starting with a BEGIN block
will not be read.
c.
To get rid of a Graphical icon or whole series of connected icons, drag them into the
rows of available icons at the bottom of the screen.
3. For the Tangible Interface, place the Tangible blocks at least 18 inches to two feet away from
the webcam.
a. If the icons are too close to the webcam, the computer vision will not see your
program properly.
b. You may get a prompt to include a BEGIN block in your program. If you do have a
BEGIN block and it appeared within the image, change the distance between the
webcam and your program and re-download the program.
4. Position the IR port (the smooth black rectangle) of your RCX-based robot near the front of
the LEGO™ USB Tower and make sure that the RCX is turned on.
5. Press the appropriate download button (mouse for Graphical; blocks for Tangible; see
below). The RCX will play a sound when the download is complete.
Note: To download a Graphical program it is NOT necessary to remove Tangible blocks from
the webcam and, likewise, to download a Tangible program, it is not necessary to remove an
existing Graphical program from the screen.
6. Place your robot where it can safely move around and press the green “Run” button on the
RCX to run the program.
7. Regardless of how your program was made, once you download it by pressing the
appropriate download button, you can then edit the program onscreen.
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
Using CHERP with your LEGO™ RCX-based robot:
You can build your robot using any combination of LEGO™ bricks, LEGO™ RCX robotic parts,
and recycled materials. To work with CHERP, your robot must conform to the following:

Motors must be attached to Ports A and/or C on the RCX brick. Depending on the
orientation of your motors and their wires, commands like FORWARD and BACKWARD may
be reversed. It is crucial to test that your robot behaves as expected and change the wire
orientation until it does.

Hint: attach the wires with the orientations in the image
before attaching the motors to the RCX.

This set-up will work if the IR port end of the robot (not
shown) will be its front. For other orientations, experiment
with the wire and motor placements! See what happens,
and make sure it does what you want before proceeding!

CHERP allows you to control your robot’s behavior using LIGHT or TOUCH SENSORS. If
you choose to use a sensor, it must be attached to Port 1 on your RCX brick.

To use a LEGO™ light bulb piece, attach it to Port B on your RCX brick.

You can download up to 5 programs on your RCX. Press the grey “Program” button on the
RXC to change which program “slot” you are running or downloading to.

See the next page for information and tips on re-installing firmware on your RCX.
Other than that, the sky is the limit! Have a blast building your robot!
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
Firmware
Your RXC brick needs firmware, software that allows it to receive and run CHERP programs. This
can be downloaded to your RCX from LEGO™’s RoboLab software.

The firmware will be lost after 30 seconds (or less!) of having one or more batteries shaken
loose or taken out.

Tips regarding firmware:


o
Use a flathead screwdriver or staple remover to pry the battery-holder’s prongs
outward, assuring a snug connection for the batteries.
o
Clean any corrosion off the contacts.
o
When replacing batteries, do so quickly.
If firmware is lost:
o
Plug in a Tower. Open RoboLab™. Click “Administrator.”
o
Click “Select COM Port” and choose USB 1. Click the empty check box in the lower
right hand corner.
o
Turn on the RCX and place its IR port in front of the Tower.
o
Click the Tower symbol, the RXC hardware type, and then “Download.”
o
The RCX’s screen will count up from 0 to about 2400. You may get an error message
if communication between the Tower and the RCX fails during the download. You
can “Try Again” or “Skip it” (stop downloading). Try a few times with the following in
mind:
o
You may need to turn off overhead lights and/or cover the RCX and Tower with a box
to avoid interference from infrared light in the environment.
o
You may also need to install firmware on one RXC at a time or position them away
from each other so multiple Towers’ signals do not interfere with each other.
o
You will hear a series of musical notes, 2 beeps, and more musical notes when the
firmware download finishes, which will take about four minutes.
For more information, visit:
http://www.lego.com/eng/education/mindstorms/home.asp?pagename=qsg_firmware
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
How to Build the CHERP Wooden Blocks
One full set will include:





2 Begin Blocks (with peg, no hole)
2 End Blocks (no peg, with hole)
28 Regular Blocks, 2 each of:
o Forward
o Backward
o Turn Left
o Turn Right
o Spin
o Shake
o Sing
o Beep
o Light On
o Light Off
o End-Repeat
o End-If
o If-Not
o End-If-Not
4 Double Blocks:
o 2 Repeat
o 2 If
12 Parameter labels (not affixed to blocks):
o Number labels 2-5 for use with REPEAT blocks
o PUSHED, RELEASED, LIGHT, DARK labels for use with IF blocks
o UNTIL PUSHED, UNTIL RELEASED, UNTIL LIGHT, UNTIL DARK labels for use
with REPEAT blocks
Materials:








40 1 3/4” wooden craft cubes (www.barclaywoods.com/craft_parts.htm)
40 3/8” x 1 1/4” fluted pin dowels (or 3/8” dowel, cut to size)
Yellow wood glue
Rubber cement or 3M spray adhesive
White card stock paper or printable sticker sheets for printing labels
Medium grade sandpaper
Velcro coins for attaching parameters to control flow blocks (Repeat, If)
OPTIONAL: Thick magnetic paper (Note, some brands of magnet paper recently became
thinner and less effective. Look for thick magnet paper.)
Tools:






10” drill press
3/8” drill bit
Drill press vice
Small hand saw (e.g. Tenon saw or Dovetail saw)
C-clamp or vice
Paper cutter (or access to a laser cutter!)
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
Instructions for building:
1. Current laboratory versions of CHERP are built out of 1 3/4” wooden craft cubes. These
cubes can be purchased from online vendors such as:
http://www.barclaywoods.com/craft_parts.htm Vendors may also tumble and drill the blocks
and glue pegs as in step 2 upon request and for an extra cost per block.
2. Assembling the wooden blocks.
a. Each block needs a 3/8” hole drilled through it. This is best done with a 10” drill
press and a 3/8” drill bit. Clamp each cube down with a vice and drill the hole with
the grain (i.e. drill into one of the end grain sides of the cube). It's important to drill
the holes exactly into the center of the cubes so that the blocks line up straight when
connected together in a program.
b. For the BEGIN and END blocks, drill the holes only half way through the cube. To
make REPEAT and IF blocks, drill holes only half-way through two cubes, then use
wood glue to glue the sides opposite the holes together to form double blocks.
c. Use wood glue to glue the pin dowels into the cubes. Spread glue on the bottom 1/2”
of the peg and twist it into the hole of the cube so as to distribute the glue evenly.
The dowel should stick out 3/4” from the hole. You can use a penny (which has 3/4”
diameter) to gauge the height.
d. After the glue has dried, sand the edges and corners of the blocks as needed to
make them comfortable to handle.
3. PNG files of the icons can be found on the CHERP website:
http://ase.tufts.edu/DevTech/tangiblek/research/cherp.asp
a. Print 2 copies of each file on printable sticker sheets or card stock using a color
printer. Simply cut out each individual label with a paper cutter or scissors and stick
on the blocks! Make sure each label is correctly oriented and smooth down the edges
to keep it from peeling.
b. We recommend opening the png files with The GIMP and printing at a high resolution
(600dpi) (http://www.gimp.org/downloads/). SVG (Inkscape) files are provided
in case you want to edit the icons http://inkscape.org/download/?lang=en .
c. If using card stock rather than sticker sheets, use rubber cement or 3M adhesive to
glue the block labels onto the four outside faces of the cubes. It is important that the
TopCode label be aligned as shown in the image above, with the dowel pointing to
the right and/or the hole to the left. This ensures that the webcam will be able to
correctly identify the block.
4. Put fuzzy Velcro coins in the center of the If blocks’ parameter space and scratchy coins
under the center of the If Parameters. Put scratchy Velcro coins in the lower left corner of the
Repeat Forever and fuzzy coins under the lower left corner of the Repeat parameters. This
way, you can’t attach If Parameters to a Repeat block and vice versa!
a. OPTIONAL, if using magnet paper for parameters: Printing on magnet sheets
works best on a laser printer rather than an ink-jet printer. You can always ink-jet
print on regular or sticker paper and attach that to the magnet paper. If using
magnetic parameters, glue 4 squares of magnet paper under the 4 parameter
spaces on Repeats and Ifs.
**Feel free to come up with your own materials and techniques for making a working set of
CHERP programming blocks! We’d love to know if you have a great tip to share!**
Copyright © 2011 DevTech Research Group
CHERP programming language for LEGO™ Mindstorms® RCX
For More Information:
The Developmental Technologies Research Group:
http://ase.tufts.edu/DevTech/
The TangibleK Project:
http://ase.tufts.edu/DevTech/tangiblek/
The Human-Computer Interaction Group at Tufts:
http://hci.cs.tufts.edu/
Tern:
http://hci.cs.tufts.edu/tern/
TopCodes Computer Vision Library:
http://hci.cs.tufts.edu/topcodes/
Please feel free to let us know how you’re using CHERP by emailing us at devtech@tufts.edu.
The TangibleK Project is supported by National Science Foundation Grant #DRL0735657. Any opinions, findings, and conclusions or recommendations expressed
in this material are those of the authors and do not necessarily reflect the views of
the National Science Foundation
CHERP is licensed with a Creative Commons Attribution-NonCommercial-ShareAlike
3.0 Unported License. Under this license, you may use and adapt this work, but you must attribute
the work to the DevTech Research Group. You may not use this work for commercial purposes.
Copyright © 2011 DevTech Research Group
Download