def create_drone(simulator=False): # mav-link connection class: conn = MavlinkConnection( 'tcp:127.0.0.1:8021', threaded=True) #MavlinkConnection('tcp:127.0.0.1:5460', threaded=True) #Drone-Class drone_ = Drone(conn) #Set Home drone_.set_home_position(drone_.global_position[0], drone_.global_position[1], drone_.global_position[2]) return drone_
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)
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()