Dronekit
python script to automate arm & throttle (autonomy)
Still Debugging
Installation Instructions [x]
Open the terminal with Ctrl
+ Alt
+ T
cd ~
git clone https://github.com/dronekit/dronekit-python
cd dronekit-python
sudo python setup.py install
Dronekit Simple_goto example
cd examples/simple_goto
gedit modified_goto.py
## copy and paste the whole file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
© Copyright 2015-2016, 3D Robotics.
simple_goto.py: GUIDED mode "simple goto" example (Copter Only)
Demonstrates how to arm and takeoff in Copter and how to navigate to points using Vehicle.simple_goto.
Full documentation is provided at http://python.dronekit.io/examples/simple_goto.html
"""
from __future__ import print_function
import time
from dronekit import connect, VehicleMode, LocationGlobalRelative
# Set up option parsing to get connection string
#import argparse
#parser = argparse.ArgumentParser(description='Commands vehicle using vehicle.simple_goto.')
#parser.add_argument('--connect',
# help="Vehicle connection target string. If not specified, SITL #automatically started and used.")
#args = parser.parse_args()
#connection_string = args.connect
#sitl = None
import dronekit_sitl
sitl = dronekit_sitl.start_default()
connection_string = sitl.connection_string()
print('Connecting to vehicle on 127.0.0.1:14450')
vehicle = connect("127.0.0.1:14550", wait_ready=False)
print('connected')
def arm_and_takeoff(aTargetAltitude):
"""
Arms vehicle and fly to aTargetAltitude.
"""
print("Basic pre-arm checks")
# Don't try to arm until autopilot is ready
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Arming motors")
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
# Confirm vehicle armed before attempting to take off
while not vehicle.armed:
print(" Waiting for arming...")
time.sleep(1)
print("Taking off!")
vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
# Wait until the vehicle reaches a safe height before processing the goto
# (otherwise the command after Vehicle.simple_takeoff will execute
# immediately).
while True:
print(" Altitude: ", vehicle.location.global_relative_frame.alt)
# Break and return from function just below target altitude.
if vehicle.location.global_relative_frame.alt >= aTargetAltitude * 0.95:
print("Reached target altitude")
break
time.sleep(1)
arm_and_takeoff(10)
print("Set default/target airspeed to 3")
vehicle.airspeed = 3
print("Going towards first point for 30 seconds ...")
point1 = LocationGlobalRelative(35.063570, -118.156204, 20)
vehicle.simple_goto(point1)
# sleep so we can see the change in map
time.sleep(30)
print("Going towards second point for 30 seconds (groundspeed set to 10 m/s) ...")
point2 = LocationGlobalRelative(35.059257, -118.157724, 20)
vehicle.simple_goto(point2, groundspeed=10)
# sleep so we can see the change in map
time.sleep(30)
print("Returning to Launch")
vehicle.mode = VehicleMode("RTL")
# Close vehicle object before exiting script
print("Close vehicle object")
vehicle.close()
# Shut down simulator if it was started.
if sitl:
sitl.stop()
python modified_goto.py
*edit the python file*
# comment out .argparse lines
# add the following lines:
print('Connecting to vehicle on 127.0.0.1:14450')
vehicle = connnect("127.0.0.1:14550", wait_ready=False)
print('connected')
cd Downloads/
python aruco_land.py
Location Changes
Mojave=35.059217, -118.150861,0.0,0
Mojave_1=35.063570, -118.156204,0.0,0
Mojave_2=35.059257, -118.157724,0.0,0
## open new terminal
cd ardupilot/Tools/autotest
nano locations.txt
## add the followig:
Mojave=35.059217, -118.150861,0.0,0
Sources
[1] qGroundControl
Last updated