Esempio n. 1
0
def main():
	print("Creating UAV")
	vehicle = api.navigation(timeout = 120000)
	time.sleep(3)
	print("Taking off")
	vehicle.take_off(height)
	time.sleep(1)
	vehicle.position_set(0, 0, 0, relative=True, tolerance=0.1, yaw_valid=True, yaw=-vehicle.get_vfr_hud().heading*pi/180)
	print("Took off to height %2.2f metre" % -vehicle.get_local_position().z)

	init_x = float(vehicle.get_local_position().x)
	init_y = float(vehicle.get_local_position().y)
	vehicle.position_set(traj_len, 0, 0, relative=True, tolerance=0.1, async=False, yaw_valid=False)
	#while(float(vehicle.get_local_position().x)-init_x < traj_len):
	#	pass
	move = float(vehicle.get_local_position().x)-init_x
	print("Moved %2.2f metre" % abs(move))
	
	init_x = float(vehicle.get_local_position().x)
	init_y = float(vehicle.get_local_position().y)
	vehicle.position_set(0, traj_len, 0, relative=True, tolerance=0.1, async=False, yaw_valid=True, yaw=90*pi/180)
	#while(float(vehicle.get_local_position().y)-init_y < traj_len):
	#	pass
	move = float(vehicle.get_local_position().y)-init_y
	print("moved %2.2f metre" % abs(move))

	init_x = float(vehicle.get_local_position().x)
	init_y = float(vehicle.get_local_position().y)
	vehicle.position_set(-traj_len, 0, 0, relative=True, tolerance=0.1, async=False, yaw_valid=True, yaw=90*pi/180)
	#while(float(vehicle.get_local_position().x)-init_x < traj_len):
	#	pass
	move = float(vehicle.get_local_position().x)-init_x
	print("moved %2.2f metre" % abs(move))

	init_x = float(vehicle.get_local_position().x)
	init_y = float(vehicle.get_local_position().y)
	vehicle.position_set(0, -traj_len, 0, relative=True, tolerance=0.1, async=False, yaw_valid=True, yaw=90*pi/180)
	#while(float(vehicle.get_local_position().y)-init_y < traj_len):
	#	pass
	move = float(vehicle.get_local_position().y)-init_y
	print("moved %2.2f metre" % abs(move))

	vehicle.position_set(0, 0, 0, relative=True, tolerance=0.1, yaw_valid=True, yaw=90*pi/180)

	print("Initiating landing")
	vehicle.land(async=False)
	print("Landed")

	vehicle.disconnect()
Esempio n. 2
0
#!/usr/bin/env python

from flyt_python import api

nav = api.navigation()  # instance of flyt navigation class

print 'taking off'
nav.take_off(3.0)
print ' going along the setpoints'
nav.position_set(5, 0, -3)
nav.position_set(5, 5, -3)
nav.position_set(0, 5, -3)
nav.position_set(0, 0, -3)
print 'Done'
print nav.land(false)
print 'wait for the vehicle to land'
Esempio n. 3
0
import gpxpy.geo
# add arguments

max_abs_dist = 20 # in meters, max horizontal distance from current location to the target


parser = argparse.ArgumentParser()
parser.add_argument('lat_off', help='lat off')
parser.add_argument('lon_off', help='lon off')
parser.add_argument('height', help='height from ground in meters')
parser.add_argument('wait_time', help='wait time at target spot')
args = parser.parse_args()


from flyt_python import api
drone = api.navigation(timeout=120000) # instance of drone navigation class

#at least 3sec sleep time for the drone interface to initialize properly
time.sleep(3)


fly = True

if fly:
    try:
        gpos_home_gnd = drone.get_global_position()
        lpos_home_gnd = drone.get_local_position()
    except:
        pass
    print gpos_home_gnd.lat, gpos_home_gnd.lon, gpos_home_gnd.alt, "ground global position"
    lat1, lon1 = gpos_home_gnd.lat, gpos_home_gnd.lon
Esempio n. 4
0
import time
from flyt_python import api
drone = api.navigation(timeout=120000)

time.sleep(3)

print 'taking off'
drone.take_off(5.0)

print 'starting mission'
drone.position_set(6.5, 0, 0, relative=True)
drone.position_set(0, 6.5, 0, relative=True)
drone.position_set(-6.5, 0, 0, relative=True)
drone.position_set(0, -6.5, 0, relative=True)

print 'Landing'
drone.land(async=False)

drone.disconnect()
Esempio n. 5
0
#...........................................................................
# Author: Saiffullah Sabir Mohamed
# Email:  [email protected]
# Github: https://github.com/TechnicalVillager
#...........................................................................

#!/usr/bin/env python
import math
import time
import sys
from flyt_python import api

# Initialize Vehicle
drone = api.navigation()


def destination_location(homeLatitude, homeLongitude, distance, bearing, alt):
    #...........................................................................
    # Purpose: This function returns the latitude and longitude of unknown
    #          position with known distance and bearing from current position.
    #
    # Format:  destination_location(18.5308934, 73.8545103, 50, 102, 25)
    #
    # Inputs:
    #           homeLatitude     -->     Latitude of home location
    #           homeLongitude    -->     Longitude of home location
    #           distance         -->     distance in meters
    #           bearing          -->     Bearing angle
    #
    # Outputs:
    #           [rlat, rlon, alt] --> Latitude, Longitude, Altitude
