def position_messages_from_tlog(filename):
 messages = []
 mlog = mavutil.mavlink_connection(filename)
 while True:
  try:
   m = mlog.recv_match(type=['GLOBAL_POSITION_INT'])
   if (m is None):
    break
  except Exception:
   break
  if (m.lat == 0):
   continue
  messages.append(m)
 num_points = len(messages)
 keep_point_distance = 3
 kept_messages = []
 kept_messages.append(messages[0])
 pt1num = 0
 pt2num = 1
 while True:
  if ((pt2num == (num_points - 1)) or (len(kept_messages) == 99)):
   kept_messages.append(messages[pt2num])
   break
  pt1 = LocationGlobalRelative((messages[pt1num].lat / 10000000.0), (messages[pt1num].lon / 10000000.0), 0)
  pt2 = LocationGlobalRelative((messages[pt2num].lat / 10000000.0), (messages[pt2num].lon / 10000000.0), 0)
  distance_between_points = get_distance_metres(pt1, pt2)
  if (distance_between_points > keep_point_distance):
   kept_messages.append(messages[pt2num])
   pt1num = pt2num
  pt2num = (pt2num + 1)
 return kept_messages

def position_messages_from_tlog ( filename ) : messages = [ ] mlog = mavutil . mavlink_connection ( filename ) while True : try : m = mlog . recv_match ( type = [ 'GLOBAL_POSITION_INT' ] ) if ( m is None ) : break except Exception : break if ( m . lat == 0 ) : continue messages . append ( m ) num_points = len ( messages ) keep_point_distance = 3 kept_messages = [ ] kept_messages . append ( messages [ 0 ] ) pt1num = 0 pt2num = 1 while True : if ( ( pt2num == ( num_points - 1 ) ) or ( len ( kept_messages ) == 99 ) ) : kept_messages . append ( messages [ pt2num ] ) break pt1 = LocationGlobalRelative ( ( messages [ pt1num ] . lat / 10000000.0 ) , ( messages [ pt1num ] . lon / 10000000.0 ) , 0 ) pt2 = LocationGlobalRelative ( ( messages [ pt2num ] . lat / 10000000.0 ) , ( messages [ pt2num ] . lon / 10000000.0 ) , 0 ) distance_between_points = get_distance_metres ( pt1 , pt2 ) if ( distance_between_points > keep_point_distance ) : kept_messages . append ( messages [ pt2num ] ) pt1num = pt2num pt2num = ( pt2num + 1 ) return kept_messages
given telemetry log .