def connect(self): print "Pyrobot Player: hostname=", self.hostname, "port=", self.port # FIXME: arbitrary time! How can we know server is up and running? time.sleep(1) print "Trying to connect..." self._client = playerc.playerc_client(None, self.hostname, self.port) retval = self._client.connect() while retval == -1: print "Trying to connect..." self._client = playerc.playerc_client(None, self.hostname, self.port) time.sleep(1) retval = self._client.connect()
def main(): # Initialization highgui.cvNamedWindow("Guardian", 1) signal.signal(signal.SIGINT, handler) # Stage #robot = playerc.playerc_client(None, "localhost", 6665) # Corobot robot = playerc.playerc_client(None, "corobot-w.wifi.wpi.edu", 6665) robot.connect() p2dproxy = playerc.playerc_position2d(robot, 0) p2dproxy.subscribe(playerc.PLAYERC_OPEN_MODE) p2dproxy.get_geom() robot.read() while True: image = highgui.cvQueryFrame(camera) detectObject(image) p2dproxy.set_cmd_vel(speed[0], 0, speed[1], 0) draw_gui(image) highgui.cvShowImage("Guardian", image) if highgui.cvWaitKey(20) != -1: break highgui.cvDestroyWindow("Guardian") p2dproxy.set_cmd_vel(0, 0, 0, 0)
def connect(self): print "Pyrobot Player: hostname=", self.hostname, "port=", self.port # FIXME: arbitrary time! How can we know server is up and running? time.sleep(1) print "Trying to connect..." self._client = playerc.playerc_client( None, 'localhost', 6665 ) # Connect it if self._client.connect() != 0: raise playerc.playerc_error_str()
def __init__(self, host="localhost", port=6665, speed=20, devices=[]): self._thread = None self._running = False self._lock = RLock() self.speed = speed self._client = PlayerClient(playerc.playerc_client(None, host, port), self._lock) self._queues_running = False self._devices = [] for devname, devnum in devices: self.add_device(devname, devnum=devnum)
def __init__(self, host='localhost', port=6665, speed=20, devices=[]): self._thread = None self._running = False self._lock = RLock() self.speed = speed self._client = PlayerClient(playerc.playerc_client(None, host, port), self._lock) self._queues_running = False self._devices = [] for devname, devnum in devices: self.add_device(devname, devnum=devnum)
def __init__(self, hostname): self._client = playerc.playerc_client(None, hostname, 7000) self._client.connect() PlayerDevice.__init__(self, self._client, "simulation")
def __init__(self, hostname): self._client = playerc.playerc_client(None, hostname, 7000) self._client.connect() PlayerDevice.__init__(self, self._client, "simulation") self.thread = PlayerUpdater(self) self.thread.start()
The test sets up two blackboards, and connects to them via a passthrough driver with multiple clients. First a direct connection is established and some bootstrap data is placed into both blackboards. Then three connections are established via the passthrough. The first two two the first blackboard and the third to the second bloackboard. This allows for testing of independant connections that should all recieve different data To run tests simply run the .cfg with player and then run this script. """ import playerc, sys, time, pprint harness_client = playerc.playerc_client(None,"localhost",6665) harness_client.connect() harness_client.set_replace_rule(-1, -1, playerc.PLAYER_MSGTYPE_DATA, -1, 0) def read_if_waiting(c): if c.peek(1): c.read() print "Bootstrapping first BB" harness_bb1 = playerc.playerc_blackboard(harness_client,0) harness_bb1.subscribe(playerc.PLAYER_OPEN_MODE) harness_bb1.SetInt("Client1","BB1",11) harness_bb1.SetInt("Client2","BB1",12) harness_bb1.SetInt("Shared","BB1",13) harness_bb1.SubscribeToKey("Client1","BB1")
The test sets up two blackboards, and connects to them via a passthrough driver with multiple clients. First a direct connection is established and some bootstrap data is placed into both blackboards. Then three connections are established via the passthrough. The first two two the first blackboard and the third to the second bloackboard. This allows for testing of independant connections that should all recieve different data To run tests simply run the .cfg with player and then run this script. """ import playerc, sys, time, pprint harness_client = playerc.playerc_client(None, "localhost", 6665) harness_client.connect() harness_client.set_replace_rule(-1, -1, playerc.PLAYER_MSGTYPE_DATA, -1, 0) def read_if_waiting(c): if c.peek(1): c.read() print "Bootstrapping first BB" harness_bb1 = playerc.playerc_blackboard(harness_client, 0) harness_bb1.subscribe(playerc.PLAYER_OPEN_MODE) harness_bb1.SetInt("Client1", "BB1", 11) harness_bb1.SetInt("Client2", "BB1", 12) harness_bb1.SetInt("Shared", "BB1", 13)