Skip to content

Commit a0bb8e0

Browse files
authored
Remove SBP conversions (#50)
* remove sbp feature * Add getter/setter for navmeas flags
1 parent b8e9532 commit a0bb8e0

File tree

6 files changed

+93
-284
lines changed

6 files changed

+93
-284
lines changed

Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ readme = "README.md"
88
repository = "https://github.com/swift-nav/swiftnav-rs"
99
license = "LGPL-3.0"
1010

11-
[features]
12-
sbp-conversions = ["sbp"]
13-
14-
[dependencies]
15-
sbp = { git = "https://github.com/swift-nav/libsbp.git", rev="51660bd02f18216aef7abcdebf27fec72a93c161", optional = true }
16-
1711
[build-dependencies]
1812
bindgen = "0.58"
1913
cmake = "0.1"

build.rs

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -44,89 +44,89 @@ fn main() {
4444
// Tell cargo to invalidate the built crate whenever any of the
4545
// included header files changed.
4646
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
47-
.blacklist_type("u8")
48-
.blacklist_type("u16")
49-
.blacklist_type("u32")
50-
.whitelist_type("gps_time_t")
51-
.whitelist_function("gpsdifftime")
52-
.whitelist_function("gps_time_valid")
53-
.whitelist_function("add_secs")
54-
.whitelist_var("FLOAT_EQUALITY_EPS")
55-
.whitelist_var("MINUTE_SECS")
56-
.whitelist_var("HOUR_SECS")
57-
.whitelist_var("DAY_SECS")
58-
.whitelist_var("WEEK_SECS")
59-
.whitelist_type("constellation_t")
60-
.whitelist_type("code_t")
61-
.whitelist_type("gnss_signal_t")
62-
.whitelist_function("is_gps")
63-
.whitelist_function("is_sbas")
64-
.whitelist_function("is_glo")
65-
.whitelist_function("is_bds2")
66-
.whitelist_function("is_gal")
67-
.whitelist_function("is_qzss")
68-
.whitelist_function("sid_to_constellation")
69-
.whitelist_function("sid_valid")
70-
.whitelist_function("code_to_constellation")
71-
.whitelist_function("constellation_to_sat_count")
72-
.whitelist_function("constellation_to_string")
73-
.whitelist_function("code_to_sig_count")
74-
.whitelist_function("code_to_chip_count")
75-
.whitelist_function("code_to_chip_rate")
76-
.whitelist_function("sid_to_carr_freq")
77-
.whitelist_function("code_string_to_enum")
78-
.whitelist_function("code_to_string")
79-
.whitelist_var("NUM_SATS_GPS")
80-
.whitelist_var("NUM_SATS_SBAS")
81-
.whitelist_var("NUM_SATS_GLO")
82-
.whitelist_var("NUM_SATS_BDS")
83-
.whitelist_var("NUM_SATS_GAL")
84-
.whitelist_var("NUM_SATS_QZS")
85-
.whitelist_var("GPS_FIRST_PRN")
86-
.whitelist_var("SBAS_FIRST_PRN")
87-
.whitelist_var("GLO_FIRST_PRN")
88-
.whitelist_var("BDS_FIRST_PRN")
89-
.whitelist_var("GAL_FIRST_PRN")
90-
.whitelist_var("QZS_FIRST_PRN")
91-
.whitelist_function("llhrad2deg")
92-
.whitelist_function("llhdeg2rad")
93-
.whitelist_function("wgsllh2ecef")
94-
.whitelist_function("wgsecef2llh")
95-
.whitelist_function("wgsecef2azel")
96-
.whitelist_type("ionosphere_t")
97-
.whitelist_function("calc_ionosphere")
98-
.whitelist_function("decode_iono_parameters")
99-
.whitelist_function("calc_troposphere")
100-
.whitelist_type("ephemeris_t")
101-
.whitelist_function("calc_sat_state")
102-
.whitelist_function("calc_sat_az_el")
103-
.whitelist_function("calc_sat_doppler")
104-
.whitelist_function("get_ephemeris_status_t")
105-
.whitelist_function("ephemeris_valid_detailed")
106-
.whitelist_function("ephemeris_valid")
107-
.whitelist_function("ephemeris_equal")
108-
.whitelist_function("ephemeris_healthy")
109-
.whitelist_function("get_ephemeris_iod_or_iodcrc")
110-
.whitelist_function("decode_ephemeris")
111-
.whitelist_function("decode_bds_d1_ephemeris")
112-
.whitelist_function("decode_gal_ephemeris")
113-
.whitelist_function("crc24q")
114-
.whitelist_type("measurement_std_t")
115-
.whitelist_function("nav_meas_flags_valid")
116-
.whitelist_function("pseudorange_valid")
117-
.whitelist_function("encode_lock_time")
118-
.whitelist_function("decode_lock_time")
119-
.whitelist_var("NAV_MEAS_FLAG_CODE_VALID")
120-
.whitelist_var("NAV_MEAS_FLAG_MEAS_DOPPLER_VALID")
121-
.whitelist_var("NAV_MEAS_FLAG_CN0_VALID")
122-
.whitelist_function("sid_set_init")
123-
.whitelist_function("sid_set_get_sat_count")
124-
.whitelist_function("sid_set_get_sig_count")
125-
.whitelist_function("sid_set_contains")
126-
.whitelist_function("calc_PVT")
127-
.whitelist_var("pvt_err_msg")
128-
.whitelist_function("correct_iono")
129-
.whitelist_function("correct_tropo")
47+
.blocklist_type("u8")
48+
.blocklist_type("u16")
49+
.blocklist_type("u32")
50+
.allowlist_type("gps_time_t")
51+
.allowlist_function("gpsdifftime")
52+
.allowlist_function("gps_time_valid")
53+
.allowlist_function("add_secs")
54+
.allowlist_var("FLOAT_EQUALITY_EPS")
55+
.allowlist_var("MINUTE_SECS")
56+
.allowlist_var("HOUR_SECS")
57+
.allowlist_var("DAY_SECS")
58+
.allowlist_var("WEEK_SECS")
59+
.allowlist_type("constellation_t")
60+
.allowlist_type("code_t")
61+
.allowlist_type("gnss_signal_t")
62+
.allowlist_function("is_gps")
63+
.allowlist_function("is_sbas")
64+
.allowlist_function("is_glo")
65+
.allowlist_function("is_bds2")
66+
.allowlist_function("is_gal")
67+
.allowlist_function("is_qzss")
68+
.allowlist_function("sid_to_constellation")
69+
.allowlist_function("sid_valid")
70+
.allowlist_function("code_to_constellation")
71+
.allowlist_function("constellation_to_sat_count")
72+
.allowlist_function("constellation_to_string")
73+
.allowlist_function("code_to_sig_count")
74+
.allowlist_function("code_to_chip_count")
75+
.allowlist_function("code_to_chip_rate")
76+
.allowlist_function("sid_to_carr_freq")
77+
.allowlist_function("code_string_to_enum")
78+
.allowlist_function("code_to_string")
79+
.allowlist_var("NUM_SATS_GPS")
80+
.allowlist_var("NUM_SATS_SBAS")
81+
.allowlist_var("NUM_SATS_GLO")
82+
.allowlist_var("NUM_SATS_BDS")
83+
.allowlist_var("NUM_SATS_GAL")
84+
.allowlist_var("NUM_SATS_QZS")
85+
.allowlist_var("GPS_FIRST_PRN")
86+
.allowlist_var("SBAS_FIRST_PRN")
87+
.allowlist_var("GLO_FIRST_PRN")
88+
.allowlist_var("BDS_FIRST_PRN")
89+
.allowlist_var("GAL_FIRST_PRN")
90+
.allowlist_var("QZS_FIRST_PRN")
91+
.allowlist_function("llhrad2deg")
92+
.allowlist_function("llhdeg2rad")
93+
.allowlist_function("wgsllh2ecef")
94+
.allowlist_function("wgsecef2llh")
95+
.allowlist_function("wgsecef2azel")
96+
.allowlist_type("ionosphere_t")
97+
.allowlist_function("calc_ionosphere")
98+
.allowlist_function("decode_iono_parameters")
99+
.allowlist_function("calc_troposphere")
100+
.allowlist_type("ephemeris_t")
101+
.allowlist_function("calc_sat_state")
102+
.allowlist_function("calc_sat_az_el")
103+
.allowlist_function("calc_sat_doppler")
104+
.allowlist_function("get_ephemeris_status_t")
105+
.allowlist_function("ephemeris_valid_detailed")
106+
.allowlist_function("ephemeris_valid")
107+
.allowlist_function("ephemeris_equal")
108+
.allowlist_function("ephemeris_healthy")
109+
.allowlist_function("get_ephemeris_iod_or_iodcrc")
110+
.allowlist_function("decode_ephemeris")
111+
.allowlist_function("decode_bds_d1_ephemeris")
112+
.allowlist_function("decode_gal_ephemeris")
113+
.allowlist_function("crc24q")
114+
.allowlist_type("measurement_std_t")
115+
.allowlist_function("nav_meas_flags_valid")
116+
.allowlist_function("pseudorange_valid")
117+
.allowlist_function("encode_lock_time")
118+
.allowlist_function("decode_lock_time")
119+
.allowlist_var("NAV_MEAS_FLAG_CODE_VALID")
120+
.allowlist_var("NAV_MEAS_FLAG_MEAS_DOPPLER_VALID")
121+
.allowlist_var("NAV_MEAS_FLAG_CN0_VALID")
122+
.allowlist_function("sid_set_init")
123+
.allowlist_function("sid_set_get_sat_count")
124+
.allowlist_function("sid_set_get_sig_count")
125+
.allowlist_function("sid_set_contains")
126+
.allowlist_function("calc_PVT")
127+
.allowlist_var("pvt_err_msg")
128+
.allowlist_function("correct_iono")
129+
.allowlist_function("correct_tropo")
130130
// Finish the builder and generate the bindings.
131131
.generate()
132132
// Unwrap the Result and panic on failure.

src/ephemeris.rs

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -405,137 +405,6 @@ impl Ephemeris {
405405
}
406406
}
407407

408-
#[cfg(feature = "sbp-conversions")]
409-
mod sbp_error {
410-
use crate::{signal::InvalidGnssSignal, time::InvalidGpsTime};
411-
use std::error::Error;
412-
use std::fmt;
413-
414-
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
415-
pub enum EphemerisDecodeError {
416-
InvalidTime(InvalidGpsTime),
417-
InvalidSignal(InvalidGnssSignal),
418-
}
419-
420-
impl fmt::Display for EphemerisDecodeError {
421-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
422-
match self {
423-
EphemerisDecodeError::InvalidTime(time_err) => time_err.fmt(f),
424-
EphemerisDecodeError::InvalidSignal(sig_err) => sig_err.fmt(f),
425-
}
426-
}
427-
}
428-
429-
impl Error for EphemerisDecodeError {}
430-
431-
impl From<InvalidGpsTime> for EphemerisDecodeError {
432-
fn from(other: InvalidGpsTime) -> EphemerisDecodeError {
433-
EphemerisDecodeError::InvalidTime(other)
434-
}
435-
}
436-
437-
impl From<InvalidGnssSignal> for EphemerisDecodeError {
438-
fn from(other: InvalidGnssSignal) -> EphemerisDecodeError {
439-
EphemerisDecodeError::InvalidSignal(other)
440-
}
441-
}
442-
}
443-
444-
#[cfg(feature = "sbp-conversions")]
445-
pub use sbp_error::EphemerisDecodeError;
446-
447-
#[cfg(feature = "sbp-conversions")]
448-
impl std::convert::TryFrom<sbp::messages::observation::MsgEphemerisGPS> for Ephemeris {
449-
type Error = EphemerisDecodeError;
450-
451-
fn try_from(
452-
eph: sbp::messages::observation::MsgEphemerisGPS,
453-
) -> Result<Ephemeris, EphemerisDecodeError> {
454-
use std::convert::TryInto;
455-
456-
Ok(Ephemeris::new(
457-
eph.common.sid.try_into()?,
458-
eph.common.toe.try_into()?,
459-
eph.common.ura,
460-
eph.common.fit_interval,
461-
eph.common.valid,
462-
eph.common.health_bits,
463-
0,
464-
EphemerisTerms::new_kepler(
465-
Constellation::Gps,
466-
[eph.tgd, 0.],
467-
eph.c_rc as f64,
468-
eph.c_rs as f64,
469-
eph.c_uc as f64,
470-
eph.c_us as f64,
471-
eph.c_ic as f64,
472-
eph.c_is as f64,
473-
eph.dn,
474-
eph.m0,
475-
eph.ecc,
476-
eph.sqrta,
477-
eph.omega0,
478-
eph.omegadot,
479-
eph.w,
480-
eph.inc,
481-
eph.inc_dot,
482-
eph.af0 as f64,
483-
eph.af1 as f64,
484-
eph.af2 as f64,
485-
eph.toc.try_into()?,
486-
eph.iodc,
487-
eph.iode as u16,
488-
),
489-
))
490-
}
491-
}
492-
493-
#[cfg(feature = "sbp-conversions")]
494-
impl std::convert::TryFrom<sbp::messages::observation::MsgEphemerisGal> for Ephemeris {
495-
type Error = EphemerisDecodeError;
496-
497-
fn try_from(
498-
eph: sbp::messages::observation::MsgEphemerisGal,
499-
) -> Result<Ephemeris, EphemerisDecodeError> {
500-
use std::convert::TryInto;
501-
502-
Ok(Ephemeris::new(
503-
eph.common.sid.try_into()?,
504-
eph.common.toe.try_into()?,
505-
eph.common.ura,
506-
eph.common.fit_interval,
507-
eph.common.valid,
508-
eph.common.health_bits,
509-
eph.source,
510-
EphemerisTerms::new_kepler(
511-
Constellation::Gal,
512-
[eph.bgd_e1e5a, eph.bgd_e1e5b],
513-
eph.c_rc as f64,
514-
eph.c_rs as f64,
515-
eph.c_uc as f64,
516-
eph.c_us as f64,
517-
eph.c_ic as f64,
518-
eph.c_is as f64,
519-
eph.dn,
520-
eph.m0,
521-
eph.ecc,
522-
eph.sqrta,
523-
eph.omega0,
524-
eph.omegadot,
525-
eph.w,
526-
eph.inc,
527-
eph.inc_dot,
528-
eph.af0 as f64,
529-
eph.af1 as f64,
530-
eph.af2 as f64,
531-
eph.toc.try_into()?,
532-
eph.iodc,
533-
eph.iode as u16,
534-
),
535-
))
536-
}
537-
}
538-
539408
impl PartialEq for Ephemeris {
540409
fn eq(&self, other: &Self) -> bool {
541410
unsafe { c_bindings::ephemeris_equal(&self.0, &other.0) }

src/navmeas.rs

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use std::time::Duration;
1515
const NAV_MEAS_FLAG_CODE_VALID: u16 = 1 << 0;
1616
const NAV_MEAS_FLAG_MEAS_DOPPLER_VALID: u16 = 1 << 2;
1717
const NAV_MEAS_FLAG_CN0_VALID: u16 = 1 << 5;
18-
#[allow(dead_code)]
19-
const NAV_MEAS_FLAG_RAIM_EXCLUSION: u16 = 1 << 6;
18+
pub const NAV_MEAS_FLAG_RAIM_EXCLUSION: u16 = 1 << 6;
2019

2120
/// Represents a single raw GNSS measurement
2221
#[derive(Debug, Clone, PartialOrd, PartialEq)]
@@ -126,6 +125,15 @@ impl NavigationMeasurement {
126125
GnssSignal::from_gnss_signal_t(self.0.sid).unwrap()
127126
}
128127

128+
/// Sets the measurement flags
129+
pub fn set_flags(&mut self, flags: u16) {
130+
self.0.flags = flags;
131+
}
132+
133+
pub fn get_flags(&self) -> u16 {
134+
self.0.flags
135+
}
136+
129137
/// Checks to see if all of the measurement flags marked as valid
130138
pub fn flags_are_all_valid(&self) -> bool {
131139
unsafe { c_bindings::nav_meas_flags_valid(self.0.flags) }
@@ -143,38 +151,6 @@ impl Default for NavigationMeasurement {
143151
}
144152
}
145153

146-
#[cfg(feature = "sbp-conversions")]
147-
impl std::convert::TryFrom<sbp::messages::observation::PackedObsContent> for NavigationMeasurement {
148-
type Error = crate::signal::InvalidGnssSignal;
149-
150-
fn try_from(
151-
observation: sbp::messages::observation::PackedObsContent,
152-
) -> Result<NavigationMeasurement, crate::signal::InvalidGnssSignal> {
153-
use std::convert::TryInto;
154-
155-
let mut measurement = NavigationMeasurement::new();
156-
157-
measurement.set_lock_time(decode_lock_time(observation.lock));
158-
measurement.set_sid(observation.sid.try_into()?);
159-
// A CN0 of 0 is considered invalid
160-
if observation.cn0 != 0 {
161-
measurement.set_cn0(observation.cn0 as f64 / 4.);
162-
}
163-
if observation.flags & 0x01 != 0 {
164-
measurement.set_pseudorange(observation.P as f64 / 5e1);
165-
}
166-
if observation.flags & 0x08 != 0 {
167-
measurement
168-
.set_measured_doppler(observation.D.i as f64 + (observation.D.f as f64) / 256.);
169-
}
170-
if observation.flags & 0x80 != 0 {
171-
measurement.0.flags |= NAV_MEAS_FLAG_RAIM_EXCLUSION;
172-
}
173-
174-
Ok(measurement)
175-
}
176-
}
177-
178154
/// Encodes a [`Duration`] as an SBP lock time
179155
///
180156
/// Note: It is encoded according to DF402 from the RTCM 10403.2 Amendment 2

0 commit comments

Comments
 (0)