Package topo :: Package misc :: Module playerrobot :: Class PlayerRobot
[hide private]
[frames] | no frames]

Class PlayerRobot

source code



Player Robot interface.

A PlayerRobot instance encapsulates an interface to a Player
robot. It creates and manages a playerc.client object and a set of
device proxies wrapped in PlayerDevice objects.  In addition, it
maintains a run-loop in a separate thread that calls the client's
.read() method at regular intervals.  The devices are published
through standard interfaces on the PlayerRobot instance, and their
methods and properties are synchronized with the run thread
through a mutex.

Example:

  # set up a robot object with position, laser, and camera objects
  robot = PlayerRobot(host='myrobot.mydomain.edu',port=6665,
                      devices = [('position2d',0),
                                 ('laser',0),
                                 ('camera',1)])

  # start the run thread, devices will be subscribed
  # automatically.
  robot.start()

  # start the robot turning at 30 deg/sec
  robot.position2d[0].set_cmd_vel(0, 0, 30*pi/180)

  # wait for a while
  time.sleep(5.0)

  # all stop
  robot.position2d[0].set_cmd_vel(0,0,0)

  # shut down the robot's thread, unsubscribing all devices and
  # disconnecting the client
  robot.stop()

Instance Methods [hide private]
 
__init__(self, host='localhost', port=6665, speed=20, devices=[])
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
start(self) source code
 
stop(self) source code
 
run_loop(self) source code
 
run_queues(self, run_state)
When using queues for communication with devices, this method toggles queue processing.
source code
 
process_queues(self) source code
 
subscribe_all(self) source code
 
unsubscribe_all(self) source code
 
add_device(self, devname, devnum=0) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, host='localhost', port=6665, speed=20, devices=[])
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

run_queues(self, run_state)

source code 
When using queues for communication with devices, this method toggles queue processing. It is often useful to turn off queue processing, e.g. when a client does not plan on using queued data for a while.