Home ]Software ]Curriculum ]Hardware ]Community ]News ]Publications ]Search ]


1. Pyro Cheat Sheet

THIS IS NO LONGER VALID FOR PYRO 3.0.0

This page is a brief overview of the main Pyro objects, and their methods.

1.1. Robot Object

A robot object can be accessed via any brain through the Brain's getRobot() method. It can also be accessed via the Pyro command line by the name robot.

1.1.1. get()

Get is the flexible interface for getting information from the robot, or some other information from a sensor on the robot. It takes three main forms:

Format #1: ROBOT.get(ITEM, SPEC)

Notice that ITEM and SPEC are typically strings.

ITEM Valid SPECs
'self' 'x', 'y', 'th', 'name'
'range', 'sonar', 'light', 'ir' 'count', 'type', 'units', 'maxvalue'

Not all robots have all types of sensors (for example, Pioneers don't have light or ir sensors).

'units' is given as one of the following:

'CM' The values reported are in centimeters.
'METERS' The values reported by sensors are in meters.
'MM' The values reported are in millimeters.
'RAW' The values reported are the raw values from the sensors.
'ROBOTS' The values reported are in proportion to the robot's physical diameter. Thus a distance equal to the robot's diameter is 1.
'SCALED' The values reported are scaled in the range -1.0..1.0

Format #2: ROBOT.get(ITEM, SPEC, DETAIL)

This form allows you to get additional detail from a SPEC.

ITEM Valid SPECs DETAIL
'range', 'sonar', 'light', 'ir' 'value' position number, list, or named group

Examples:

robot.get('sonar', 'value', 3)
robot.get('light', 'value', (3, 4))
robot.get('range', 'value', 'all')

Format #3: ROBOT.get(ITEM, SPEC, GROUP[, FUNCTION])

This form allows you to apply a function to a set of values:

ITEM Valid SPECs GROUP FUNCTION
'range', 'sonar', 'light', 'ir' 'value' position number, list, or named group 'min', 'max', 'avg', 'sum', 'close', 'far'

'close' and 'far' return a pair (distance, angle).

'max', 'min' return a pair (sensor number, distance).

Examples:

robot.get('range', 'value', 'front', 'avg') 
robot.get('ir', 'value', range(16), 'min') 
robot.get('sonar', 'value', 'front', 'close') 

Named sensor groups:

all           - so that you can access all sensors 
front         - the very front, center sensors 
front-left    - those front sensors on the left 
front-right   - those front sensors on the right 
front-all     - all front sensors 
left          - all sensors on the left (Pioneer has 2, Khepera has 1) 
right         - all sensors on the right (Pioneer has 2, Khepera has 1) 
back          - the very back, center sensors 
back-left     - those back sensors, on the left 
back-right    - those back sensors, on the right 
back-all      - all of the back sensors 

1.1.2. move()

ROBOT.move(TRANSLATE, ROTATE)

TRANSLATE is a value between -1.0 and 1.0. Negative values move the robot backwards, and positive moves the robot forwards.

ROTATE is a value between -1.0 and 1.0. Negative values spins the robot to the right, and positive spins the robot to the left.

The larger the magnitude the faster the robot will move or spin.

1.1.3. rotate()

ROBOT.rotate(VALUE)

VALUE is a value between -1.0 and 1.0. Negative values spins the robot to the right, and positive spins the robot to the left.

The larger the magnitude the faster the robot will spin.

1.1.4. set()

ROBOT.set(ITEM, SPEC, VALUE)

This is used to set items that are mutable. Currently only 'units' can be changed. The values that a unit can have are listed above.

robot.set('range', 'units', 'SCALED')

1.1.5. translate()

ROBOT.translate(VALUE)

VALUE is a value between -1.0 and 1.0. Negative values move the robot backwards, and positive moves the robot forwards.

The larger the magnitude the faster the robot will move.

The larger the magnitude the faster the robot will move.

1.1.6. beep()

ROBOT.beep()

Causes the robot to beep for a short amount of time

robot.beep()

1.1.7. say()

ROBOT.say(LIST)

Works similar to beep, except with one parameter defining tone and tone length. LIST is a string consisting of one or more pair or numbers. The first number in each pair will be the length that a given tone should play for, and the second number should be tone itself. A typical example is

robot.say("")
which will play tone 75 for a length of 10. An example of a slightly longer sequence is
robot.say("")

1.2. Brain Object

1.3. Camera Object

1.4. Speech Interface

>>> from ArAudio import ArAudio
>>> audio = ArAudio()
>>> audio.init()
ArSphinx is initializing, please wait.
ArSphinx initialized and listening.
>>> audio.play("sound/file.au")
>>> audio.play("sound/file.wav")
>>> audio.speak("This is something to say")
>>> audio.setListen(1)   # say something
>>> audio.amListening()
1
>>> audio.setListen(0)
>>> audio.getPhrase()
"SOMETHING MAYBE SOMETHING ELSE"
>>> audio.getPhrase()   # resets after getting
""
>>> audio.amSpeaking()
0
>>> audio.amListening()
0


Home ]Software ]Curriculum ]Hardware ]Community ]News ]Publications ]Search ]

CreativeCommons View Wiki Source | Edit Wiki Source | Mail Webmaster