示例#1
0
class RelayService:
    def __init__(self, url, username, password):
        self.client = AsyncClient(
            url=url,
            username=username,
            password=password,
        )
        self.last_telemetry = time()

    def telemetry(self, lat, lon, alt, heading):
        t = Telemetry(latitude=lat,
                      longitude=lon,
                      altitude_msl=alt,
                      uas_heading=heading)
        self.client.post_telemetry(t)

        new_time = time()
        print 1/(new_time-self.last_telemetry)
        self.last_telemetry = new_time

        return True

    def server_info(self):
        info = self.client.get_server_info().result()
        return str(info.message)
示例#2
0
class RelayService:
    def __init__(self, url, username, password):
        self.client = AsyncClient(url=url,
                                  username=username,
                                  password=password)
        self.last_telemetry = time()

    def telemetry(self, lat, lon, alt, heading):
        t = Telemetry(latitude=lat,
                      longitude=lon,
                      altitude_msl=alt,
                      uas_heading=heading)
        self.client.post_telemetry(t)

        new_time = time()
        print(1 / (new_time - self.last_telemetry))
        self.last_telemetry = new_time

        return True

    def get_obstacles(self):
        async_future = self.client.get_obstacles()
        async_stationary, async_moving = async_future.result()
        #print("here")
        # stat_ob, moving_ob = self.client.get_obstacles()
        async_radii_stationary = [o.cylinder_radius for o in async_stationary]
        async_lat_stationary = [o.latitude for o in async_stationary]
        async_lng_stationary = [o.longitude for o in async_stationary]
        async_height_stationary = [o.cylinder_height for o in async_stationary]
        async_radii_moving = [o.sphere_radius for o in async_moving]
        async_lat_moving = [o.latitude for o in async_moving]
        async_lng_moving = [o.longitude for o in async_moving]
        async_height_moving = [o.altitude_msl for o in async_moving]
        
        return async_radii_stationary, async_lat_stationary, async_lng_stationary, async_height_stationary, async_radii_moving, async_lat_moving, async_lng_moving, async_height_moving
	
	def get_moving_obstacles(self):
	
		return True

    def server_info(self):
        info = self.client.get_server_info().result()
        return str(info.message), str(info.message_timestamp), str(info.server_time)
示例#3
0
class RelayService:
    def __init__(self, url, username, password):
        self.client = AsyncClient(url=url,
                                  username=username,
                                  password=password)
        self.last_telemetry = time()

    def telemetry(self, lat, lon, alt, heading):
        t = Telemetry(latitude=lat,
                      longitude=lon,
                      altitude_msl=alt,
                      uas_heading=heading)
        self.client.post_telemetry(t)

        new_time = time()
        print(1 / (new_time - self.last_telemetry))
        self.last_telemetry = new_time

        return True

    def server_info(self):
        info = self.client.get_server_info().result()
        return str(info.message)
示例#4
0
class RelayService:
    def __init__(self, url, username, password):
        self.client = AsyncClient(url=url,
                                  username=username,
                                  password=password)
        self.last_telemetry = time()

    def telemetry(self, lat, lon, alt, heading):
        t = Telemetry(latitude=lat,
                      longitude=lon,
                      altitude_msl=alt,
                      uas_heading=heading)
        self.client.post_telemetry(t)

        new_time = time()
        print(1 / (new_time - self.last_telemetry))
        self.last_telemetry = new_time

        return True

    # POSTs target data, where target is a json object conforming to the
    # interop Target class specifications
    def target_data(self, target):
        # the ** operator unwraps the dictionary (here a json object)
        # into an actual argument list, and then we use that to create
        # an instance of the interop Target class
        t = Target(**target)
        self.client.post_target(t)

    # GETs all target info as a json object and prints it
    def get_target_data(self):
        return str(self.client.get_targets().result())

    def server_info(self):
        info = self.client.get_server_info().result()
        return str(info.server_time)