Skip to content
Permalink
Browse files

change: report WGS-84 height above ellipsoid in ownship geometric

altitude as per GDL90 specs.
  • Loading branch information...
dndx committed Jul 29, 2018
1 parent 1201c5b commit 63f02e903ff4c8703abd0cac140947fb0299d189
Showing with 24 additions and 20 deletions.
  1. +10 −7 src/processor/ownship.rs
  2. +4 −3 src/protocol/gdl90.rs
  3. +2 −2 src/sensor/gnss/fake.rs
  4. +1 −1 src/sensor/gnss/mod.rs
  5. +3 −3 src/sensor/gnss/ublox.rs
  6. +2 −2 webui/index.html
  7. +2 −2 webui/js/index.js
@@ -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<i32>,
/// 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;

@@ -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

@@ -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,
@@ -54,7 +54,7 @@ pub struct Fix {
/// Height above MSL and accuracy in millimeters
pub height_msl: Reading<i32, u32>,
/// Height above ellipsoid and accuracy in millimeters
pub height_ellipsoid: OptionalReading<i32, u32>,
pub height_ellipsoid: Reading<i32, u32>,
/// Ground speed and accuracy in millimeters per second
pub gs: Reading<u32, u32>,
/// True course and accuracy in degrees
@@ -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,
@@ -17,10 +17,10 @@ <h1>Pitot Status</h1>
<b>Connection to Pitot: </b><span id="conn_stat">Disconnected</span><br>
<b>Latitude: </b><span id="lat">Unknown</span><br>
<b>Longitude: </b><span id="lon">Unknown</span><br>
<b>MSL Altitude: </b><span id="alt">Unknown</span> ft<br>
<b>MSL Altitude: </b><span id="msl_alt">Unknown</span> ft<br>
<b>Pressure Altitude: </b><span id="pres_alt">Unknown</span> ft<br>
<b>Vertical speed: </b><span id="vs">Unknown</span> fpm<br>
<b>Track: </b><span id="track">Unknown</span>&deg;<br>
<b>True track: </b><span id="true_track">Unknown</span>&deg;<br>
<b>Ground speed: </b><span id="gs">Unknown</span> kts<br>
<b>Fix quality: </b><span id="fix_quality">Unknown</span> <span id="nacp"></span><br>
<b>Number of SV used in fix: </b><span id="num_sv">Unknown</span><br>
@@ -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);

0 comments on commit 63f02e9

Please sign in to comment.
You can’t perform that action at this time.