UserPreferences

PyroServices


THIS PAGE IS OUTDATED. PLEASE SEE PYROBOT DEVICES.

1. Pyro Services

This page describes the pyro services interface that defines how the robot can interact with items such as: power monitor, gripper, cameras, gps, sonar, laser, blobs, ptz, bumpers, and truth.

/!\ These are only notes right now. This will be turned into documentation shortly.

There are two kinds of services: those that a robot can handle directly, and those that it can't. Most robots can handle commands to their bumpers, sonar, laser, etc. Many robots don't handle their framegrabbers directly. The Services interface attempts to hide the details between these very different kinds of services.

You start up all services by using either of these two calls:

robot.startService( SERVICENAME )
robot.startServices( SERVICE_SET )

There is a callback mechanism defined so that you can load services from a file. For example:

# SimpleService.py
from pyrobot.robot.service import Service

def INIT(robot):
    return {"serviceName": Service() }

/!\ Notice that the service INIT callback takes a robot, not an engine. All services hang off of the robot.

This is a simple example of returning a SERVICE_SET using startServices(). In startService(), SERVICENAME can either be a name that the robot knows, or can be a filename. SERVICE_SET can be either a dictionary, or a list of known services. For example:

def INIT(robot):
    return ("power", "laser", "blob")

This example returns 3 names of known services: power, laser, and blob. The next example creates two camera objects and returns them with two differnt names in dictionary form:

# CameraServices.py
def INIT(robot):
    return {"camera0": Camera(), "camera1": Camera(), "gps": GPS()}

The above file can be loaded with the command:

robot.startService("CameraServices")

if the file is in your current directory, you give a path to it, or in the pyrobot/plugins/services/ directory.

The robot starts and stops all services in the same manner:

robot.startService( SERVICENAME )    => starts a file or named service
robot.startServices( SERVICE_SET )   => starts all services in SET
robot.getServices()                  => returns list of services
robot.getService(SERVICENAME)        => returns a service object
robot.getServiceData(SERVICENAME)    => returns the main data from this service

Some services have their own methods; however, all services have a core set of commands:

service.stopService()
service.startService()
service.makeWindow()
service.update()
service.windowUpdate()

1.1. Putting it all together

robot.startService("BlobCamera")          # this loads the pyrobot/plugins/services/BlobCamera.py file.
service = robot.getService("BlobCamera")
service.makeWindow()                      # this creates a window and adds the window to the redraw list
service.active = 0                        # this temporarily disables this service
service.visible = 0                       # this prevents updating the window

You can create your own Service if you wish for something to be done each robot update(). In fact, you could write your own controller in these services, or even control the robot.

1.2. Command line services

You may startup a set of services on the shell command line when starting up Pyro with the -v flag:

$ pyrobot -r Player1 -v blob,truth

Note that you must list a robot with the -r flag as services require a robot.

== Config file services ===

You can also have a set of services begin by using a config file (either bay naming it .pyrobot or pyrobot.ini, or by giving it on the command line with the -i flag). The format is:

[robot]
services=BlobCamera,laser

1.3. Gripper

The following methods are defined for all grippers.

    open():
    close():
    stopMoving():
    liftUp():
    liftDown():
    liftStop():
    store():
    deploy():
    halt():
    getState():
    getBreakBeamState():
    isClosed(): 
    isMoving():
    isLiftMoving():
    isLiftMaxed():

1.4. PTZ

The following methods are defined for all pan-tilt-zoom units.

    pan(numDegrees):
    panRel(numDegrees):
    tilt(numDegrees):
    tiltRel(numDegrees):
    panTilt(panDeg, tiltDeg):
    panTiltRel(panDeg, tiltDeg):
    centerCamera():
    zoom(numDegrees):
    zoomRel(numDegrees):
    getPan():
    getTilt():
    getZoom():
    getRealPan():
    getRealTilt():
    getRealZoom():
    canGetRealPanTilt():
    canGetRealZoom():
    getMaxPosPan():
    getMaxNegPan():
    getMaxPosTilt():
    getMaxNegTilt():
    getMaxZoom():
    getMinZoom():

1.5. Camera

The following methods are defined for all cameras.

    def updateWindow():
    def makeWindow():
    visible = [0|1]
    active = [0|1]

Plus all of the methods from PyroImage (pyrobot/vision/init.py). Including:

    def getVal(x, y):
    def getRow(y):
    def getCol(x):
    def getDim():
    def histogram(cols = 20, rows = 20, initvals = 0):
    def convolve(convmask, bit = 0, threshold = 0):
    def update(1):                                  # Returns motion info

2. TODO

  1. Services should have a frequency time to indicate how often they are updated. The window should only update if the data is new. Need a timestamp to show updated time, and to check for window updates.