UserPreferences

Running Pyro


Running Pyro

See PyroInstallation for technical documentation about installation of the system. For this tutorial, it is assumed that you have installed and configured all of the components required to use Pyro.

For a newer introduction to Pyro, see The Pyro Interface

Getting Started: SRISim + Pioneer + Command Line Interaction

In what follows, we will provide detailed, step-by-step instructions on getting familiar with the Pyro environment. Our task here will be to use Pyro's command line control to experiment with a simulated Pioneer robot using the SRISim simulator.

You will perform the following steps:

  1. Start pyro.

  2. Choose a simulator.

  3. Specify a world in the simulator.

  4. Specify a robot platform.

  5. Interact with the robot

Later, when you wish to use an actual robot, you will skip Steps 2 and 3 above. In Pyro Brains, you will learn how to write and load a program, called a brain, to control the robot.

Step 1: Starting Pyro

If your installation is set up properly, all you have to do is enter the command in a terminal window:

 $ pyro

If all goes well, you will see the following window on your desktop:

http://.brynmawr.edu/~dkumar/wikigifs/PyroSplash.jpg

The top bar of the window above is a menu bar below which are several robot control buttons labelled, Step, Reload, Refresh, Run, Edit, Stop.

Step 2: Choose a simulator

Next, we will tell Pyro to choose a specific robot simulator. Click on the Simulators menu on the menu bar and and select the Load... option. You will get a pop-up file navigator dialog as shown below:

http://cs.brynmawr.edu/~dkumar/wikigifs/LoadSimulators.jpg

***Need to update this to show other simulators in picture above as well as add to text***

As you can see, the directory chosen (/usr/local/pyrobot/plugins/simulators) contains three simulators:

  1. Pioneer: This is the standard Pioneer simulator (Saphira 6.X)

  2. PyroSim: This is an experimental simulator. Outdated, not to be used, and will be removed in the next revision of the system.

  3. SRIsim: This is the current Pioneer simulator, provided from ActivMedia in their open-source Aria distribution. This is the recommended simulator for use as a Pioneer simulator.

As you can see in the picture above, we have selected the SRIsim simulator. Select it, and press the OK button to start the SRI Simulator. Another window will pop up as shown below:

http://cs.brynmawr.edu/~dkumar/wikigifs/SRIsimSplash.jpg

This is where the magic of Pyro starts to take effect. The simulator software, as provided by the developers, was started by Pyro. That is, if you were to use the simulator as stand alone software, which is how it is supplied, the window you see above is what you would get. We are setting up to use the simulator as provided, and yet, use Pyro to control the robot situated in the simulator by writing our own robot controller in Python. We are jumping way ahead here, so let's turn our attention back to the simulator.

The round object you see in the center of the screen is a visual representation of the simulated robot. Next, we will specify a world for the simulated robot.

Step 3: Specify a world in the simulator

In the SRIsim window, pull down the Load menu and select the world option (Remember, you are doing this in the SRIsim window, and not in the Pyro window). You will get the following World popup window:

http://cs.brynmawr.edu/~dkumar/wikigifs/WorldPopup.jpg

Three world files are already provided. All world files end in the suffix .wld Choose the file office.wld (as shown above). You may want to take note of the location of the world files. Later, go ahead and look inside the world files. A world is specified very simply, and by looking at the notation used, you can try to define a world of your own for your next experiment.

The office.wld file defines the floor plan of an office environment with rooms, desks, corridors, and cubicles. When you select the office world, you may not see the entire floor plan due to rendering scale. This is a good time to explore the menus and options available in the SRIsim window so that you can adjust the window size and the office world to proper scale. For starters, your mouse buttons (there are three of them, right?) are very useful here:

  1. Left clicking the mouse button in the SRIsim window, moves the robot to the location of mouse click. Try it several times.

  2. Right clicking the mouse button orients the robot towards the direction of the mouse click. The line running in the center of the robot points out towards the front of the robot. Try clicking the mouse in different directions to see how the mouse orients in response.

  3. The middle button (it is a little tricky to operate) will position the spot on the floor plan, where the mouse is clicked, in the center of the window. In order to fully appreciate what this does, first use the Shrink button in the menu bar to shrink the floor plan (the Grown button will do the opposite). Shrink the floor plan so that the entire plan is visible in the window. You may need to shrink and use the middle mouse button clicks to position and center the floor plan. Play with it to get the hang of it.

Once you have managed to shrink the floor plan and centered it (or resized the window), it may look like this:

http://cs.brynmawr.edu/~dkumar/wikigifs/OfficeWorld.jpg

Next, focus your attention on the bottom-left part of the SRIsim window. Notice that the location and orientation of the robot in the office world are specified as x, y, and th (for theta, the angle). The origin (0.0, 0.0) lies in the bottom left corner of the floor plan. The robot's orientation is shown at 90 degrees (pointing north or up). 0 degrees is located in the east direction. The x and y coordinates are specified in meters. Thus, the location of the robot, as shown is 4.5 meters away from the bottom left corner in the x direction and 2.2 meters in the y direction. Try moving the robot to various places in the world and also try reorienting it to get familiarized with the coordinate system being used here. This will come in useful later.

