From IPRE Wiki
Revision as of 09:10, 11 May 2010 by Hetchienna18 (Talk | contribs)

Jump to: navigation, search

Lab 2: Programming Your Personal Robot - The Scribbler

Error creating thumbnail: Unable to save thumbnail to destination


  • Collect Your Scribbler Robot Kit
  • Connect to Your Robot
  • Write simple programs to control your robot
  • Personalize Your Robots

Lab Exercises

Collect Your Scribbler Robot Kit

Today, you will get your Scribbler Robot Kit. Each kit contains the following items:

  1. The Scribbler Robot
  2. The Fluke Dongle
  3. The Bluetooth Dongle (This is the USB key stuck on top of your robot)
  4. A GamePad Controller
  5. 6 AA batteries (already inserted in your robot)
  6. 4 color permanent marker pens
  7. A flashlight
  8. A carrying case for your kit

The main components of the kit are shown below:

Error creating thumbnail: Unable to save thumbnail to destination

Make sure that all of these parts are present in your kit. If anything is missing, or you are having trouble identifying something, please call your instructor to help you. If your fluke is detached from your robot, attach it now using the connector in the image above.

Your Fluke Number

Your Fluke dongle has a barcode with a number on it (a 6-digit number). You will need this number to create the connection to the computer. Write this number on your notebook. Also, using a Sharpie, write it down on the inside cover of your carry case, as well as on the underside of the robot itself, and on the Bluetooth dongle. This will also ensure that all your parts are accounted for. In case they get misplaced, we will be able to trace them back to you. We will also note this number in our records. As an example, we will use the number: 125802.

Configure Bluetooth dongle

