from udacidrone import Drone
from udacidrone.connection.mavlink_connection import MavlinkConnection

# Initiate a Mavlink connection
conn = MavlinkConnection('tcp:127.0.0.1:5760', threaded=True)

# Initialize a drone
drone = Drone(conn)

# Start receiving messages from the drone
drone.start()

# Take control and set the mode to guided
drone.take_control()

# Arms the rotors
drone.arm()

# Set the drone's home position
drone.set_home_position(drone.global_position[0], drone.global_position[1],
                        drone.global_position[2])

# Takeoff
drone.takeoff(3)

# Send a position (north, east, down, heading) command
drone.cmd_position(5, 0, 3, 0)
예제 #2
0
time.sleep(2)
print('starting drone...')
drone.start()

print('taking control...')
drone.take_control()

print('arming...')
drone.arm()

drone.set_home_position(drone.global_position[0], drone.global_position[1],
                        drone.global_position[2])

drone.takeoff(1)
time.sleep(5)
drone.cmd_position(0, 0, 3, 0)
time.sleep(5)
drone.cmd_position(0, 10, 3, 0)
time.sleep(5)
drone.cmd_position(10, 10, 3, 0)
time.sleep(5)
drone.cmd_position(10, 0, 3, 0)
time.sleep(5)
drone.cmd_position(0, 0, 3, 0)
time.sleep(5)
drone.cmd_position(0, 0, 3, 0)
time.sleep(5)

drone.disarm()
drone.stop()
예제 #3
0
from udacidrone import Drone
from udacidrone.connection import MavlinkConnection

conn = MavlinkConnection('tcp:127.0.0.1:5760', threaded=False, PX4=False)
drone = Drone(conn)
drone.connection.start()
drone.take_control()
drone.arm()
#drone.set_home_as_current_position()
drone.takeoff(3.0)
drone.cmd_position(2, 1, 3.0, 0)
drone.cmd_position(0, 0, 3, 0)
drone.land()
drone.disarm()
drone.release_control()
drone.stop()
from udacidrone import Drone
from udacidrone.connection import MavlinkConnection
conn = MavlinkConnection('tcp:127.0.0.1:5760', threaded=True)
drone = Drone(conn)
drone.start()
drone.take_control()
drone.arm()
drone.set_home_position(drone.global_position[0], 
                        drone.global_position[1], 
                        drone.global_position[2])
drone.takeoff(30)
drone.cmd_position(5,5,5,5)
drone.stop()

예제 #5
0
from udacidrone import Drone
from udacidrone.connection import MavlinkConnection
conn = MavlinkConnection('tcp:127.0.0.1:5760', threaded=True)
drone = Drone(conn)
drone.start()
drone.take_control()
drone.arm()
drone.set_home_position(drone.global_position[0], drone.global_position[1],
                        drone.global_position[2])
drone.takeoff(30)
drone.cmd_position(5, 5, 5, 5)
drone.stop()