dronekit / dronekit-python

DroneKit-Python library for communicating with Drones via MAVLink.
https://readthedocs.org/projects/dronekit-python/
Apache License 2.0
1.58k stars 1.44k forks source link

Get gps velocity #1177

Open allenizac opened 1 year ago

allenizac commented 1 year ago

how to i get the gps velocity from this two def or other ways

def get_location_metres(original_location, dNorth, dEast): earth_radius = 6378137.0 #Radius of "spherical" earth

Coordinate offsets in radians

dLat = dNorth/earth_radius
dLon = dEast/(earth_radius*math.cos(math.pi*original_location.lat/180))

New position in decimal degrees

newlat = original_location.lat + (dLat * 180/math.pi)
newlon = original_location.lon + (dLon * 180/math.pi)
if type(original_location) is LocationGlobal:
    targetlocation=LocationGlobal(newlat, newlon,original_location.alt)
elif type(original_location) is LocationGlobalRelative:
    targetlocation=LocationGlobalRelative(newlat, newlon,original_location.alt)
else:
    raise Exception("Invalid Location object passed")

​ return targetlocation; ​ def get_distance_metres(aLocation1, aLocation2): dlat = aLocation2.lat - aLocation1.lat dlong = aLocation2.lon - aLocation1.lon return math.sqrt((dlatdlat) + (dlongdlong)) * 1.113195e5