diff --git a/src/processor/ownship.rs b/src/processor/ownship.rs index 4e5048e..f800e6a 100644 --- a/src/processor/ownship.rs +++ b/src/processor/ownship.rs @@ -25,8 +25,10 @@ pub struct Ownship { pub lat: f32, /// Longitude in deg pub lon: f32, - /// Height above WGS-84 ellipsoid if available, otherwise MSL in ft - pub altitude: i32, + /// MSL altitude in ft + pub msl_altitude: i32, + /// Height above WGS-84 ellipsoid in ft + pub hae_altitude: i32, /// Cabin pressure altitude in ft pub pressure_altitude: Option, /// Vertical speed @@ -37,7 +39,8 @@ pub struct Ownship { pub nacp: u8, /// Ground speed in kts pub gs: f32, - pub track: f32, + /// True track in degrees + pub true_track: f32, } impl Processor for Ownship { @@ -65,12 +68,12 @@ impl Processor for Ownship { self.lat = (f.lat_lon.0).0; self.lon = (f.lat_lon.0).1; - // GDL90 says we should use height above ellipsoid - // here, but most EFB displays as MSL - self.altitude = mm_to_ft!(f.height_msl.0).round() as i32; + + self.msl_altitude = mm_to_ft!(f.height_msl.0).round() as i32; + self.hae_altitude = mm_to_ft!(f.height_ellipsoid.0).round() as i32; self.gs = mmps_to_kts!(f.gs.0); - self.track = f.true_course.0; + self.true_track = f.true_course.0; self.valid = true; diff --git a/src/protocol/gdl90.rs b/src/protocol/gdl90.rs index 4be7486..32e0081 100644 --- a/src/protocol/gdl90.rs +++ b/src/protocol/gdl90.rs @@ -155,7 +155,8 @@ impl GDL90 { buf[23] = 'o' as u8; buf[24] = 't' as u8; - buf[38] = 0x01; // geometric altitude datum = MSL + // datum is WGS-84 ellipsoid + buf[38] = 0x00; Payload { queueable: false, @@ -185,7 +186,7 @@ impl GDL90 { buf[0] = 0x0B; // type = ownship geometric - let alt = (e.altitude / 5) as i16; + let alt = (e.hae_altitude / 5) as i16; buf[1] = (alt >> 8) as u8; buf[2] = (alt & 0x00FF) as u8; @@ -238,7 +239,7 @@ impl GDL90 { buf[15] = (((gs & 0x00F) << 4) | ((vs & 0x0F00) >> 8)) as u8; buf[16] = (vs & 0xFF) as u8; - buf[17] = crs_to_gdl90(e.track); + buf[17] = crs_to_gdl90(e.true_track); buf[18] = 0x01; // Light (ICAO) < 15 500 lbs diff --git a/src/sensor/gnss/fake.rs b/src/sensor/gnss/fake.rs index 51ce5a0..fcaf178 100644 --- a/src/sensor/gnss/fake.rs +++ b/src/sensor/gnss/fake.rs @@ -27,7 +27,7 @@ impl Sensor for FakeGNSSProvider { fix: Some(Fix { lat_lon: ((12345_f32, 12345_f32), Some(1000)), height_msl: (1000, Some(500)), - height_ellipsoid: Some((900, Some(500))), + height_ellipsoid: (900, Some(500)), gs: (10000, Some(100)), true_course: (123_f32, Some(2_f32)), quality: FixQuality::ThreeDim, @@ -71,7 +71,7 @@ mod tests { fix: Some(Fix { lat_lon: ((12345_f32, 12345_f32), Some(1000)), height_msl: (1000, Some(500)), - height_ellipsoid: Some((900, Some(500))), + height_ellipsoid: (900, Some(500)), gs: (10000, Some(100)), true_course: (123_f32, Some(2_f32)), quality: FixQuality::ThreeDim, diff --git a/src/sensor/gnss/mod.rs b/src/sensor/gnss/mod.rs index 24fb7aa..b139e6d 100644 --- a/src/sensor/gnss/mod.rs +++ b/src/sensor/gnss/mod.rs @@ -54,7 +54,7 @@ pub struct Fix { /// Height above MSL and accuracy in millimeters pub height_msl: Reading, /// Height above ellipsoid and accuracy in millimeters - pub height_ellipsoid: OptionalReading, + pub height_ellipsoid: Reading, /// Ground speed and accuracy in millimeters per second pub gs: Reading, /// True course and accuracy in degrees diff --git a/src/sensor/gnss/ublox.rs b/src/sensor/gnss/ublox.rs index 9bbb9a1..44602bd 100644 --- a/src/sensor/gnss/ublox.rs +++ b/src/sensor/gnss/ublox.rs @@ -403,7 +403,7 @@ fn fix_from_pvt( Some(horizontal_accuracy), ), height_msl: (height_msl, Some(vertical_accuracy)), - height_ellipsoid: Some((height_ellipsoid, Some(vertical_accuracy))), + height_ellipsoid: (height_ellipsoid, Some(vertical_accuracy)), gs: (gs as u32, Some(gs_accuracy)), true_course: (hdg as f32 * 1.0e-5, Some(hdg_accuracy as f32 * 1.0e-5)), quality: if fix_status & 0x02 != 0 { @@ -913,7 +913,7 @@ mod tests { fix: Some(Fix { lat_lon: ((37.65518, -122.492645), Some(83757)), height_msl: (16303, Some(468059)), - height_ellipsoid: Some((-13707, Some(468059))), + height_ellipsoid: (-13707, Some(468059)), gs: (688, Some(3919)), true_course: (0_f32, Some(180_f32)), quality: FixQuality::ThreeDim, @@ -941,7 +941,7 @@ mod tests { fix: Some(Fix { lat_lon: ((37.65518, -122.492645), Some(83757)), height_msl: (16303, Some(468059)), - height_ellipsoid: Some((-13707, Some(468059))), + height_ellipsoid: (-13707, Some(468059)), gs: (688, Some(3919)), true_course: (0_f32, Some(180_f32)), quality: FixQuality::SBAS, diff --git a/webui/index.html b/webui/index.html index b582288..e50a843 100644 --- a/webui/index.html +++ b/webui/index.html @@ -17,10 +17,10 @@

Pitot Status

Connection to Pitot: Disconnected
Latitude: Unknown
Longitude: Unknown
- MSL Altitude: Unknown ft
+ MSL Altitude: Unknown ft
Pressure Altitude: Unknown ft
Vertical speed: Unknown fpm
- Track: Unknown°
+ True track: Unknown°
Ground speed: Unknown kts
Fix quality: Unknown
Number of SV used in fix: Unknown
diff --git a/webui/js/index.js b/webui/js/index.js index 66a983c..08a2720 100644 --- a/webui/js/index.js +++ b/webui/js/index.js @@ -56,8 +56,8 @@ case "Ownship": $('#lat').text(m.lat.toFixed(4)); $('#lon').text(m.lon.toFixed(4)); - $('#alt').text(m.altitude); - $('#track').text(m.track.toFixed(0)); + $('#msl_alt').text(m.msl_altitude); + $('#true_track').text(m.true_track.toFixed(0)); $('#nacp').text('(' + nacp[m.nacp] + ')'); $('#gs').text(m.gs.toFixed(0)); $('#vs').text(m.vs);