示例#1
0
def new_waypoint_post_function():
    if (request.form['latitude'] != '' and request.form['longitude'] != ''
            and request.form['altitude'] != ''):
        try:
            temp_new_lat = float(request.form['latitude'])
            temp_new_lng = float(request.form['longitude'])
            temp_new_alt = float(request.form['altitude'])
            new_lat, new_lng, new_alt = temp_home_lat, temp_home_lng, temp_new_alt
            try:
                mp_client = mp_coms.MissionPlannerClient(
                    config.MISSION_PLANNER_HOST,
                    config.GROUND_STATION2MISSION_PLANNER_PORT)

                path = [(-1, -1, -1), (new_lat, new_lng, new_alt)]

                path = np.asarray(np.reshape(path, (1, -1))[0],
                                  dtype=np.float32).tolist()

                mp_client.send_data(path)

                mp_client.client_socket.close()

            except Exception as e:
                exc_type, exc_obj, exc_tb = sys.exc_info()
                fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                print(exc_type, fname, exc_tb.tb_lineno, e, file=sys.stderr)
        except Exception as e:
            print("Error processing new drop lat/lng args:{}".format(e),
                  file=sys.stderr)

    return redirect(url_for('index'))
示例#2
0
def payload_deployment_post_function():
    print('=' * int(os.popen('stty size', 'r').read().split()[1]))
    print("Payload Deployment Activated")
    print('-' * int(os.popen('stty size', 'r').read().split()[1]))
    global v_alt

    drop_lat = 38.145842
    drop_lng = -76.426375

    # Easter egg
    # drop_lat = 45.632661
    # drop_lng = -122.651915

    if not isinstance(v_alt, int):
        drop_height = 300
    else:
        if (v_alt > 100 and v_alt < 400):
            drop_height = v_alt
        else:
            drop_height = 300

    if (request.form['latitude'] != '' and request.form['longitude'] != ''):
        try:
            temp_drop_lat = float(request.form['latitude'])
            temp_drop_lng = float(request.form['longitude'])
            drop_lat, drop_lng = temp_drop_lat, temp_drop_lng
        except Exception as e:
            print("Error processing new drop lat/lng args:{}".format(e),
                  file=sys.stderr)
    print("Deployment Zone: {}:{}:{}".format(drop_lat, drop_lng, drop_height))
    print('-' * int(os.popen('stty size', 'r').read().split()[1]))
    try:

        mp_client = mp_coms.MissionPlannerClient(
            config.MISSION_PLANNER_HOST,
            config.GROUND_STATION2MISSION_PLANNER_PORT)

        path = [(0, 0, 0), (drop_lat, drop_lng, drop_height)]

        path = np.asarray(np.reshape(path, (1, -1))[0],
                          dtype=np.float32).tolist()

        mp_client.send_data(path)
        print("Path sent to Mission Planner: {}".format(path))
        print('=' * int(os.popen('stty size', 'r').read().split()[1]))

        mp_client.client_socket.close()

    except Exception as e:
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        print(exc_type, fname, exc_tb.tb_lineno, e, file=sys.stderr)

    return redirect(url_for('index'))
示例#3
0
def client_test():

    mp_client = mp_coms.MissionPlannerClient(host, port)

    while True:
        try:
            data = [1, 2, 3, 4, 5]

            mp_client.send_data(data)
            print('Data sent:{}'.format(data))
        except Exception as e:
            print(e)
            print("Are you sure that the server is turned on?")
示例#4
0
def main():
    #gs2mp_client = osc_client.OSCClient('192.168.1.42',5005)
    #gs2mp_client.init_client()

    stealth = StealthMode()
    obstacles = [(45.9616069, -121.2746859, 50)]
    mission_waypoints = [(45.9626361, -121.2751794, 200)]

    current_position = (45.960615, -121.274267, 0)
    home_waypoint = Waypoint(1, current_position[0], current_position[1])

    stealth.set_home_location(home_waypoint)
    stealth.set_max_altitude(400)
    stealth.set_min_altitude(100)

    print(stealth.latlng2ft(mission_waypoints[0][0], mission_waypoints[0][1]))

    boundary_points = [(45.9601301, -121.2709951), (45.9598616, -121.2774324),
                       (45.9643066, -121.2795138), (45.9647988, -121.2711239)]
    boundary = FlyZone(boundary_points, 100, 400)
    path = stealth.find_path(obstacles, mission_waypoints, current_position,
                             [boundary])
    print('Path:', path)

    while True:
        mp_client = mp_coms.MissionPlannerClient(host, port)
        #print("sending:{}\n{}".format(path,'-'*80))
        #path = np.asarray(path)
        #path = pickle.dumps(path)
        #path = zlib.compress(path)
        #path = [1,2,3,4,5]
        path = np.asarray(np.reshape(path, (1, -1))[0],
                          dtype=np.float32).tolist()

        #path = [1,2,3,4,5]
        print(path)

        mp_client.send_data(path)
        # mp_client.client_socket.close()
        #gs2mp_client.send_data(path,channel='path')
        time.sleep(1)
        mp_client.client_socket.close()
        break
