-
Notifications
You must be signed in to change notification settings - Fork 17k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copter: support SET_GPS_GLOBAL_ORIGIN message #6967
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, with minor exception of struct init
thanks!
ArduCopter/GCS_Mavlink.cpp
Outdated
if (!check_latlng(packet.latitude, packet.longitude)) { | ||
break; | ||
} | ||
Location ekf_origin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this in unsafe stack init of a structure. Need to zero, or set options
a8adb44
to
5d6cbd7
Compare
Issue raised by Tridge has been addressed in follow up commit so dismissing.
5d6cbd7
to
233c40f
Compare
plane.set_ekf_origin(ekf_origin); | ||
break; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this code be moved to the GCS_Mavlink library ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides my inline comment, LGTM.
I agree with @amilcarlucas though, I think we should be friendly to @peterbarker who has been moving identical code into GCS_Common; at least the MAVLink parsing could be there (the set_ekf_origin is also almost equal to all, but requires more changes to be common code).
ArduCopter/commands.cpp
Outdated
// returns true on success | ||
bool Copter::set_ekf_origin(const Location& loc) | ||
{ | ||
// only allow setting origin if motors are disarmed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? The origin will be set if GPS fix is acquired while flying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I also wondered if we should allow setting the ekf origin while moving. I can't think of a reason why we can't so I'll remove that restriction.
For this to be completed I guess #6720 should get merged at some point :) |
@amilcarlucas I don't see how that PR is in any way connected to this one...? |
That one also does a lot of stuff with origin and home. |
I'd suggest one more small change to DO_SET_HOME. I think we should make param1=2 mean "set latitude and longitude, but not altitude". |
also remove setting of origin from DO_SET_HOME command initialise ekf_origin location when consuming SET_GPS_GLOBAL_ORIGIN set_ekf_origin performs sanity check on location
previously the home position could be set from DCM This makes the setting of home slower but more accurate
ea4ca4d
to
d9bf36e
Compare
// check AHRS and GPS are within 10m of each other | ||
Location gps_loc = ahrs.get_gps().location(); | ||
Location ahrs_loc; | ||
if (ahrs.get_position(ahrs_loc)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to break the plane usage scenario where you move the aircraft from where it was booted then attempt to arm. If I left the plane at the new location long enough it was okay, however that took far longer then makes sense/would confuse a user in the field. (Confused me at least)
This PR resolves an issue that could cause vehicles to fly to extremely high altitudes during autonomous modes including RTL, Auto, Guided in cases where the ground station has sent an inaccurate altitude in a DO_SET_HOME message before the vehicle's EKF origin has been set (i.e. before a good GPS lock).
The following changes are included:
These changes mostly only affect Copter (the AP_Arming check affects all vehicles) but I will extend the changes to at least Rover and Tracker (and Plane if people want) if the peer review is happy with them.