Esempio n. 1
0
def test():
    input_port = sys.argv[1]

    client = Drone()
    print("Client id[", client.id, "] connected to the server.")
    resp = client.ping()  
    print("[received] moving to", resp.loc)
    last_loc = resp.loc

    try:
        while True: 
            for response in client.stub.update(Request(id=client.id)):  
                if response.loc != last_loc:
                    print("[received] now moving to", response.loc)
                    last_loc = response.loc         
            time.sleep(0.1)
    except KeyboardInterrupt:
        client.stop(0)
Esempio n. 2
0
 def ping(self, data):
     req = Request(data=str(data))
     return self.stub.ping(req)
Esempio n. 3
0
 def coordinates(self, data):
     req = Request(data=str(data), id=self.clientid)
     #print("test1")
     reqs = self.stub.coordinates(req)
     for req in reqs:
         yield req
Esempio n. 4
0
 def __init__(self, host='0.0.0.0', port=3000):
     self.channel = grpc.insecure_channel('%s:%d' % (host,port))
     self.stub = ping_pb2_grpc.PingPongStub(self.channel)
     resp = self.stub.register(Request(id=-1))
     self.id = resp.id
Esempio n. 5
0
 def ping(self):
     return self.stub.ping(Request(id=self.id))
Esempio n. 6
0
 def ping(self, data):
     print("test")
     req = Request(data=str(data))
     return self.stub.ping(req)