Esempio n. 1
0
def run():
    with grpc.insecure_channel("localhost:50052") as channel:
        stub = imu_pb2_grpc.ImuServiceStub(channel)
        print("-------------- GetStatus --------------")
        status = get_status(stub)
        print(repr(status))

        if not status.mpu_calibrated:
            stub.CalibrateMPU(imu_pb2.EmptyRequest())
            stub.Configure(imu_pb2.EmptyRequest())

        if not status.is_updating and not status.has_position:
            print("-------------- StartUpdating --------------")
            start_updating(stub)

            status = get_status(stub)

        print("-------------- GetPosition --------------")
        while True:
            get_position(stub)
            time.sleep(1)
Esempio n. 2
0
 def configure(self):
     with grpc.insecure_channel(self.service_address) as channel:
         stub = imu_pb2_grpc.ImuServiceStub(channel)
         stub.Configure(imu_pb2.EmptyRequest())
Esempio n. 3
0
 def position(self):
     with grpc.insecure_channel(self.service_address) as channel:
         stub = imu_pb2_grpc.ImuServiceStub(channel)
         return stub.GetPosition(imu_pb2.EmptyRequest())
Esempio n. 4
0
 def stop(self):
     with grpc.insecure_channel(self.service_address) as channel:
         stub = imu_pb2_grpc.ImuServiceStub(channel)
         return stub.StopUpdating(imu_pb2.EmptyRequest())
Esempio n. 5
0
 def calibrate_mpu(self):
     with grpc.insecure_channel(self.service_address) as channel:
         stub = imu_pb2_grpc.ImuServiceStub(channel)
         return stub.CalibrateMPU(imu_pb2.EmptyRequest())