示例#5
0
def client_test():

    host = config.GROUND_STATION_HOST
    port = config.MISSION_PLANNER2GROUND_STATION_PORT

    while True:

        try:
            #start_time = time.time()
            mp_client = mp_coms.MissionPlannerClient(host, port)
            data = [cs.lat, cs.lng, cs.alt, cs.groundcourse, cs.airspeed]
            data = list(map(float, data))

            mp_client.send_data(data)
            print('Data sent:{}'.format(data))
            #time.sleep(1e-1)
            mp_client.client_socket.close()
            #print("Time elapsed:",start_time-time.time())

        except Exception as e:
            print(e)
            print("Are you sure that the Ground Station server is turned on?")
示例#6
0
    def run_stealth_mode(self):
        """Run stealth mode: determine path, send path to Mission Planner"""

        # Format the obstacles
        obstacles = []
        for n in self.stealth_mode.obstacles:
            try:
                obstacles.append((n[0], n[1], n[2]))
            except:
                obstacles.append((n[0], n[1], n[2]))

        # print(obstacles)
        print('-' * int(os.popen('stty size', 'r').read().split()[1]))
        print("Finding path...")

        stealth_mode = stealth.StealthMode()

        drop_zone = (38.145842, -76.426375)

        mission_waypoints = [(38.145314, -76.429119, 200),
                             (38.149222, -76.429483, 300),
                             (38.150133, -76.430856, 300),
                             (38.14895, -76.432286, 300),
                             (38.147011, -76.430642, 400),
                             (38.143783, -76.431994, 200)]
        current_position = (38.14792, -76.427995, 0)

        home_waypoint = Waypoint(1, current_position[0], current_position[1])

        stealth_mode.set_home_location(home_waypoint)
        stealth_mode.set_max_altitude(400)
        stealth_mode.set_min_altitude(100)

        boundary_points = [(38.146269, -76.428164), (38.151625, -76.428683),
                           (38.151889, -76.431467), (38.150594, -76.435361),
                           (38.147567, -76.432342), (38.144667, -76.432947),
                           (38.143256, -76.434767), (38.140464, -76.432636),
                           (38.140719, -76.426014), (38.143761, -76.421206),
                           (38.147347, -76.423211), (38.146131, -76.426653)]
        boundary = FlyZone(boundary_points, 100, 410)

        optimal_path = stealth_mode.find_path(obstacles, mission_waypoints,
                                              current_position, [boundary])
        '''
        # Hard set mission variables
        mission_waypoints = [
            (38.145314,-76.429119,200),
            (38.149222,-76.429483,300),
            (38.150133,-76.430856,300),
            (38.14895,-76.432286,300),
            (38.147011,-76.430642,400),
            (38.143783,-76.431994,200)
        ]

        # Hard set boundary point variables
        boundary_points = [
            (38.146269,-76.428164),
            (38.151625,-76.428683),
            (38.151889,-76.431467),
            (38.150594,-76.435361),
            (38.147567,-76.432342),
            (38.144667,-76.432947),
            (38.143256,-76.434767),
            (38.140464,-76.432636),
            (38.140719,-76.426014),
            (38.143761,-76.421206),
            (38.147347,-76.423211),
            (38.146131,-76.426653)
        ]

        # Create a FlyZone object
        boundary = FlyZone(boundary_points,100,410)

        # Determine the optimal path
        optimal_path = self.stealth_mode.find_path(obstacles,
            mission_waypoints,
            mission_waypoints[0],
            [boundary])

        # Version which takes in the data from Interop instead of being 
        # hard set from pregiven variables
        """
         optimal_path = self.stealth_mode.find_path(obstacles,
            self.stealth_mode.mission_waypoints,
            self.stealth_mode. mission_waypoints[0],
            self.stealth_mode.boundary_points)
        """

        print("Path Variables:\n\tStarting Point:\t{}\n\n\tWaypoints:{}".format(
            mission_waypoints[0],
            mission_waypoints))

        print("Optimal path selected: {}".format(optimal_path),file=sys.stderr)
        print('-'*int(os.popen('stty size','r').read().split()[1]))
        '''
        try:
            # Setup client to Mission Planner
            mp_client = mp_coms.MissionPlannerClient(
                config.MISSION_PLANNER_HOST,
                config.GROUND_STATION2MISSION_PLANNER_PORT)

            # Format the path into a one row list
            path = np.asarray(np.reshape(optimal_path, (1, -1))[0],
                              dtype=np.float32).tolist()

            print('-' * int(os.popen('stty size', 'r').read().split()[1]))
            print("Sending data to Mission Planner...")

            # Send the data to Mission Planner
            mp_client.send_data(path)

            print('-' * int(os.popen('stty size', 'r').read().split()[1]))
            print("Path sent to Mission Planner")
            print('=' * int(os.popen('stty size', 'r').read().split()[1]))

            # Release the socket
            mp_client.client_socket.close()

        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno, e, file=sys.stderr)