|
|
@ -1,5 +1,9 @@ |
|
|
|
from __future__ import print_function |
|
|
|
from __future__ import print_function |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
''' |
|
|
|
|
|
|
|
AP_FLAKE8_CLEAN |
|
|
|
|
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
import atexit |
|
|
|
import atexit |
|
|
|
import math |
|
|
|
import math |
|
|
|
import os |
|
|
|
import os |
|
|
@ -24,10 +28,10 @@ else: |
|
|
|
|
|
|
|
|
|
|
|
RADIUS_OF_EARTH = 6378100.0 # in meters |
|
|
|
RADIUS_OF_EARTH = 6378100.0 # in meters |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# List of open terminal windows for macosx |
|
|
|
# List of open terminal windows for macosx |
|
|
|
windowID = [] |
|
|
|
windowID = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def m2ft(x): |
|
|
|
def m2ft(x): |
|
|
|
"""Meters to feet.""" |
|
|
|
"""Meters to feet.""" |
|
|
|
return float(x) / 0.3048 |
|
|
|
return float(x) / 0.3048 |
|
|
@ -57,10 +61,12 @@ def topdir(): |
|
|
|
d = os.path.dirname(d) |
|
|
|
d = os.path.dirname(d) |
|
|
|
return d |
|
|
|
return d |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def relcurdir(path): |
|
|
|
def relcurdir(path): |
|
|
|
"""Return a path relative to current dir""" |
|
|
|
"""Return a path relative to current dir""" |
|
|
|
return os.path.relpath(path, os.getcwd()) |
|
|
|
return os.path.relpath(path, os.getcwd()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reltopdir(path): |
|
|
|
def reltopdir(path): |
|
|
|
"""Returns the normalized ABSOLUTE path for 'path', where path is a path relative to topdir""" |
|
|
|
"""Returns the normalized ABSOLUTE path for 'path', where path is a path relative to topdir""" |
|
|
|
return os.path.normpath(os.path.join(topdir(), path)) |
|
|
|
return os.path.normpath(os.path.join(topdir(), path)) |
|
|
@ -99,7 +105,19 @@ def relwaf(): |
|
|
|
return "./modules/waf/waf-light" |
|
|
|
return "./modules/waf/waf-light" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def waf_configure(board, j=None, debug=False, math_check_indexes=False, coverage=False, ekf_single=False, postype_single=False, sitl_32bit=False, extra_args=[], extra_hwdef=None, ubsan=False, ubsan_abort=False, extra_defines={}): |
|
|
|
def waf_configure(board, |
|
|
|
|
|
|
|
j=None, |
|
|
|
|
|
|
|
debug=False, |
|
|
|
|
|
|
|
math_check_indexes=False, |
|
|
|
|
|
|
|
coverage=False, |
|
|
|
|
|
|
|
ekf_single=False, |
|
|
|
|
|
|
|
postype_single=False, |
|
|
|
|
|
|
|
sitl_32bit=False, |
|
|
|
|
|
|
|
extra_args=[], |
|
|
|
|
|
|
|
extra_hwdef=None, |
|
|
|
|
|
|
|
ubsan=False, |
|
|
|
|
|
|
|
ubsan_abort=False, |
|
|
|
|
|
|
|
extra_defines={}): |
|
|
|
cmd_configure = [relwaf(), "configure", "--board", board] |
|
|
|
cmd_configure = [relwaf(), "configure", "--board", board] |
|
|
|
if debug: |
|
|
|
if debug: |
|
|
|
cmd_configure.append('--debug') |
|
|
|
cmd_configure.append('--debug') |
|
|
@ -139,6 +157,7 @@ def waf_build(target=None): |
|
|
|
cmd.append(target) |
|
|
|
cmd.append(target) |
|
|
|
run_cmd(cmd, directory=topdir(), checkfail=True) |
|
|
|
run_cmd(cmd, directory=topdir(), checkfail=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_SITL( |
|
|
|
def build_SITL( |
|
|
|
build_target, |
|
|
|
build_target, |
|
|
|
board='sitl', |
|
|
|
board='sitl', |
|
|
@ -210,6 +229,7 @@ def build_examples(board, j=None, debug=False, clean=False, configure=True, math |
|
|
|
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True) |
|
|
|
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True) |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_replay(board, j=None, debug=False, clean=False): |
|
|
|
def build_replay(board, j=None, debug=False, clean=False): |
|
|
|
# first configure |
|
|
|
# first configure |
|
|
|
waf_configure(board, j=j, debug=debug) |
|
|
|
waf_configure(board, j=j, debug=debug) |
|
|
@ -223,8 +243,20 @@ def build_replay(board, j=None, debug=False, clean=False): |
|
|
|
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True) |
|
|
|
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True) |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
def build_tests(board, j=None, debug=False, clean=False, configure=True, math_check_indexes=False, coverage=False, |
|
|
|
|
|
|
|
ekf_single=False, postype_single=False, sitl_32bit=False, ubsan=False, ubsan_abort=False, extra_configure_args=[]): |
|
|
|
def build_tests(board, |
|
|
|
|
|
|
|
j=None, |
|
|
|
|
|
|
|
debug=False, |
|
|
|
|
|
|
|
clean=False, |
|
|
|
|
|
|
|
configure=True, |
|
|
|
|
|
|
|
math_check_indexes=False, |
|
|
|
|
|
|
|
coverage=False, |
|
|
|
|
|
|
|
ekf_single=False, |
|
|
|
|
|
|
|
postype_single=False, |
|
|
|
|
|
|
|
sitl_32bit=False, |
|
|
|
|
|
|
|
ubsan=False, |
|
|
|
|
|
|
|
ubsan_abort=False, |
|
|
|
|
|
|
|
extra_configure_args=[]): |
|
|
|
|
|
|
|
|
|
|
|
# first configure |
|
|
|
# first configure |
|
|
|
if configure: |
|
|
|
if configure: |
|
|
@ -248,6 +280,7 @@ def build_tests(board, j=None, debug=False, clean=False, configure=True, math_ch |
|
|
|
run_cmd([relwaf(), "tests"], directory=topdir(), checkfail=True, show=True) |
|
|
|
run_cmd([relwaf(), "tests"], directory=topdir(), checkfail=True, show=True) |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# list of pexpect children to close on exit |
|
|
|
# list of pexpect children to close on exit |
|
|
|
close_list = [] |
|
|
|
close_list = [] |
|
|
|
|
|
|
|
|
|
|
@ -299,7 +332,6 @@ def pexpect_close_all(): |
|
|
|
|
|
|
|
|
|
|
|
def pexpect_drain(p): |
|
|
|
def pexpect_drain(p): |
|
|
|
"""Drain any pending input.""" |
|
|
|
"""Drain any pending input.""" |
|
|
|
import pexpect |
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
p.read_nonblocking(1000, timeout=0) |
|
|
|
p.read_nonblocking(1000, timeout=0) |
|
|
|
except Exception: |
|
|
|
except Exception: |
|
|
@ -326,6 +358,7 @@ def kill_screen_gdb(): |
|
|
|
cmd = ["screen", "-X", "-S", "ardupilot-gdb", "quit"] |
|
|
|
cmd = ["screen", "-X", "-S", "ardupilot-gdb", "quit"] |
|
|
|
subprocess.Popen(cmd) |
|
|
|
subprocess.Popen(cmd) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def kill_mac_terminal(): |
|
|
|
def kill_mac_terminal(): |
|
|
|
global windowID |
|
|
|
global windowID |
|
|
|
for window in windowID: |
|
|
|
for window in windowID: |
|
|
@ -333,6 +366,7 @@ def kill_mac_terminal(): |
|
|
|
"(window(get index of window id %s))\'" % window) |
|
|
|
"(window(get index of window id %s))\'" % window) |
|
|
|
os.system(cmd) |
|
|
|
os.system(cmd) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def start_SITL(binary, |
|
|
|
def start_SITL(binary, |
|
|
|
valgrind=False, |
|
|
|
valgrind=False, |
|
|
|
callgrind=False, |
|
|
|
callgrind=False, |
|
|
@ -449,7 +483,7 @@ def start_SITL(binary, |
|
|
|
# somewhere for MAVProxy to connect to: |
|
|
|
# somewhere for MAVProxy to connect to: |
|
|
|
cmd.append('--uartC=tcp:2') |
|
|
|
cmd.append('--uartC=tcp:2') |
|
|
|
if not enable_fgview_output: |
|
|
|
if not enable_fgview_output: |
|
|
|
cmd.append("--disable-fgview"); |
|
|
|
cmd.append("--disable-fgview") |
|
|
|
|
|
|
|
|
|
|
|
cmd.extend(customisations) |
|
|
|
cmd.extend(customisations) |
|
|
|
|
|
|
|
|
|
|
@ -496,7 +530,6 @@ def start_SITL(binary, |
|
|
|
else: |
|
|
|
else: |
|
|
|
print("Running: %s" % cmd_as_shell(cmd)) |
|
|
|
print("Running: %s" % cmd_as_shell(cmd)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
first = cmd[0] |
|
|
|
first = cmd[0] |
|
|
|
rest = cmd[1:] |
|
|
|
rest = cmd[1:] |
|
|
|
child = pexpect.spawn(first, rest, logfile=sys.stdout, encoding=ENCODING, timeout=5) |
|
|
|
child = pexpect.spawn(first, rest, logfile=sys.stdout, encoding=ENCODING, timeout=5) |
|
|
@ -519,6 +552,7 @@ def mavproxy_cmd(): |
|
|
|
'''return path to which mavproxy to use''' |
|
|
|
'''return path to which mavproxy to use''' |
|
|
|
return os.getenv('MAVPROXY_CMD', 'mavproxy.py') |
|
|
|
return os.getenv('MAVPROXY_CMD', 'mavproxy.py') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def MAVProxy_version(): |
|
|
|
def MAVProxy_version(): |
|
|
|
'''return the current version of mavproxy as a tuple e.g. (1,8,8)''' |
|
|
|
'''return the current version of mavproxy as a tuple e.g. (1,8,8)''' |
|
|
|
command = "%s --version" % mavproxy_cmd() |
|
|
|
command = "%s --version" % mavproxy_cmd() |
|
|
@ -529,6 +563,7 @@ def MAVProxy_version(): |
|
|
|
raise ValueError("Unable to determine MAVProxy version from (%s)" % output) |
|
|
|
raise ValueError("Unable to determine MAVProxy version from (%s)" % output) |
|
|
|
return (int(match.group(1)), int(match.group(2)), int(match.group(3))) |
|
|
|
return (int(match.group(1)), int(match.group(2)), int(match.group(3))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def start_MAVProxy_SITL(atype, |
|
|
|
def start_MAVProxy_SITL(atype, |
|
|
|
aircraft=None, |
|
|
|
aircraft=None, |
|
|
|
setup=False, |
|
|
|
setup=False, |
|
|
@ -865,6 +900,7 @@ def constrain(value, minv, maxv): |
|
|
|
value = maxv |
|
|
|
value = maxv |
|
|
|
return value |
|
|
|
return value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_local_module(fname): |
|
|
|
def load_local_module(fname): |
|
|
|
'''load a python module from within the ardupilot tree''' |
|
|
|
'''load a python module from within the ardupilot tree''' |
|
|
|
fname = os.path.join(topdir(), fname) |
|
|
|
fname = os.path.join(topdir(), fname) |
|
|
|