Esempio n. 1
0
def mission_proto(mission):
    """Converts a mission to protobuf format."""
    mission_proto = interop_api_pb2.Mission()
    mission_proto.id = mission.pk

    mission_proto.lost_comms_pos.latitude = mission.lost_comms_pos.latitude
    mission_proto.lost_comms_pos.longitude = mission.lost_comms_pos.longitude

    for fly_zone in mission.fly_zones.all():
        fly_zone_proto = mission_proto.fly_zones.add()
        fly_zone_proto.altitude_min = fly_zone.altitude_msl_min
        fly_zone_proto.altitude_max = fly_zone.altitude_msl_max
        for boundary_point in fly_zone.boundary_pts.order_by('order').all():
            boundary_proto = fly_zone_proto.boundary_points.add()
            boundary_proto.latitude = boundary_point.latitude
            boundary_proto.longitude = boundary_point.longitude

    for waypoint in mission.mission_waypoints.order_by('order').all():
        waypoint_proto = mission_proto.waypoints.add()
        waypoint_proto.latitude = waypoint.latitude
        waypoint_proto.longitude = waypoint.longitude
        waypoint_proto.altitude = waypoint.altitude_msl

    for search_point in mission.search_grid_points.order_by('order').all():
        search_point_proto = mission_proto.search_grid_points.add()
        search_point_proto.latitude = search_point.latitude
        search_point_proto.longitude = search_point.longitude

    mission_proto.off_axis_odlc_pos.latitude = mission.off_axis_odlc_pos.latitude
    mission_proto.off_axis_odlc_pos.longitude = mission.off_axis_odlc_pos.longitude

    mission_proto.map_center_pos.latitude = mission.map_center_pos.latitude
    mission_proto.map_center_pos.longitude = mission.map_center_pos.longitude
    mission_proto.map_height = mission.map_height_ft

    mission_proto.emergent_last_known_pos.latitude = mission.emergent_last_known_pos.latitude
    mission_proto.emergent_last_known_pos.longitude = mission.emergent_last_known_pos.longitude

    for pt in mission.air_drop_boundary_points.order_by('order').all():
        proto = mission_proto.air_drop_boundary_points.add()
        proto.latitude = pt.latitude
        proto.longitude = pt.longitude

    mission_proto.air_drop_pos.latitude = mission.air_drop_pos.latitude
    mission_proto.air_drop_pos.longitude = mission.air_drop_pos.longitude

    mission_proto.ugv_drive_pos.latitude = mission.ugv_drive_pos.latitude
    mission_proto.ugv_drive_pos.longitude = mission.ugv_drive_pos.longitude

    stationary_obstacles = mission.stationary_obstacles.all()
    for obst in stationary_obstacles:
        obst_proto = mission_proto.stationary_obstacles.add()
        obst_proto.latitude = obst.latitude
        obst_proto.longitude = obst.longitude
        obst_proto.radius = obst.cylinder_radius
        obst_proto.height = obst.cylinder_height

    return mission_proto
Esempio n. 2
0
    def get_mission(self, mission_id):
        """GET a mission by ID.

        Returns:
            Mission.
        Raises:
            InteropError: Error from server.
            requests.Timeout: Request timeout.
            ValueError or AttributeError: Malformed response from server.
        """
        r = self.get('/api/missions/%d' % mission_id)
        mission = interop_api_pb2.Mission()
        json_format.Parse(r.text, mission)
        return mission
Esempio n. 3
0
def mission_proto(mission):
    """Converts a mission to protobuf format."""
    mission_proto = interop_api_pb2.Mission()
    mission_proto.id = mission.pk

    for fly_zone in mission.fly_zones.select_related().all():
        fly_zone_proto = mission_proto.fly_zones.add()
        fly_zone_proto.altitude_min = fly_zone.altitude_msl_min
        fly_zone_proto.altitude_max = fly_zone.altitude_msl_max
        for boundary_point in fly_zone.boundary_pts.order_by(
                'order').select_related().all():
            boundary_proto = fly_zone_proto.boundary_points.add()
            boundary_proto.latitude = boundary_point.position.gps_position.latitude
            boundary_proto.longitude = boundary_point.position.gps_position.longitude

    for waypoint in mission.mission_waypoints.order_by(
            'order').select_related().all():
        waypoint_proto = mission_proto.waypoints.add()
        waypoint_proto.latitude = waypoint.position.gps_position.latitude
        waypoint_proto.longitude = waypoint.position.gps_position.longitude
        waypoint_proto.altitude = waypoint.position.altitude_msl

    for search_point in mission.search_grid_points.order_by(
            'order').select_related().all():
        search_point_proto = mission_proto.search_grid_points.add()
        search_point_proto.latitude = search_point.position.gps_position.latitude
        search_point_proto.longitude = search_point.position.gps_position.longitude

    mission_proto.off_axis_odlc_pos.latitude = mission.off_axis_odlc_pos.latitude
    mission_proto.off_axis_odlc_pos.longitude = mission.off_axis_odlc_pos.longitude

    mission_proto.emergent_last_known_pos.latitude = mission.emergent_last_known_pos.latitude
    mission_proto.emergent_last_known_pos.longitude = mission.emergent_last_known_pos.longitude

    mission_proto.air_drop_pos.latitude = mission.air_drop_pos.latitude
    mission_proto.air_drop_pos.longitude = mission.air_drop_pos.longitude

    return mission_proto