Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: added dup_samples.py #857

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions examples/dup_samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3

from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("log")

args = parser.parse_args()

from pymavlink import mavutil

def process(logfile):
'''look for duplicate raw gyro samples'''
mlog = mavutil.mavlink_connection(logfile)

last_gyr = {}
dup_count = {}
total_dup = {}
while True:
m = mlog.recv_match(type='GYR')
if m is None:
break
if not m.I in last_gyr:
last_gyr[m.I] = m
dup_count[m.I] = 0
total_dup[m.I] = 0
continue
axes = 0
if last_gyr[m.I].GyrX == m.GyrX and abs(m.GyrX) >= 1:
axes |= 1
if last_gyr[m.I].GyrY == m.GyrY and abs(m.GyrY) >= 1:
axes |= 2
if last_gyr[m.I].GyrX == m.GyrZ and abs(m.GyrZ) >= 1:
axes |= 4
if axes != 0:
if dup_count[m.I] == 0:
print("%s" % str(last_gyr[m.I]))
dup_count[m.I] += 1
total_dup[m.I] += 1
print("%s dup=%u axes=%u" % (str(m), dup_count[m.I], axes))
else:
dup_count[m.I] = 0
last_gyr[m.I] = m
print(total_dup)

process(args.log)

Loading