Detach the Bluetooth dongle from your robot (it is stuck using Velcro tape) and remove its cap. Put the cap in a safe place in your carrying case. Locate an available USB port on your computer. The port may be in the front or on the back panel of the computer. Insert the Bluetooth dongle into the USB port. Your computer will announce that it has found a new device. Open the Bluetooth Devices configuration window (you can do this by double clicking on the Bluetooth logo on your computer screen (look in the bottom right hand corner). Alternatively you may have to navigate to the Settings --> Control Panel and select Bluetooth Devices. The following window should appear:

Error creating thumbnail: Unable to save thumbnail to destination

The window above shows the current Bluetooth devices available. In the case above there are none. You may see many on the computers in the lab. Next you will add a new Bluetooth device to this. Go ahead and press your mouse on the ADD button.

You will get a window from the Add Bluetooth Device Wizard:

Error creating thumbnail: Unable to save thumbnail to destination

Do as directed above, turn the robot on, and make sure the checkbox is selected (see above) and then press the Next button. The window shown below will appear. Your computer is going to go looking for all the available Bluetooth signals and report back whatever it finds. Below, you can see that it has found IPRE125802.

Error creating thumbnail: Unable to save thumbnail to destination

Any other Bluetooth devices available will also be displayed above. For example, if you are in the lab with other students, you will also see their robots (for example, IPRE125888 is also visible). Locate the Scribbler by the number of your robot (in this case IPRE125802) and select it in the window above. Then press the Next button. The next window that appears will ask for a passkey. This is shown below:

Error creating thumbnail: Unable to save thumbnail to destination

In the above window, select the "Use passkey found in the documentation" option, enter 1234 in the textbox and then press the Next button. The wizard will then configure your computer and the dongle to properly communicate with your Scribbler robot and report the following window:

Error creating thumbnail: Unable to save thumbnail to destination

Take a note of the "Outgoing COM port:" Above it is showing "COM10". You will need this information when you are ready to control your robot. Write it down on a piece of paper. Select Finish above and you will then get the window below showing that you have configured a Bluetooth service to IPRE125802 (it will show your robot's number).

Press OK and the device window will disappear.

Connecting to Your Robot

**Tip:** Make sure your game pad is plugged into a USB port before starting IDLE,

Once your Bluetooth device is configured, open the Python shell, IDLE. If you don't do this now, then when you try to do it later on, you will need to insert your game pad into a port later on and restart your python shell.

To start IDLE:
Double click the “Start Python.pyw” icon on your desktop.

The next step is to use Myro to communicate with your robot. To import all the functions from the Myro library, type the following command at the prompt:

>>> from myro import *

To connect to your robot, (Note: You will need to enter the passkey (1234) again to fully connect to your robot) type the following :

>>> init("comX")

X is the port number that your computer is using to communicate with your robot. So, you would type something like:

>>> init("com5")

The window below shows how to issue the command when the port com5 is being used:

Error creating thumbnail: Unable to save thumbnail to destination

The init command tries to establish communication between your computer and your robot. If this is successful, the robot responds with the Hello... line shown above. In the example above, the robot's name is Scribby. You can change this name to whatever you prefer. We will do this next.

Naming Your Robot

To name your robot SuperBot, type the following command:

>>> setName("SuperBot")

To give your robot a different name, replace the word SuperBot in the setName function above. To ask the robot its name, type the following:

>>> getName()

By using the setName command, you have permanently changed the name of your robot. It will report this name every time you connect to it using the initialize command:

>>> initialize("com5")
Waking robot from sleep...
Hello, I'm SuperBot!

Make Your Robot Sing

To make the robot beep, enter the following command at the prompt:

>>> beep(2, 700)

The command above tells your robot to make a beeping sound at 700 Hertz for 2 seconds. Try a combination of sounds. You can play two tones at once:

>>> beep(1, 400, 800)

This will play two tones, one at 400 Hz and the other at 800 Hz for 1 second.

You can define your own functions and place different beep commands in this function. An example of this giving below:

>>> def mySong():

Using Your Game Pad to Drive Your Robot Around

In this exercise, you will control your robot's movements using the game pad device in your kit. Your game pad should be plugged into a USB port (following the tip I gave you earlier). If you haven't done so yet then locate an available USB port on your computer and insert your game pad controller into this port. You will need to restart the shell to use the gamepad() function. The annotated image below shows a game pad similar to the one you will be using.

Error creating thumbnail: Unable to save thumbnail to destination

To use the game pad, type the following at the prompt:


You should see the following options when you do this:

        Pad   Action
     ------   -------
 Left/Right   turnLeft() and turnRight()
    Up/Down   forward() and backward()

     Button   Action
     ------   -------
          1   stop()
          2   takePicture()
          3   beep(.25, 523)
          4   beep(.25, 587)
          5   beep(.25, 659)
          6   speak('Hello. My name is Dribbler.')
          7   speak('Ouch! I'm a sensitive robot.')
          8   speak('I'm hungry. Do you have any batteries?')

Gamepad is now running... Press button 1 to stop.

Use the buttons on your game pad to move your robot around as well as to explore additional features of your robot (e.g. taking a picture, beeping or speaking).

Using Different Commands to Move Your Robot

In this section, you will explore other commands to control your robot's movements. The following commands allow your robot to move forward, backward, to the left, to the right, to spin and to stop all movement:

  • forward(amount, seconds)
  • backward(amount, seconds)
  • turnLeft(amount, seconds)
  • turnRight(amount, seconds)
  • rotate(amount, seconds)
  • stop()

You can, for example, type the following:

>>> forward(0.5, 2)

>>> turnLeft(.6, 1)

You can find these and all other robot commands in the Myro Reference Manual

Assignment 02

  1. Write Your Name: Place your robot on a big piece of paper, insert a Sharpie pen in your robot's pen port and using your game pad and/or other move commands, make your robot Scribble your name on the paper. This can be just your initials (Two initials are OK) or your entire first name. IT WILL NOT BE LIKE WRITING IT YOURSELF. Don't worry! Approximations are okay. Please Note: Be sure to enclose the sheets of paper with the wooden blocks that are available in the lab in order to prevent permanent pen marks being left on the lab floor. Also, when you are done working on one side of the paper, you can flip the sheets.
  2. Draw a Star: Place your robot on a big piece of paper (large sheets of paper will be available in the lab), insert a Sharpie pen in your robot's pen port and using your game pad and/or other move commands, make your robot draw a five point star. DO NOT EXPECT PERFECTION. YOU WILL MESS UP, THIS IS OKAY. If it has the general look of a star, you will succeed.
  3. Challenges: Explain some of the challenges you faced in using the game pad or the other move commands you used to control your robot's movements
  4. Readings: Read chapter 2 of your text.