the Lego WeDO kit - Tufts University

advertisement
CHERP programming language for LEGO WeDo™ robotic kit
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 ones built with Lego WeDo Construction kit. 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 and Safoura Seddighin. 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
1
CHERP programming language for LEGO WeDo™ robotic kit
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 ( This version of CHERP works with the LEGO WeDo™ robotic kit)
Supported Platforms: Windows XP or better
System Requirements: Two or more USB 2.0 ports
Required Equipment:
The newest version of CHERP, called CherpW, works with both the embedded and external
cameras. That means that it will automatically detect any type of camera on your computer to
take the pictures with. If you do not have an embedded camera on your computer, you will need
an external camera. You need to make sure that the proper driver for the external camera is
installed on your computer before it is used by the software. Also, if you have both an embedded
and an external camera on your camera, the external camera will the first choice to be used by
the software. Therefore, the required equipments are:
 Any type of webcam, embedded or external.

LEGO WeDo™ Construction Kit
Required Software (included with CherpW installer):

Java 7 Development Kit (http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download432154.html)

LEGO WeDo™ driver
Quick Instructions
1. Download and run the installer called “CherpW”, attached to the CHERP webpage. This is the
newest version of Cherp, modified to adopt LEGO WeDo™ hardware.
2. When prompted by the Java 7 Rutime, agree with the default settings and go on..
3. To install the appropriate LEGO WeDo™ driver, you need to have the LEGO WeDo™ Hub
connected to the computer usb port. When prompted by the LEGO WeDo™ driver installer,
choose the Lego WeDo device/USB Human Interface Device (Vendor ID# 0x0694 and product
ID# 0x0003) and accept all the steps and options(including “saving” the driver file). Then, click
the “Install Now” button and wait for installation to complete.
Testing the CHERP Interface
1. Make sure that the webcam (if you are using an external camera) and the LEGO WeDo™
drivers are installed, and that the webcam and Lego WeDo Robot are both plugged in before you
start CherpW. *If they are plugged into different USB ports than when the drivers were
installed, you might have to switch the ports which they are plugged into, so the software
recognizes the LEGO WeDo™ hardware and the external camera .*
If you are using your computer’s internal (embedded) camera, you will not need to do anything in
regards to the camera.
2. Place the external webcam on a table aimed along the tabletop or on the table’s edge looking
down at the floor. If you are using an internal camera, you need to make sure that it is aligned in
2
CHERP programming language for LEGO WeDo™ robotic kit
the way that can capture a clear picture of the tangible icons/blocks .Leave at least 18 inches to
two feet between the tangible icons/blocks and the webcam.
3. Double-click the CherpW desktop icon to open it. 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, it means that
no internal or external webcam was detected on your computer. Please 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 CherpW.
b. If you get an error message indicating that you need a Begin block, the webcam is
working.
4. Create a short Graphical program (e.g. Begin-End) and click the Graphical Download button.
If everything is set up right, the robot should start running the program immediately.
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.
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.
3
CHERP programming language for LEGO WeDo™ robotic kit

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.
Note: The latest version of CHERP, CherpW, is designed to work with LEGO WeDo™
hardware. Therefore, if you do not have the LEGO WeDo™ hub (the first and main part of the
robot that is connected to the computer USB port), and try to run a program, you will receive
a message that prompts to connect the robot to the computer. However, those actions that do
not require the robot to run such as SING and BEEP, will still run.
If you have an IF or REPEAT block with NEAR, FAR, UNTIL FAR or UNTIL NEAR condition
in your program, you will receive a message prompting you to use a distance sensor, only
when you do not have one connected.
4
CHERP programming language for LEGO WeDo™ robotic kit
Programming with CHERP: Build and run a program by a Robot
1. Plug in the LEGO WeDo™ and webcam(if an external webcam is used), before starting
CherpW. Make sure CherpW is installed on your PC.
2. Open CherpW 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. Press the appropriate download button (mouse for Graphical; blocks for Tangible; see
below). After downloading the program, the LEGO WeDo™ robot starts the program
immediately.
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.
5. Place your robot where it can safely move. Keep in mind that since the robot is connected to
the computer you need to allow enough and appropriate space for it moves. You can use
extension cords to extend the length of the wire that has connected the robot to the USB port
of the computer and thus give more freedom to the robot.
6. Regardless of how your program was made, once you download it by pressing the
appropriate download button, you can then edit the program onscreen.
5
CHERP programming language for LEGO WeDo™ robotic kit
Using CHERP with you LEGO WeDo™ robot:
You can build your robot using any combination of LEGO™ bricks, LEGO WeDo™ robotic parts,
and recycled materials. To work with CherpW, your robot must conform to the following:
There is one hub, one motor, one distance sensor and one tilt sensor in every construction kit.
Hubs are quite expensive if you plan to have extras for every kit. Motors are fairly affordable.
Here you can see possible combinations of hubs and motors and the types of the robots you can
have. Note that the Tilt sensor is not used with CherpW and only Distance sensor can be
recognized by the software.
If only one HUB is used:


Two motors can be connected to two connections on the hub. This would give you a two
motor car with no sensors and the assembly would be quite simple.
The set of possible commands: Forward, Backward, TR, TL, Shake, Spin, Beep, Sing,
Repeat (with number condition). If command can NOT be implemented.
One motor and one sensor can each get connected to one of the connections of the hub.
This would give you a one motor car with a distance sensor. The assembly might be more
complex.
The set of possible commands: Forward, Backward, Beep, Sing, Repeat (with sensor
condition and any of the stated commands as its action), If(sensor condition and any of the
stated commands as its action)
It is physically impossible to have a two motor car with two motors and one sensor all connected
to one hub and still have a fully functional robot.
If two HUBs are used:
A robot with more functionalities can be made. A complete set of commands mentioned above
using the distance sensor can be implemented.
Some point to consider while building the robots are:

Motors must be attached to the two ports on the LEGO WeDo™ hub. 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.

CHERP allows you to control your robot’s behavior using Distance sensor. If you choose to
use a sensor, it does not matter to which connection on the hub you attach it to.

You can run one program at the time using CHERP and the LEGO WeDo™ robot. Every time
you build a program, you would have to press one of the buttons (graphical or tangible), see
the results and then start making another one or modify the one you just ran.
Other than that, the sky is the limit! Have a blast building your robot!
6
CHERP programming language for LEGO WeDo™ robotic kit
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.
7
CHERP programming language for LEGO WeDo™ robotic kit
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)
24 Regular Blocks, 2 each of:
o Forward
o Backward
o Turn Left
o Turn Right
o Spin
o Shake
o Sing
o Beep
o End-Repeat
o End-If
o If-Not
o End-If-Not
4 Double Blocks:
o 2 Repeat
o 2 If
8 Parameter labels (not affixed to blocks):
o Number labels 2-5 for use with REPEAT blocks
o NEAR, FAR, labels for use with IF blocks
o UNTIL NEAR, UNTIL FAR, labels for use with REPEAT blocks
Materials:







