Skip to content

Commit 9e503b3

Browse files
authored
Add Navigation measurement and PVT solver (#30)
1 parent 64ff337 commit 9e503b3

File tree

5 files changed

+1667
-0
lines changed

5 files changed

+1667
-0
lines changed

build.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ fn main() {
2727
.header(format!("{}/include/swiftnav/troposphere.h", dst.display()))
2828
.header(format!("{}/include/swiftnav/ephemeris.h", dst.display()))
2929
.header(format!("{}/include/swiftnav/edc.h", dst.display()))
30+
.header(format!("{}/include/swiftnav/nav_meas.h", dst.display()))
31+
.header(format!(
32+
"{}/include/swiftnav/single_epoch_solver.h",
33+
dst.display()
34+
))
3035
// Tell cargo to invalidate the built crate whenever any of the
3136
// included header files changed.
3237
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
@@ -83,6 +88,20 @@ fn main() {
8388
.whitelist_function("decode_bds_d1_ephemeris")
8489
.whitelist_function("decode_gal_ephemeris")
8590
.whitelist_function("crc24q")
91+
.whitelist_type("measurement_std_t")
92+
.whitelist_function("nav_meas_flags_valid")
93+
.whitelist_function("pseudorange_valid")
94+
.whitelist_function("encode_lock_time")
95+
.whitelist_function("decode_lock_time")
96+
.whitelist_var("NAV_MEAS_FLAG_CODE_VALID")
97+
.whitelist_var("NAV_MEAS_FLAG_MEAS_DOPPLER_VALID")
98+
.whitelist_var("NAV_MEAS_FLAG_CN0_VALID")
99+
.whitelist_function("sid_set_init")
100+
.whitelist_function("sid_set_get_sat_count")
101+
.whitelist_function("sid_set_get_sig_count")
102+
.whitelist_function("sid_set_contains")
103+
.whitelist_function("calc_PVT")
104+
.whitelist_var("pvt_err_msg")
86105
// Finish the builder and generate the bindings.
87106
.generate()
88107
// Unwrap the Result and panic on failure.

src/coords.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,68 @@ impl AsMut<[f64; 3]> for ECEF {
305305
}
306306
}
307307

308+
/// Local North East Down reference frame coordinates
309+
///
310+
/// Internally stored as an array of 3 [f64](std::f64) values: N, E, D all in meters
311+
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
312+
pub struct NED([f64; 3]);
313+
314+
impl NED {
315+
pub fn new(n: f64, e: f64, d: f64) -> NED {
316+
NED([n, e, d])
317+
}
318+
319+
pub fn from_array(array: &[f64; 3]) -> NED {
320+
NED(*array)
321+
}
322+
323+
pub fn as_ptr(&self) -> *const [f64; 3] {
324+
&self.0
325+
}
326+
327+
pub fn as_mut_ptr(&mut self) -> *mut [f64; 3] {
328+
&mut self.0
329+
}
330+
331+
pub fn as_array_ref(&self) -> &[f64; 3] {
332+
&self.0
333+
}
334+
335+
pub fn as_mut_array_ref(&mut self) -> &mut [f64; 3] {
336+
&mut self.0
337+
}
338+
339+
pub fn n(&self) -> f64 {
340+
self.0[0]
341+
}
342+
343+
pub fn e(&self) -> f64 {
344+
self.0[1]
345+
}
346+
347+
pub fn d(&self) -> f64 {
348+
self.0[2]
349+
}
350+
}
351+
352+
impl Default for NED {
353+
fn default() -> Self {
354+
Self::new(0., 0., 0.)
355+
}
356+
}
357+
358+
impl AsRef<[f64; 3]> for NED {
359+
fn as_ref(&self) -> &[f64; 3] {
360+
&self.0
361+
}
362+
}
363+
364+
impl AsMut<[f64; 3]> for NED {
365+
fn as_mut(&mut self) -> &mut [f64; 3] {
366+
&mut self.0
367+
}
368+
}
369+
308370
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
309371
pub struct AzimuthElevation {
310372
pub az: f64,

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub mod coords;
1919
pub mod edc;
2020
pub mod ephemeris;
2121
pub mod ionosphere;
22+
pub mod navmeas;
2223
pub mod signal;
24+
pub mod solver;
2325
pub mod time;
2426
pub mod troposphere;

0 commit comments

Comments
 (0)