-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
237 changed files
with
17,185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
from lib2to3.main import main | ||
|
||
sys.exit(main("lib2to3.fixes")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
#!/usr/bin/env python | ||
|
||
''' | ||
search a set of log files for signs of inconsistent IMU data | ||
''' | ||
|
||
import sys, time, os, glob | ||
import zipfile | ||
|
||
from pymavlink import mavutil | ||
from math import degrees | ||
|
||
# extra imports for pyinstaller | ||
import json | ||
from pymavlink.dialects.v10 import ardupilotmega | ||
|
||
search_dirs = ['c:\Program Files\APM Planner', | ||
'c:\Program Files\Mission Planner', | ||
'c:\Program Files (x86)\APM Planner', | ||
'c:\Program Files (x86)\Mission Planner'] | ||
results = 'SearchResults.zip' | ||
email = 'Craig Elder <[email protected]>' | ||
|
||
def IMUCheckFail(filename): | ||
try: | ||
mlog = mavutil.mavlink_connection(filename) | ||
except Exception: | ||
return False | ||
|
||
accel1 = None | ||
accel2 = None | ||
gyro1 = None | ||
gyro2 = None | ||
t1 = 0 | ||
t2 = 0 | ||
ecount_accel = [0]*3 | ||
ecount_gyro = [0]*3 | ||
athreshold = 3.0 | ||
gthreshold = 30.0 | ||
count_threshold = 100 | ||
imu1_count = 0 | ||
imu2_count = 0 | ||
|
||
while True: | ||
try: | ||
m = mlog.recv_match(type=['RAW_IMU','SCALED_IMU2','IMU','IMU2','PARM','PARAM_VALUE']) | ||
except Exception as e: | ||
print('Error: %s' % e) | ||
break | ||
if m is None: | ||
break | ||
mtype = m.get_type() | ||
gotimu2 = False | ||
if mtype == 'RAW_IMU': | ||
accel1 = [m.xacc*9.81*0.001, m.yacc*9.81*0.001, m.zacc*9.81*0.001] | ||
gyro1 = [degrees(m.xgyro*0.001), degrees(m.ygyro*0.001), degrees(m.zgyro*0.001)] | ||
t1 = m.time_usec/1000 | ||
imu1_count += 1 | ||
elif mtype == 'SCALED_IMU2': | ||
accel2 = [m.xacc*9.81*0.001, m.yacc*9.81*0.001, m.zacc*9.81*0.001] | ||
gyro2 = [degrees(m.xgyro*0.001), degrees(m.ygyro*0.001), degrees(m.zgyro*0.001)] | ||
gotimu2 = True | ||
t2 = m.time_boot_ms | ||
imu2_count += 1 | ||
elif mtype == 'IMU': | ||
accel1 = [m.AccX, m.AccY, m.AccZ] | ||
gyro1 = [m.GyrX, m.GyrY, m.GyrZ] | ||
t1 = m.TimeMS | ||
imu1_count += 1 | ||
elif mtype == 'IMU2': | ||
accel2 = [m.AccX, m.AccY, m.AccZ] | ||
gyro2 = [m.GyrX, m.GyrY, m.GyrZ] | ||
gotimu2 = True | ||
t2 = m.TimeMS | ||
imu2_count += 1 | ||
elif mtype == 'PARM': | ||
if m.Name.startswith('INS_ACCOFFS_') or m.Name.startswith('INS_ACC2OFFS_'): | ||
if m.Value == 0.0: | ||
print('UNCALIBRATED: %s' % m) | ||
return False | ||
elif mtype == 'PARAM_VALUE': | ||
if m.param_id.startswith('INS_ACCOFFS_') or m.param_id.startswith('INS_ACC2OFFS_'): | ||
if m.param_value == 0.0: | ||
print('UNCALIBRATED: %s' % m) | ||
return False | ||
|
||
# skip out early if we don't have two IMUs | ||
if imu1_count > imu2_count + 100: | ||
return False | ||
|
||
if accel1 is not None and accel2 is not None and gotimu2 and t2 >= t1: | ||
for i in range(3): | ||
adiff = accel1[i] - accel2[i] | ||
if adiff > athreshold: | ||
if ecount_accel[i] < 0: | ||
ecount_accel[i] = 0 | ||
else: | ||
ecount_accel[i] += 1 | ||
elif adiff < -athreshold: | ||
if ecount_accel[i] > 0: | ||
ecount_accel[i] = 0 | ||
else: | ||
ecount_accel[i] -= 1 | ||
else: | ||
ecount_accel[i] = 0 | ||
gdiff = gyro1[i] - gyro2[i] | ||
if gdiff > gthreshold: | ||
if ecount_gyro[i] < 0: | ||
ecount_gyro[i] = 0 | ||
else: | ||
ecount_gyro[i] += 1 | ||
elif gdiff < -gthreshold: | ||
if ecount_gyro[i] > 0: | ||
ecount_gyro[i] = 0 | ||
else: | ||
ecount_gyro[i] -= 1 | ||
else: | ||
ecount_gyro[i] = 0 | ||
if abs(ecount_accel[i]) > count_threshold: | ||
print("acceldiff[%u] %.1f" % (i, adiff)) | ||
print(m) | ||
return True | ||
if abs(ecount_gyro[i]) > count_threshold: | ||
print("gyrodiff[i] %.1f" % (i, adiff)) | ||
print(m) | ||
return True | ||
|
||
return False | ||
|
||
found = [] | ||
directories = sys.argv[1:] | ||
if not directories: | ||
directories = search_dirs | ||
|
||
filelist = [] | ||
|
||
extensions = ['.tlog','.bin'] | ||
|
||
def match_extension(f): | ||
'''see if the path matches a extension''' | ||
(root,ext) = os.path.splitext(f) | ||
return ext.lower() in extensions | ||
|
||
for d in directories: | ||
if not os.path.exists(d): | ||
continue | ||
if os.path.isdir(d): | ||
print("Searching in %s" % d) | ||
for (root, dirs, files) in os.walk(d): | ||
for f in files: | ||
if not match_extension(f): | ||
continue | ||
path = os.path.join(root, f) | ||
filelist.append(path) | ||
elif match_extension(d): | ||
filelist.append(d) | ||
|
||
for i in range(len(filelist)): | ||
f = filelist[i] | ||
print("Checking %s ... [found=%u i=%u/%u]" % (f, len(found), i, len(filelist))) | ||
try: | ||
if IMUCheckFail(f): | ||
found.append(f) | ||
except Exception as e: | ||
print("Failed - %s" % e) | ||
continue | ||
sys.stdout.flush() | ||
|
||
if len(found) == 0: | ||
print("No matching files found - all OK!") | ||
raw_input('Press enter to close') | ||
sys.exit(0) | ||
|
||
print("Creating zip file %s" % results) | ||
try: | ||
zip = zipfile.ZipFile(results, 'w') | ||
except Exception: | ||
print("Unable to create zip file %s" % results) | ||
print("Please send matching files manually") | ||
for f in found: | ||
print('MATCHED: %s' % f) | ||
raw_input('Press enter to close') | ||
sys.exit(1) | ||
|
||
for f in found: | ||
arcname=os.path.basename(f) | ||
if not arcname.startswith('201'): | ||
mtime = os.path.getmtime(f) | ||
arcname = "%s-%s" % (time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(mtime)), arcname) | ||
zip.write(f, arcname=arcname) | ||
zip.close() | ||
|
||
print('==============================================') | ||
print("Created %s with %u of %u matching logs" % (results, len(found), len(filelist))) | ||
print("Please send this file to %s" % email) | ||
print('==============================================') | ||
|
||
raw_input('Press enter to close') | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/bin/sh | ||
clear | ||
|
||
echo "Solo Test Script" | ||
SSHARGS="-o StrictHostKeyChecking=no -o ConnectTimeout=3" | ||
MAC=`ifconfig -a | grep HWaddr | awk '{print $5}' | tr '[:upper:]' '[:lower:]'` | ||
DEBUGFSDIR=/sys/kernel/debug/ieee80211/phy0/ | ||
|
||
connectToTF() { | ||
SSID=$1 | ||
rm -f /tmp/wpa* | ||
killall wpa_supplicant &> /dev/null | ||
echo "Connecting" | ||
cp /etc/wpa_supplicant.conf /tmp/ | ||
wpa_passphrase $SSID sololink > /tmp/wpa_supplicant.conf | ||
wpa_supplicant -c/tmp/wpa_supplicant.conf -Dnl80211 -B -iwlan0 &> /dev/null | ||
ifconfig wlan0 10.1.1.10 | ||
ping 10.1.1.1 -c1 -W5 &> /dev/null | ||
if [ $? -ne 0 ]; then | ||
echo "Unable to connect" | ||
echo "********************FAIL************************" | ||
disconnectFromTF | ||
exit 1 | ||
fi | ||
} | ||
|
||
disconnectFromTF() { | ||
echo "Disconnecting" | ||
ifconfig wlan0 down | ||
killall wpa_supplicant | ||
} | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Please specify the SoloLink_TEST network SSID" | ||
exit 1 | ||
fi | ||
|
||
TFSSID=$1 | ||
|
||
echo "Initializing system" | ||
init 2 | ||
sleep 2 | ||
ssh-keygen -R 10.1.1.1 &> /dev/null | ||
|
||
echo "Attempting to connect to $TFSSID" | ||
connectToTF $TFSSID | ||
#ssh $SSHARGS [email protected] "iw phy0 set txpower fixed 100" | ||
#iw phy0 set txpower fixed 100 | ||
|
||
echo "Testing connection" | ||
PASS=1 | ||
for ant in 1 2; do | ||
echo "Antenna ${ant}: " | ||
ifconfig wlan0 down | ||
iw phy0 set antenna 0x${ant} 0x${ant} | ||
ifconfig wlan0 10.1.1.10 | ||
sleep 1 | ||
rx=0 | ||
tx=0 | ||
rxWorst=0 | ||
txWorst=0 | ||
rxBest=-200 | ||
txBest=-200 | ||
for i in {1..20}; do | ||
rxSig=`cat ${DEBUGFSDIR}netdev:wlan0/stations/*/last_signal` | ||
txSig=`ssh $SSHARGS [email protected] "cat ${DEBUGFSDIR}netdev:wlan0-ap/stations/${MAC}/last_signal"` | ||
if [ $? -ne 0 ]; then | ||
echo "Unable to connect to read signal value." | ||
echo "********************FAIL************************" | ||
PASS=0 | ||
break | ||
fi | ||
|
||
echo -n "." | ||
#echo "$txSig $txWorst $txBest" | ||
#echo "$rxSig $rxWorst $rxBest" | ||
rx=$((rx+rxSig)) | ||
tx=$((tx+txSig)) | ||
if [ $rxSig -le $rxWorst ]; then | ||
rxWorst=$rxSig | ||
fi | ||
if [ $txSig -le $txWorst ]; then | ||
txWorst=$txSig | ||
fi | ||
if [ $rxSig -ge $rxBest ]; then | ||
rxBest=$rxSig | ||
fi | ||
if [ $txSig -ge $txBest ]; then | ||
txBest=$txSig | ||
fi | ||
done | ||
echo "" | ||
rx=$((rx/20)) | ||
tx=$((tx/20)) | ||
echo "Rx best: ${rxBest} avg: ${rx} worst: $rxWorst" | ||
echo "Tx best: ${txBest} avg: ${tx} worst: $txWorst" | ||
|
||
if [ $rx -le -42 ] && [ $rxBest -le -40 ]; then | ||
echo "********************FAIL************************" | ||
disconnectFromTF | ||
#echo "Done" | ||
#exit | ||
PASS=0 | ||
break | ||
fi | ||
|
||
if [ $tx -le -42 ] && [ $rxBest -le -40 ]; then | ||
echo "********************FAIL************************" | ||
disconnectFromTF | ||
#echo "Done" | ||
#exit | ||
PASS=0 | ||
break | ||
fi | ||
done | ||
|
||
if [ $PASS -eq 1 ]; then | ||
echo "********************PASS************************" | ||
disconnectFromTF | ||
fi | ||
#iw phy0 set txpower fixed 2700 | ||
#ssh $SSHARGS [email protected] "iw phy0 set txpower fixed 2700" | ||
echo "Done" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
|
||
# Send "app connected" message | ||
# Required artoo 0.7.9 or later. | ||
|
||
import socket | ||
import struct | ||
import sys | ||
|
||
DISCONNECTED = 0 | ||
CONNECTED = 1 | ||
|
||
# Must match flightcode/stm32 | ||
APP_CONNECTED_PORT = 5026 | ||
|
||
def send(app_connected): | ||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
msg = struct.pack("!B", app_connected) | ||
s.sendto(msg, ("127.0.0.1", APP_CONNECTED_PORT)) | ||
s.close() | ||
|
||
def send_connected(): | ||
send(CONNECTED) | ||
|
||
def send_disconnected(): | ||
send(DISCONNECTED) | ||
|
||
def usage(): | ||
print "usage: app_connected.py <connected>" | ||
print " where <connected> is one of" | ||
print " c[onnected] tell stm32 app is connected" | ||
print " d[isconnected] tell stm32 app is disconnected" | ||
|
||
if __name__ == "__main__": | ||
# one required argument: "c[onnected]" or "d[isconnected]" | ||
if len(sys.argv) != 2: | ||
usage() | ||
elif sys.argv[1][0] == "c": | ||
send_connected() | ||
elif sys.argv[1][0] == "d": | ||
send_disconnected() | ||
else: | ||
usage() |
Oops, something went wrong.