ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Copter: switch to NED for WPNav

Open jason4short opened this issue 13 years ago • 6 comments

// wpinav_set_origin_and_destination - set origin and destination using lat/lon coordinates
public function wpinav_set_origin_and_destination(origin:Location, destination:Location):void
{
    //trace("wpinav_set_origin_and_destination", destination);
    wpinav_origin.x         = (origin.lat-home.lat) * LATLON_TO_CM;
    wpinav_origin.y         = (origin.lng-home.lng) * LATLON_TO_CM * scaleLongDown;
    wpinav_destination.x    = (destination.lat-home.lat) * LATLON_TO_CM;
    wpinav_destination.y    = (destination.lng-home.lng) * LATLON_TO_CM * scaleLongDown;
    wpinav_pos_delta.x      = wpinav_destination.x - wpinav_origin.x;
    wpinav_pos_delta.y      = wpinav_destination.y - wpinav_origin.y;
    wpinav_track_length     = wpinav_pos_delta.length;
    wpinav_track_desired    = 0;

    // set next_WP, prev_WP for reporting purposes
    // To-Do: move calcs below to a function
    set_next_WP_latlon(
        home.lat + wpinav_destination.x / LATLON_TO_CM,
        home.lng + wpinav_destination.y / LATLON_TO_CM * scaleLongUp);
}

Throughout the code, the lat is assigned to the X axis. Latitude is North/South so it should be the Y axis!

Jason

jason4short avatar Apr 05 '13 20:04 jason4short

Yes, I agree it's backwards. I've sent an email to the group re switching to NED...this would also mean switching the altitude to be negative at least for the internal calculations in the navigation library although we wouldn't want to expose that to the user...we can leave them dealing with lat-lon-alt which is more understandable to humans.

rmackay9 avatar Apr 06 '13 02:04 rmackay9

@rmackay9 I think this has been fixed.

squilter avatar Aug 09 '15 21:08 squilter

@squilter, the inertial nav part has been fixed because the EKF uses NED. The waypoint controller is still all NEU though. I'll update the subject but we probably need to leave this open until we convert the navigation code too.

rmackay9 avatar Aug 10 '15 06:08 rmackay9

Does the waypoint controller still use NEU?

Naterater avatar Jan 17 '19 23:01 Naterater

yes it does I'm afraid

rmackay9 avatar Jan 18 '19 01:01 rmackay9

Closed by PR #31513. That PR converted AC_WPNav and AC_PosControl to work internally in NED metres (93b5456b6b, aa69e790bc); waypoint origin/destination are now stored as _origin_ned_m/_destination_ned_m, and the remaining NEU centimetre functions are conversion wrappers.

peterbarker avatar Nov 15 '26 05:11 peterbarker