question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get local ned location

See original GitHub issue

Hello everyone,

I am new with MAVSDK Python and trying to get location of the vehicle in local ned frame. I am able to get the location in global frame with drone.telemetry.position() but I need to convert it into local frame in every target point reach check. I thought, since we are able to set target location with local ned frame, there must be the get part but I can not find it in the examples nor in the documentation.

I am looking for the MAVSDK Python equivalent of the vehicle.location.local_frame from Dronekit. What is the best way to do it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
canberkdurmuscommented, Mar 20, 2020

I just finished implementation and testing according to the cpp version. Will compare it with this one also, thank you so much @JonasVautherin 👍

0reactions
JonasVautherincommented, Mar 20, 2020

Here it is in Python:

def global_from_local(north_m, east_m, ref_lat, ref_lon):
    world_radius_m = 6371000
    ref_lat_rad = math.pi / 180 * ref_lat
    ref_lon_rad = math.pi / 180 * ref_lon
    x_rad = north_m / world_radius_m
    y_rad = east_m / world_radius_m

    c = math.sqrt(x_rad * x_rad + y_rad * y_rad);

    if (c == 0):
        return ref_lat, ref_lon

    sin_c = math.sin(c)
    cos_c = math.cos(c)

    ref_sin_lat = math.sin(ref_lat_rad)
    ref_cos_lat = math.cos(ref_lat_rad)

    lat_rad = math.asin(cos_c * ref_sin_lat + (x_rad * sin_c * ref_cos_lat) / c)
    lon_rad = (ref_lon_rad + math.atan2(y_rad * sin_c, c * ref_cos_lat * cos_c - x_rad * ref_sin_lat * sin_c))

    global_lat = 180 / math.pi * lat_rad
    global_lon = 180 / math.pi * lon_rad

    return global_lat, global_lon
Read more comments on GitHub >

github_iconTop Results From Across the Web

Local tangent plane coordinates - Wikipedia
The east north up (ENU) local tangent plane is similar to NED, except for swapping 'down' for 'up' and x for y.
Read more >
Search Your Location | FEMA.gov
Find the most relevant information by searching your location, including: Active and past disaster declarations. Helpful resources specific to ...
Read more >
Local Cartesian (NED) to Geodetic (Lat,Lon,Alt) Conversion
The obvious question is by how much the current location on local Cartesian NED (xNorth,yEast,zDown) can be far away from the reference point...
Read more >
NED frame and Home Position - PX4 Discuss
Hi, I have a question about Home Position and NED Frame. ... compute this point from the current position (geodetic and local cartesian)...
Read more >
MATLAB ned2aer - MathWorks
This MATLAB function transforms the local north-east-down (NED) Cartesian coordinates specified by ... Then, calculate the AER coordinates of the landmark.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found