36 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
OPTIONAL: Thick magnetic paper or Velcro coins for control flow blocks and parameters
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!)
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:
8
CHERP programming language for LEGO WeDo™ robotic kit
http://www.barclaywoods.com/craft_parts.htm
2. Each block will need to have a 3/8” hole drilled through the cube. This is best done with a 10”
drill press and a 3/8” drill bit. Each cube should be clamped down with a vice and the hole should
be drilled with the grain (i.e. drill into one of the end grain sides of the cube). It's important that
the holes be drilled exactly into the center of the cubes so that the blocks line up straight when
connected together in a program.
3. For the START and END blocks, holes should only be drilled half way through the cube. For
the REPEAT and IF blocks, drill the holes only half-way through two cubes. Then use wood glue
to glue the sides opposite the holes together to form double blocks.
4. 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 proper
height.
5. After the glue has dried, sand the edges and corners of the blocks to make them smooth.
6. PDF files of the icons and parameters can be found on the CHERP website:
http://ase.tufts.edu/DevTech/tangiblek/research/cherp.asp
Print out two copies of the icons and one copy of the parameters on printable sticker sheets or
card stock using a color printer, and cut out each individual label with a paper cutter.
OPTIONAL: You may want to print the labels for the parameters on magnetic paper so that the
parameter icons can easily stick to the control flow blocks. This works best on a laser printer
rather than an ink-jet printer.
7. If using magnetic parameters, glue 4 squares of magnet paper under the 4 parameter spaces
on double-blocks.
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.
If using Velcro coins to attach parameters, be sure to place the coins in the proper location to
ensure that the parameters are in line with the other blocks. For instance, place Velcro coins on
the bottom left corner of the REPEAT FOREVER spaces or in the center of the Ifs’ empty
parameter spaces, and place the other half of the coin in the corresponding spot on the
parameters. Also be sure to place the correct half of the coin pairs (scratchy or fuzzy) on the
block versus the parameter.
7. Feel free to come up with your own materials and techniques for making a working set of
Tangible blocks! Feel free to let us know if you have a great tip to share!
CHERP is licensed with a Creative Commons Attribution-NonCommercialShareAlike 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.
9
Download