mav_accel.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. '''
  3. show accel calibration for a set of logs
  4. '''
  5. from __future__ import print_function
  6. from argparse import ArgumentParser
  7. parser = ArgumentParser()
  8. parser.add_argument("--no-timestamps", dest="notimestamps", action='store_true', help="Log doesn't have timestamps")
  9. parser.add_argument("--planner", action='store_true', help="use planner file format")
  10. parser.add_argument("--robust", action='store_true', help="Enable robust parsing (skip over bad data)")
  11. parser.add_argument("logs", metavar="LOG", nargs="+")
  12. args = parser.parse_args()
  13. from pymavlink import mavutil
  14. def process(logfile):
  15. '''display accel cal for a log file'''
  16. mlog = mavutil.mavlink_connection(filename,
  17. planner_format=args.planner,
  18. notimestamps=args.notimestamps,
  19. robust_parsing=args.robust)
  20. m = mlog.recv_match(type='SENSOR_OFFSETS')
  21. if m is not None:
  22. z_sensor = (m.accel_cal_z - 9.805) * (4096/9.81)
  23. print("accel cal %5.2f %5.2f %5.2f %6u %s" % (
  24. m.accel_cal_x, m.accel_cal_y, m.accel_cal_z,
  25. z_sensor,
  26. logfile))
  27. total = 0.0
  28. for filename in args.logs:
  29. process(filename)