/!\ Note that the x, y, and theta measurement values represent the position and pose that the robot has in the simulated world. This information is not known to the robot, but only shown to us from our bird's eye, all-knowing view. Since robots don't have access to this information (unless they have a GPS and compass) they have to continually guess where they are!

Step 4: Specify a robot platform to Pyro

Next, we need to instantiate a robot in the Pyro environment (one that will link up the robot in the simulator to the one in our Python brain). This is the step that establishes a connection with the robot to be controlled: either in the simulated world (if we're using one), or the physical robot. Here is how you do it. First, select the Pyro window to make it active. From the menu bar in the Pyro window, pull down the Robot menu and select the Load... option. This will result in a Load Robots popup window shown below:

http://cs.brynmawr.edu/~dkumar/wikigifs/LoadRobots.jpg

This is where you specify the Python code that implements the drivers for specific robots. As you can see there are several robots listed above:

***Also need to add simulated khepera here, both in text and image above.***

  1. Khepera.py This is the driver module for controlling an actual Khepera robot.

  2. Piopneer2AT.py This is the driver for controlling an actual Pioneer 2 At robot.

  3. PioneerSimulated.py This is the driver for controlling the simulated Pioneer robot (in the already running SRIsim process). We will use this one (shown selected above).

  4. PyroSimRobot.py An older outdated simulator which will be removed in a future revision of the system. Do not use this one.

  5. SimpleRobot.py This is an example of a simple interface for a generic robot. This can be used to develop the prototype for other robots and/or simulators.

(!) Notice that all the robot files end in the suffix .py. Make a mental note of this and remember the location of these files. Later you can browse these files for the Python code used to control the robots.

As shown above, choose the PioneerSimulated.py file and press the OK button.

If you glance over in the terminal window where you started Pyro (in Step 1 above), you will notice that a series of messages were printed in response to your selection. These are diagnostics informing you of the things Pyro did in response to your selection. In this case, it establishes a connection with SRIsim, and loads the appropriate drivers to provide the robot's functional features to the Pyro system. Also, at the same time, you will notice that a rendering of the robot is now drawn in the Pyro window:

http://cs.brynmawr.edu/~dkumar/wikigifs/PyroRobot1.jpg

The display is a graphical rendering of the robot (looking at it from the top). Your mouse buttons can be used in this window to alternate the views:

  1. Clicking the left mouse button and dragging it will move the robot in the window,without changing the view.

  2. Clicking the middle mouse button and dragging will change the 3-dimensional orientation of the robot's view.

  3. Clicking and dragging the right mouse button will zoom the view in or out.

Try these various mouse operations. In addition to the robot (its front is marked by the yellow cube on the top), you will also notice the blue bands stretching out of the robot. These represent the readings obtained from the robot's sensors. However, when you first load the robot, the two bands you see do not correspond to the robot itself. The Pioneer robot has 8 sonar sensors in the front and 8 in the rear, both arranged in a semi-circle around the robot's body.

Below, we show the location of the robot and the corresponding sensor rendering.

http://cs.brynmawr.edu/~dkumar/wikigifs/OfficeWorld2.jpg http://cs.brynmawr.edu/~dkumar/wikigifs/PyroRobot2.jpg

Each time you move the robot in the simulator (by clicking the right and left mouse buttons), you will need to press the Refresh button to see the new sensor values rendered. Try it a few times.

You may also wish to orient the robot in the pyro window in the same direction as the simulated robot in the SRISim window, as this may make it easier to watch both at the same time.

Step 5: Interact with the robot

It is now possible to interact with the robot, so let's do something. All of the interactions will originate from the Pyro window, either through the Move menu, or through the command text area at the bottom of the window. First, let's get the robot to do something in the office world.

Make sure you have both the Pyro and SRISim windows visible. Pull down the Move menu in the Pyro window and you will notice six options: Forward, Backward, Left, Right, Stop, and Update. Select Forward and watch the robot moving forward in the SRISim window. (You will not see the sensors update in the Pyro window unless you stop the robot or click on Update.) Your robot might run into a wall, but you can easily move the robot by clicking the left mouse button in the SRISim window. You can stop the robot from moving by selecting the Stop option in the Move menu. Try out the other commands as well.

Next, we will try interacting with the robot through the Command text area at the bottom of the Pyro window. In the text area you can enter any robot command. Depending on the command you type, you will either see the robot respond by moving in its world, or if the command was a query for some kind of information, you will see the results printed in your terminal window. Organize your windows so that the following are visible on your desktop: The Pyro window, SRISim window, and the terminal window where you started pyro. This is shown below:

*** Grab a picture of the screen shot here

First, let's query the robot for some information. The Python variable robot is the handle that enables us to issue commands to the robot. The simplest command you can enter is

robot

This is equivalent to evaluating the value of the variable robot in Python. When you enter the above command, the response will be printed in the terminal window:

> robot => Robot name = 'PioneerSimulated', type = 'pioneer'

That is, the object robot has a name field whose value is PioneerSimulated and its type is pioneer.

/!\ Note that this information is displayed in the terminal window. You may have to arrange the windows so that you can see both the Pyro and the terminal window on your screen.

You can also get these values by typing Python field selectors:

robot.name

will return

> robot.name => PioneerSimulated
and
robot.type
will return
> robot.type => pioneer

You can also ask the robot to start moving forward by giving it the translate command.

robot.translate(0.1)

You will see the robot moving forward in the simulator window.

Now, issue a command for the robot to stop:

robot.stop()

You should see that the sonar values now correspond to the robot's location in the simulated world.

The translate() and stop() commands work as follows:

stop(): A method. Stops the robot's translation and rotation motors.

Similarly, you can ask the robot to rotate:

robot.rotate(0.2)
Here are the details of the rotate command:

You can combine the translation and rotation (i.e. moving forward/backward while rotating) using the move comand which is defined as follows:

/!\ Notice that negative values rotate to the right. This may seem unintuitive, but think of angles drawn in the first quadrant on a graph. Angles such as 45 degrees are shown increasing counter-clockwise.

Try this and all other commands to get comfortable with the various robot motions. The command text area has some convenient command history and command line editing functionality which is summarized in the table below:

--------------------------------------------------
  GUI Command line editing:
--------------------------------------------------
  Control+p or UpArrow        previous line
  Control+n or DownArrow      next line
  Control+a or Home           beginning of line
  Control+e or End            end of line
  Control+f or RightArrow     forward one character
  Control+b or LeftArrow      back one character
  Control+RightArrow          forward one word
  Control+LeftArrow           back one word

Cleaning up

Note that when you are done, you should close the Pyro window first. You can press control+c in the Terminal window, or click on the file close button of the Pyro window frame. Then you can close the simulator window.

Plots and Graphs

In addition to the 3D view of the robot, Pyro also sports the ability to draw simple graphs on the fly. There are two additional graphic views: brain views, and plots.

A Behavior-based brain can be viewed by selecting Brain -> View from the menu.

Plots of named sensor groups can be viewed by selecting Plot -> Load... from the menu.

Exercises

1. Creating a different world. In this exercise, you will create your own world. You might want to create a world looks like your environment so that you'll have it to use as a test ground before setting a real robot off into your real environment.

You will need to create your own world file (save it with the extension .wld). A world file is a text file that contains the definition of various components in the simulated world. Basically, a world is made up of line segments specified in a coordinate system with (0,0) at the bottom left corner, x values incrementing as you go right and y values incrementing as you go up.

In the world file, you start by defining the width and the height of the world on the first two lines as shown below:

width 20000
height 15000
The units used are millimeters. Thus the world above is 20 meters long and 15 meters deep. The width and height above refer to the width and height of the rectangle on your display, thus what we specify as width is the length and what we specify as height is the depth of the world. It is all about keeping the right frame of reference.

Any line starting with a semicolon is treated as a comment. You can also use a semicolon anywhere in a line and everything following the semicolon until the end of the line is treated as a comment.

Line segments are then specified, generally, one segment on each line, by giving the (x1, y1) and the (x2, y2) coordinates of the line (in the coordinate system and units mentioned above). For example, the following four lines specify the edge of the world.

; The world boundary
0 0 0 15000                
0 0 20000 0
20000 0 20000 15000
0 15000 20000 15000
In a world, the starting position and orientation of the robot can be specified using a position command (the numbers are x, y, and theta):
; the starting location of the robot
position 2000 5000 90
This will get you started on some simple worlds. Creating a simulation of your real environment will take a bit more time.

2. Moving in Your New World: Load your new world into the simulator, then type in commands at the command line to move your robot around your new world. Can you command the robot to get from one room to another?

3. Try #2 again, but this time only look at the Pyro window and hide the simulator view. You should click Refresh to update the sensors in the Pyro window often. Can you manuever the robot by only looking at the sensor readings? To make it even more realistic, have someone else load a random map so that you have no idea of the surrounding map. Now, you have a sense of the difficulty facing these poor robots!

Next Section: Pyro Sensors

Pyro Modules Table of Contents

Modules

  1. PyroModuleIntroduction

  2. PyroModuleObjectOverview

  3. PyroModulePythonIntro

  4. PyroModuleDirectControl

  5. PyroModuleSequencingControl

  6. PyroModuleBehaviorBasedControl

  7. PyroModuleReinforcementLearning

  8. PyroModuleNeuralNetworks

  9. PyroModuleEvolutionaryAlgorithms

  10. PyroModuleComputerVision

  11. PyroModuleMapping

  12. PyroModuleMultirobot

  13. FurtherReading

Additional Resources

  1. PyroIndex

  2. PyroAdvancedTopics

  3. PyroUserManual

  4. [WWW]Pyro Tutorial Movies

Reference: PyroSiteNotes