Home

Download

Tutorial

Documentation

Contact



PyPlayer: Python Client for Player/Stage



Simple example

$ python
Python 2.1.1 (#1, Jul 26 2001, 04:57:14) 
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2
Type "copyright", "credits" or "license" for more information.
>>>
>>> # import pyplayer modules
>>> from pyplayer import *
>>>
>>> # import GUI modules
>>> from pyplayer.gui import *
>>>
>>> # connect to a player server
>>> atom = player('atom', port=6666)
>>>
>>> # enable a position device in 'all' mode
>>> atom.start('position', access='a')
>>>
>>> # turn on motor power
>>> atom.turnon_motors()
>>>
>>> # make a robot move
>>> atom.set_speed(100, 0, 20)
>>>
>>> # read the latest data of the position device
>>> pose, speed, stall = atom.get_position()
>>>
>>> # enable a laser device in 'read-only' mode
>>> atom.start('laser', access='r')
>>>
>>> # visualize the data of the laser device
>>> show_laser(atom)
		
>>> 
>>> # change the configuration of the laser device
>>> atom.set_laser_config(-45, 45, 0.25)
		
>>> # stop the all devices
>>> atom.stop('position')
>>> atom.stop('laser')
>>>
>>> # disconnect from Player server
>>> atom.close()
>>>