kopia lustrzana https://github.com/IzzyBrand/spaceplane
added config and apogee detection loop
rodzic
83be44f04c
commit
cc08fcc4b4
Plik binarny nie jest wyświetlany.
38
companion.py
38
companion.py
|
@ -1,5 +1,41 @@
|
|||
from dronekit import connect, VehicleMode, APIException
|
||||
from pymavlink import mavutil
|
||||
from time import time
|
||||
from config import *
|
||||
from helpers import *
|
||||
import sys
|
||||
import time
|
||||
import argparse
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Connect to pixhawk
|
||||
###############################################################################
|
||||
vehicle = None
|
||||
try:
|
||||
vehicle = connect(PORT, baud=115200, wait_ready=True)
|
||||
except Exception as e:
|
||||
print e
|
||||
print 'Failed to connect to pixhawk. exiting.'
|
||||
sys.exit(1)
|
||||
|
||||
###############################################################################
|
||||
# Ascent
|
||||
###############################################################################
|
||||
|
||||
prev_time_below_burn_alt = time()
|
||||
while True:
|
||||
alt = vehicle.location.global_relate_frame.alt
|
||||
if alt < BURN_ALTITUDE: prev_time_below_burn_alt = time()
|
||||
else:
|
||||
time_above = time() - prev_time_below_burn_alt
|
||||
print 'Above {}m for {} seconds'.format(BURN_ALTITUDE, time_above)
|
||||
if time_above > BURN_TIME_ABOVE:
|
||||
break
|
||||
|
||||
###############################################################################
|
||||
# Burn
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# Descent
|
||||
###############################################################################
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
PORT = '/dev/ttyUSB0'
|
||||
BURN_ALTITUDE = 20000
|
||||
BURN_TIME_ABOVE = 20
|
||||
|
Ładowanie…
Reference in New Issue