Skip to content
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

AP_GPS: Fix undulation incorrect convention #29200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/AP_GPS/AP_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ void AP_GPS::send_mavlink_gps_raw(mavlink_channel_t chan)
float undulation = 0.0;
int32_t height_elipsoid_mm = 0;
if (get_undulation(0, undulation)) {
height_elipsoid_mm = loc.alt*10 - undulation*1000;
height_elipsoid_mm = loc.alt*10 + undulation*1000;
}
horizontal_accuracy(0, hacc);
vertical_accuracy(0, vacc);
Expand Down Expand Up @@ -1418,7 +1418,7 @@ void AP_GPS::send_mavlink_gps2_raw(mavlink_channel_t chan)
float undulation = 0.0;
float height_elipsoid_mm = 0;
if (get_undulation(1, undulation)) {
height_elipsoid_mm = loc.alt*10 - undulation*1000;
height_elipsoid_mm = loc.alt*10 + undulation*1000;
}
horizontal_accuracy(1, hacc);
vertical_accuracy(1, vacc);
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_GPS/AP_GPS_DroneCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void AP_GPS_DroneCAN::handle_fix2_msg(const uavcan_equipment_gnss_Fix2& msg, uin
loc.lng = msg.longitude_deg_1e8 / 10;
const int32_t alt_amsl_cm = msg.height_msl_mm / 10;
interim_state.have_undulation = true;
interim_state.undulation = (msg.height_msl_mm - msg.height_ellipsoid_mm) * 0.001;
interim_state.undulation = (msg.height_ellipsoid_mm - msg.height_msl_mm) * 0.001;
interim_state.location = loc;
set_alt_amsl_cm(interim_state, alt_amsl_cm);

Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_GPS/AP_GPS_ERB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ AP_GPS_ERB::_parse_gps(void)
state.location.lng = (int32_t)(_buffer.pos.longitude * (double)1e7);
state.location.lat = (int32_t)(_buffer.pos.latitude * (double)1e7);
state.have_undulation = true;
state.undulation = _buffer.pos.altitude_msl - _buffer.pos.altitude_ellipsoid;
state.undulation = _buffer.pos.altitude_ellipsoid - _buffer.pos.altitude_msl;
set_alt_amsl_cm(state, _buffer.pos.altitude_msl * 100);
state.status = next_fix;
_new_position = true;
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_GPS/AP_GPS_NMEA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool AP_GPS_NMEA::_term_complete()
_last_3D_velocity_ms = now;
state.location.lat = ag.lat*1.0e7;
state.location.lng = ag.lng*1.0e7;
state.undulation = -ag.undulation;
state.undulation = ag.undulation;
state.have_undulation = true;
set_alt_amsl_cm(state, ag.alt*1.0e2);
state.velocity = ag.vel_NED;
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_GPS/AP_GPS_SIRF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ AP_GPS_SIRF::_parse_gps(void)
state.location.lng = int32_t(be32toh(_buffer.nav.longitude));
const int32_t alt_amsl = int32_t(be32toh(_buffer.nav.altitude_msl));
const int32_t alt_ellipsoid = int32_t(be32toh(_buffer.nav.altitude_ellipsoid));
state.undulation = (alt_amsl - alt_ellipsoid)*0.01;
state.undulation = (alt_ellipsoid - alt_amsl)*0.01;
state.have_undulation = true;
set_alt_amsl_cm(state, alt_amsl);
state.ground_speed = int32_t(be32toh(_buffer.nav.ground_speed))*0.01f;
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_GPS/AP_GPS_UBLOX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ AP_GPS_UBLOX::_parse_gps(void)
state.location.lng = _buffer.posllh.longitude;
state.location.lat = _buffer.posllh.latitude;
state.have_undulation = true;
state.undulation = (_buffer.posllh.altitude_msl - _buffer.posllh.altitude_ellipsoid) * 0.001;
state.undulation = (_buffer.posllh.altitude_ellipsoid - _buffer.posllh.altitude_msl) * 0.001;
set_alt_amsl_cm(state, _buffer.posllh.altitude_msl / 10);

state.status = next_fix;
Expand Down Expand Up @@ -1655,7 +1655,7 @@ AP_GPS_UBLOX::_parse_gps(void)
state.location.lng = _buffer.pvt.lon;
state.location.lat = _buffer.pvt.lat;
state.have_undulation = true;
state.undulation = (_buffer.pvt.h_msl - _buffer.pvt.h_ellipsoid) * 0.001;
state.undulation = (_buffer.pvt.h_ellipsoid - _buffer.pvt.h_msl) * 0.001;
set_alt_amsl_cm(state, _buffer.pvt.h_msl / 10);
switch (_buffer.pvt.fix_type)
{
Expand Down
Loading