Esempio n. 6
0
#!/usr/bin/env python
import time
import argparse
from flyt_python import api

drone = api.navigation(timeout=120000) # instance of flyt droneigation class

#at least 3sec sleep time for the drone interface to initialize properly
time.sleep(3)

## parsing command line arguments
parser = argparse.ArgumentParser(description='Process a float value.')
parser.add_argument('side', metavar='side_length', type=float, help='side length of the square')
args = parser.parse_args()

## lets fly 
side_length = args.side

print "taking off!"
drone.take_off(3.0)

print 'flying in square', side_length
drone.position_set(side_length,0,-3)
drone.position_set(side_length,side_length,-3)
drone.position_set(0,side_length,-3)
drone.position_set(0,0,-3)

print "landing"
drone.land(False)
print 'Cheers!!'
Esempio n. 7
0
#importing_useful_libraries
import time
from flyt_python import api

#initializing
UAV = api.navigation(timeout=120000)
time.sleep(3)

#initializing_takeoff_to_5.0_meters
UAV.take_off(5.0)

#waypoint_navigation_for_a_square_path_(side_=_6.5_meters)
i = 1
while i < 5:
    UAV.position_set(
        6.5, 0, 0, 1.57079632679, 0, False, False, True, True
    )  #command_to_make_the_vehicle_go_6.5meters_in_x-direction_(NED_coordinate_system),_and_yawing_90_degrees_(1.57079632679_in_radians)
    time.sleep(2)  #for_a_better_trajectory (smoother_square_path)
    i = i + 1

#initializing_landing
UAV.land(async=False)

#terminating
UAV.disconnect()
Esempio n. 8
0
import cv2
import cv2.cv as cv
import detector as vision
import numpy as np
from flyt_python import api
import time

nav = api.navigation(timeout=120000)  # instance of flyt navigation class
time.sleep(5)

state_UP, state_DOWN = False, False
delta_h = 1.0  ## vertical distance between top and bottom points
# Take input from webcam
cap = cv2.VideoCapture(0)


def state_machine(trigA, trigB, sUP, sDOWN, del_h):
    up = bool(sUP)
    down = bool(sDOWN)
    if up:
        if not trigA and trigB:
            print "going down"
            nav.position_set(0, 0, del_h, relative=True, async=True)
            up, down = False, True
        return (up, down)
    if down:
        if trigA and not trigB:
            print "going up"
            nav.position_set(0, 0, -del_h, relative=True, async=True)
            up, down = True, False
        return (up, down)
Esempio n. 9
0
import time
from flyt_python import api

#creating the instance
quadcopter = api.navigation(timeout=120000)
time.sleep(3)

print("ARMING & TAKEOFF")
time.sleep(1)
quadcopter.take_off(5.0)

print("APPROACHING WAYPOINT 1")
time.sleep(1)
quadcopter.position_set(6.5, 0, 0, relative=True)
time.sleep(1)
print("WAYPOINT 1 REACHED")
time.sleep(1)

print("APPROACHING WAYPOINT 2")
time.sleep(1)
quadcopter.position_set(0, 6.5, 0, relative=True)
time.sleep(1)
print("WAYPOINT 2 REACHED")
time.sleep(1)

print("APPROACHING WAYPOINT 3")
time.sleep(1)
quadcopter.position_set(-6.5, 0, 0, relative=True)
time.sleep(1)
print("WAYPOINT 3 REACHED")
time.sleep(1)
Esempio n. 10
0
#!/usr/bin/env python

from flyt_python import api

nav = api.navigation() # instance of flyt navigation class

nav.arm()
print 'taking off'
nav.takeoff(3.0)
print ' going along the setpoints'
nav.position_set(5,0,-3)
nav.position_set(5,5,-3)
nav.position_set(0,5,-3)
nav.position_set(0,0,-3)
print 'Done'
nav.land()
print 'wait for the vehicle to land'

 
Esempio n. 11
0
import cv2
import cv2.cv as cv
import detector as vision
import numpy as np
from flyt_python import api
import time

nav = api.navigation(timeout=120000) # instance of flyt navigation class
time.sleep(5)

state_UP, state_DOWN = False, False
delta_h = 1.0      ## vertical distance between top and bottom points
# Take input from webcam
cap = cv2.VideoCapture(0)

def state_machine(trigA, trigB, sUP, sDOWN, del_h):
    up = bool(sUP)
    down = bool(sDOWN)
    if up:
        if not trigA and trigB:
            print "going down"
            nav.position_set(0,0, del_h, relative = True, async=True)
            up, down = False, True
        return (up, down)
    if down:
        if trigA and not trigB:
            print "going up"
            nav.position_set(0,0, -del_h, relative = True, async=True)
            up, down = True, False
        return (up, down)
    if trigA and not trigB: