Esempio n. 1
0
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) # connecting from GCS
    #vehicle = connect('udpout:127.0.0.1:14560', wait_ready=True) #connecting from onboard solo


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:
    '''
    YOUR CODE HERE
    '''

finally:
    dd.release()
Esempio n. 2
0
else:
    vehicle = connect('0.0.0.0:14550', wait_ready=True)

sd = DroneDirect(vehicle, joystick_feel=JOYSTICK_FEEL)
sd.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'
    sd.takeoff()

x, y = 0, 0
try:
    while running:
        #read user input
        event = pygame.event.poll()
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            center = event.pos
            joy = event.pos
            down = True
        elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
            down = False
            joy = width / 2, height / 2
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:
    while running:
        #read user input
        event = pygame.event.poll()
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            center = event.pos
            joy = event.pos
            down = True
        elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
            down = False
            joy = width / 2, height / 2
Esempio n. 4
0
    #vehicle = connect('udpout:127.0.0.1:14560', wait_ready=True) #connecting from onboard solo

# Take control of the drone
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:
    while running:
        # Listen for data
        print "Waiting for data..."
        data = sock.recv(16)
        print "Received!"

        # Turn data into nice JSON packages
        for i in data:
            if i == '{':
                packet_depth = packet_depth + 1
            elif i == '}':
                packet_depth = packet_depth - 1