Skip to content

Commit

Permalink
mavextra: cope with more Lat/Lon/Lng combinations
Browse files Browse the repository at this point in the history
for distance_two()
  • Loading branch information
tridge committed Mar 19, 2023
1 parent d78a586 commit 5fcef0f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mavextra.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,18 +513,26 @@ def get_origin():

def get_lat_lon_alt(MSG):
'''gets lat and lon in radians and alt in meters from a position msg'''
if hasattr(MSG, 'Lat'):
if hasattr(MSG, 'Lat') and hasattr(MSG, 'Lng'):
lat = radians(MSG.Lat)
lon = radians(MSG.Lng)
alt = MSG.Alt
elif hasattr(MSG, 'Lat') and hasattr(MSG, 'Lon'):
lat = radians(MSG.Lat)
lon = radians(MSG.Lon)
alt = MSG.Alt
elif hasattr(MSG, 'cog'):
lat = radians(MSG.lat)*1.0e-7
lon = radians(MSG.lon)*1.0e-7
alt = MSG.alt*0.001
elif hasattr(MSG,'lat'):
elif hasattr(MSG,'lat') and hasattr(MSG,'lon'):
lat = radians(MSG.lat)
lon = radians(MSG.lon)
alt = MSG.alt*0.001
elif hasattr(MSG,'lat') and hasattr(MSG,'lng'):
lat = radians(MSG.lat)
lon = radians(MSG.lng)
alt = MSG.alt*0.001
elif hasattr(MSG, 'PN'):
# origin relative position from EKF
global ORGN
Expand All @@ -540,6 +548,7 @@ def get_lat_lon_alt(MSG):
return None
return (lat, lon, alt)


def _distance_two(MSG1, MSG2, horizontal=True):
'''distance between two points'''
(lat1, lon1, alt1) = get_lat_lon_alt(MSG1)
Expand Down

0 comments on commit 5fcef0f

Please sign in to comment.