width, height = 300, 300
radius = width / 3
down = False
screen = pygame.display.set_mode((width, height))
center = width / 2, height / 2
joy = width / 2, height / 2
last_decay = 0
draw_joystick(center, joy, radius)

print "connecting to drone..."
if SIM:
    vehicle = connect('127.0.0.1:14551', wait_ready=True)
else:
    vehicle = connect('0.0.0.0:14550', wait_ready=True)

dd = DroneDirect(vehicle, joystick_feel=JOYSTICK_FEEL)
dd.take_control()

if SIM:
    #arm and takeoff drone - DO NOT USE THIS ON A REAL DRONE ONLY IN SIMULATION
    if vehicle.armed == False:
        # Don't let the user try to arm until autopilot is ready
        print " Waiting for vehicle to initialise..."
        while not vehicle.is_armable:
            time.sleep(1)
        vehicle.armed = True
        print 'Vehicle Armed'
    dd.takeoff()

x, y = 0, 0
try:
Esempio n. 2
0
from dronedirect import DroneDirect
import time

SIM = True

def translate(x=0, y=0, z=0):
    scale = 5.0
    dd.translate(x= x*scale,y=y*scale,z=z*scale, wait_for_arrival=True)

print "connecting to drone..."
if SIM:
    vehicle = connect('127.0.0.1:14551', wait_ready=True)
else:
    vehicle = connect('udpout:127.0.0.1:14560', wait_ready=True)

dd = DroneDirect(vehicle)
dd.take_control()

if SIM:
    #arm and takeoff drone - DO NOT USE THIS ON A REAL DRONE ONLY IN SIMULATION
    if vehicle.armed == False:
        # Don't let the user try to arm until autopilot is ready
        print " Waiting for vehicle to initialise..."
        while not vehicle.is_armable:
            time.sleep(1)
        vehicle.armed   = True
        print 'Vehicle Armed'
    dd.takeoff()


try: