From 0ea6812c1c185fdf6818b53eb96c7e2bacc06cd6 Mon Sep 17 00:00:00 2001 From: "Guillaume W. Bres" Date: Sun, 18 Aug 2024 17:47:58 +0200 Subject: [PATCH 1/2] update & fix warnings Signed-off-by: Guillaume W. Bres --- rinex-cli/src/positioning/mod.rs | 2 +- rinex-cli/src/positioning/ppp/report.rs | 6 +- rinex/src/lib.rs | 30 +++++----- rinex/src/navigation/ephemeris.rs | 75 +++++++++++++------------ rinex/src/navigation/record.rs | 2 +- rinex/src/observation/mod.rs | 8 +-- sp3/src/lib.rs | 4 +- tutorials/BDS/esbjerg.sh | 4 +- tutorials/BDS/nya100-brdc.sh | 27 --------- tutorials/CGGTTS/README.md | 5 ++ tutorials/CGGTTS/mojdnk-brdc.sh | 19 +++++++ 11 files changed, 92 insertions(+), 90 deletions(-) delete mode 100755 tutorials/BDS/nya100-brdc.sh create mode 100644 tutorials/CGGTTS/README.md create mode 100755 tutorials/CGGTTS/mojdnk-brdc.sh diff --git a/rinex-cli/src/positioning/mod.rs b/rinex-cli/src/positioning/mod.rs index a7564bd3..2d385eeb 100644 --- a/rinex-cli/src/positioning/mod.rs +++ b/rinex-cli/src/positioning/mod.rs @@ -40,7 +40,7 @@ use rinex_qc::prelude::QcExtraPage; use gnss_rtk::prelude::{ BdModel, Carrier as RTKCarrier, Config, Duration, Epoch, Error as RTKError, KbModel, Method, - NgModel, Orbit, PVTSolutionType, Solver, EARTH_J2000, + NgModel, Orbit, PVTSolutionType, Solver, }; use thiserror::Error; diff --git a/rinex-cli/src/positioning/ppp/report.rs b/rinex-cli/src/positioning/ppp/report.rs index 773e14b7..c0b37a7c 100644 --- a/rinex-cli/src/positioning/ppp/report.rs +++ b/rinex-cli/src/positioning/ppp/report.rs @@ -672,7 +672,7 @@ impl ReportContent { &epochs, solutions .values() - .map(|sol| sol.state.to_cartesian_pos_vel()[0] - x0_ecef) + .map(|sol| sol.state.to_cartesian_pos_vel()[0] * 1.0E3 - x0_ecef) .collect(), true, ); @@ -684,7 +684,7 @@ impl ReportContent { &epochs, solutions .values() - .map(|sol| sol.state.to_cartesian_pos_vel()[1] - y0_ecef) + .map(|sol| sol.state.to_cartesian_pos_vel()[1] * 1.0E3 - y0_ecef) .collect(), true, ); @@ -696,7 +696,7 @@ impl ReportContent { &epochs, solutions .values() - .map(|sol| sol.state.to_cartesian_pos_vel()[2] - z0_ecef) + .map(|sol| sol.state.to_cartesian_pos_vel()[2] * 1.0E3 - z0_ecef) .collect(), true, ); diff --git a/rinex/src/lib.rs b/rinex/src/lib.rs index 3e2d83bf..196520e5 100644 --- a/rinex/src/lib.rs +++ b/rinex/src/lib.rs @@ -1,6 +1,6 @@ #![doc(html_logo_url = "https://raw.githubusercontent.com/georust/meta/master/logo/logo.png")] #![doc = include_str!("../README.md")] -#![cfg_attr(docrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::type_complexity)] extern crate gnss_rs as gnss; @@ -145,7 +145,7 @@ pub use split::Split; #[macro_use] extern crate serde; -#[cfg(docrs)] +#[cfg(docsrs)] pub use bibliography::Bibliography; /* @@ -1751,7 +1751,7 @@ use crate::observation::{record::code_multipath, LliFlags, SNR}; * Either specific Iterators, or meaningful data we can extract. */ #[cfg(feature = "obs")] -#[cfg_attr(docrs, doc(cfg(feature = "obs")))] +#[cfg_attr(docsrs, doc(cfg(feature = "obs")))] impl Rinex { /// Returns a Unique Iterator over identified [`Carrier`]s pub fn carrier(&self) -> Box + '_> { @@ -2248,7 +2248,7 @@ use crate::navigation::{ * Either specific Iterators, or meaningful data we can extract. */ #[cfg(feature = "nav")] -#[cfg_attr(docrs, doc(cfg(feature = "nav")))] +#[cfg_attr(docsrs, doc(cfg(feature = "nav")))] impl Rinex { /// Returns a Unique Iterator over [`NavMsgType`]s that were identified /// ``` @@ -2629,7 +2629,7 @@ impl Rinex { * Either specific Iterators, or meaningful data we can extract. */ #[cfg(feature = "meteo")] -#[cfg_attr(docrs, doc(cfg(feature = "meteo")))] +#[cfg_attr(docsrs, doc(cfg(feature = "meteo")))] impl Rinex { /// Returns temperature data iterator, values expressed in Celcius degrees /// ``` @@ -2952,11 +2952,11 @@ impl Split for Rinex { } #[cfg(feature = "processing")] -#[cfg_attr(docrs, doc(cfg(feature = "processing")))] +#[cfg_attr(docsrs, doc(cfg(feature = "processing")))] impl Preprocessing for Rinex {} #[cfg(feature = "processing")] -#[cfg_attr(docrs, doc(cfg(feature = "processing")))] +#[cfg_attr(docsrs, doc(cfg(feature = "processing")))] impl RepairTrait for Rinex { fn repair(&self, r: Repair) -> Self { let mut s = self.clone(); @@ -2971,7 +2971,7 @@ impl RepairTrait for Rinex { } #[cfg(feature = "processing")] -#[cfg_attr(docrs, doc(cfg(feature = "processing")))] +#[cfg_attr(docsrs, doc(cfg(feature = "processing")))] impl Masking for Rinex { fn mask(&self, f: &MaskFilter) -> Self { let mut s = self.clone(); @@ -2997,7 +2997,7 @@ impl Masking for Rinex { } #[cfg(feature = "processing")] -#[cfg_attr(docrs, doc(cfg(feature = "processing")))] +#[cfg_attr(docsrs, doc(cfg(feature = "processing")))] impl Decimate for Rinex { fn decimate(&self, f: &DecimationFilter) -> Self { let mut s = self.clone(); @@ -3024,7 +3024,7 @@ impl Decimate for Rinex { use observation::Dcb; #[cfg(feature = "obs")] -#[cfg_attr(docrs, doc(cfg(feature = "obs")))] +#[cfg_attr(docsrs, doc(cfg(feature = "obs")))] impl Dcb for Rinex { fn dcb(&self) -> HashMap>> { if let Some(r) = self.record.as_obs() { @@ -3039,7 +3039,7 @@ impl Dcb for Rinex { use observation::{Combination, Combine}; #[cfg(feature = "obs")] -#[cfg_attr(docrs, doc(cfg(feature = "obs")))] +#[cfg_attr(docsrs, doc(cfg(feature = "obs")))] impl Combine for Rinex { fn combine( &self, @@ -3060,7 +3060,7 @@ use crate::clock::{ClockKey, ClockProfile, ClockProfileType}; * Clock RINEX specific feature */ #[cfg(feature = "clock")] -#[cfg_attr(docrs, doc(cfg(feature = "clock")))] +#[cfg_attr(docsrs, doc(cfg(feature = "clock")))] impl Rinex { /// Returns Iterator over Clock RINEX content. pub fn precise_clock( @@ -3108,7 +3108,7 @@ impl Rinex { * IONEX specific feature */ #[cfg(feature = "ionex")] -#[cfg_attr(docrs, doc(cfg(feature = "ionex")))] +#[cfg_attr(docsrs, doc(cfg(feature = "ionex")))] impl Rinex { /// Iterates over IONEX maps, per Epoch and altitude. /// ``` @@ -3234,7 +3234,7 @@ impl Rinex { * ANTEX specific feature */ #[cfg(feature = "antex")] -#[cfg_attr(docrs, doc(cfg(feature = "antex")))] +#[cfg_attr(docsrs, doc(cfg(feature = "antex")))] impl Rinex { /// Iterates over antenna specifications that are still valid pub fn antex_valid_calibrations( @@ -3315,7 +3315,7 @@ impl Rinex { * DORIS special features */ #[cfg(feature = "doris")] -#[cfg_attr(docrs, doc(cfg(feature = "doris")))] +#[cfg_attr(docsrs, doc(cfg(feature = "doris")))] impl Rinex { /// Returns Stations Iterator pub fn stations(&self) -> Box + '_> { diff --git a/rinex/src/navigation/ephemeris.rs b/rinex/src/navigation/ephemeris.rs index 99069ff6..08e9f45c 100644 --- a/rinex/src/navigation/ephemeris.rs +++ b/rinex/src/navigation/ephemeris.rs @@ -54,7 +54,7 @@ pub enum Error { /// GPS、BDS、Galieo /// - Helps calculate relativistic effects(todo) #[cfg(feature = "nav")] -#[cfg_attr(docrs, doc(cfg(feature = "nav")))] +#[cfg_attr(docsrs, doc(cfg(feature = "nav")))] #[derive(Debug, Clone, Copy)] struct EphemerisHelper { /// Satellite @@ -90,7 +90,7 @@ struct EphemerisHelper { } #[cfg(feature = "nav")] -#[cfg_attr(docrs, doc(cfg(feature = "nav")))] +#[cfg_attr(docsrs, doc(cfg(feature = "nav")))] impl EphemerisHelper { fn meo_orbit_to_ecef_rotation_matrix(&self) -> Rotation { // Positive angles mean counterclockwise rotation @@ -114,38 +114,44 @@ impl EphemerisHelper { } /// Calculate ecef position [km]. - /// Applies to GPS, Galileo, BeiDou (MEO). fn ecef_position(&self) -> Vector3 { - let (x, y, z) = self.r_sv; - let orbit_xyz = Vector3::new(x, y, z); - let ecef_xyz = self.meo_orbit_to_ecef_rotation_matrix() * orbit_xyz; - ecef_xyz / 1000.0 + if self.sv.is_beidou_geo() { + self.beidou_geo_ecef_position() + } else { + let (x, y, z) = self.r_sv; + let orbit_xyz = Vector3::new(x, y, z); + let ecef_xyz = self.meo_orbit_to_ecef_rotation_matrix() * orbit_xyz; + ecef_xyz / 1000.0 + } } /// Calculate ecef velocity [km/s]. - /// Applies to GPS, Galileo, BeiDou (MEO). fn ecef_velocity(&self) -> Vector3 { - let (x, y, _) = self.r_sv; - let (sin_omega_k, cos_omega_k) = self.omega_k.sin_cos(); - let (sin_i_k, cos_i_k) = self.i_k.sin_cos(); - // First Derivative of orbit position - let (fd_x, fd_y) = self.orbit_velocity(); - // First Derivative of rotation Matrix - let mut fd_r = na::SMatrix::::zeros(); - fd_r[(0, 0)] = cos_omega_k; - fd_r[(0, 1)] = -sin_omega_k * cos_i_k; - fd_r[(0, 2)] = -(x * sin_omega_k + y * cos_omega_k * cos_i_k); - fd_r[(0, 3)] = y * sin_omega_k * sin_i_k; - fd_r[(1, 0)] = sin_omega_k; - fd_r[(1, 1)] = cos_omega_k * cos_i_k; - fd_r[(1, 2)] = x * cos_omega_k - y * sin_omega_k * cos_i_k; - fd_r[(1, 3)] = y * cos_omega_k * sin_i_k; - fd_r[(2, 1)] = sin_i_k; - fd_r[(2, 3)] = y * cos_i_k; - - let rhs = Vector4::new(fd_x, fd_y, self.fd_omega_k, self.fd_i_k); - let vel = fd_r * rhs; - vel / 1000.0 + if self.sv.is_beidou_geo() { + self.beidou_geo_ecef_velocity() + } else { + let (x, y, _) = self.r_sv; + let (sin_omega_k, cos_omega_k) = self.omega_k.sin_cos(); + let (sin_i_k, cos_i_k) = self.i_k.sin_cos(); + // First Derivative of orbit position + let (fd_x, fd_y) = self.orbit_velocity(); + // First Derivative of rotation Matrix + let mut fd_r = na::SMatrix::::zeros(); + fd_r[(0, 0)] = cos_omega_k; + fd_r[(0, 1)] = -sin_omega_k * cos_i_k; + fd_r[(0, 2)] = -(x * sin_omega_k + y * cos_omega_k * cos_i_k); + fd_r[(0, 3)] = y * sin_omega_k * sin_i_k; + fd_r[(1, 0)] = sin_omega_k; + fd_r[(1, 1)] = cos_omega_k * cos_i_k; + fd_r[(1, 2)] = x * cos_omega_k - y * sin_omega_k * cos_i_k; + fd_r[(1, 3)] = y * cos_omega_k * sin_i_k; + fd_r[(2, 1)] = sin_i_k; + fd_r[(2, 3)] = y * cos_i_k; + + let rhs = Vector4::new(fd_x, fd_y, self.fd_omega_k, self.fd_i_k); + let vel = fd_r * rhs; + vel / 1000.0 + } } /// Calculate ECEF position [km] and velocity [km/s] of MEO/IGSO sv @@ -283,7 +289,7 @@ pub struct Ephemeris { #[cfg(feature = "nav")] #[derive(Default, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(docrs, doc(cfg(feature = "nav")))] +#[cfg_attr(docsrs, doc(cfg(feature = "nav")))] pub struct Kepler { /// semi major axis (m) pub a: f64, @@ -306,7 +312,7 @@ pub struct Kepler { /// Orbit Perturbations #[cfg(feature = "nav")] #[derive(Default, Clone, Debug)] -#[cfg_attr(docrs, doc(cfg(feature = "nav")))] +#[cfg_attr(docsrs, doc(cfg(feature = "nav")))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Perturbations { /// Mean motion difference from computed value [semicircles.s-1] @@ -368,15 +374,12 @@ impl Ephemeris { /// Return ToE expressed as [Epoch] pub fn toe(&self, sv_ts: TimeScale) -> Option { // TODO: in CNAV V4 TOC is said to be TOE... ... - let mut week = self.get_week()?; + let week = self.get_week()?; let sec = self.get_orbit_f64("toe")?; let week_dur = Duration::from_days((week * 7) as f64); let sec_dur = Duration::from_seconds(sec); match sv_ts { TimeScale::GPST | TimeScale::QZSST | TimeScale::GST => { - if sv_ts == TimeScale::GST { - week -= 1024; - } Some(Epoch::from_duration(week_dur + sec_dur, TimeScale::GPST)) }, TimeScale::BDT => Some(Epoch::from_bdt_duration(week_dur + sec_dur)), @@ -577,7 +580,7 @@ impl Ephemeris { /// Total seconds elapsed between `t` and ToE, expressed in appropriate timescale. /// NB: this does not apply to GEO Ephemerides but only MEO. fn t_k(&self, sv: SV, t: Epoch) -> Option { - let mut sv_ts = sv.timescale()?; + let sv_ts = sv.timescale()?; let toe = self.toe(sv_ts)?; let dt = t.to_time_scale(sv_ts) - toe; Some(dt.to_seconds()) diff --git a/rinex/src/navigation/record.rs b/rinex/src/navigation/record.rs index 298d56f8..c983ff0a 100644 --- a/rinex/src/navigation/record.rs +++ b/rinex/src/navigation/record.rs @@ -4,7 +4,7 @@ use regex::{Captures, Regex}; use std::collections::BTreeMap; use std::str::FromStr; -#[cfg(docrs)] +#[cfg(docsrs)] use crate::Bibliography; #[cfg(feature = "processing")] diff --git a/rinex/src/observation/mod.rs b/rinex/src/observation/mod.rs index 37cfd62d..45a54d0c 100644 --- a/rinex/src/observation/mod.rs +++ b/rinex/src/observation/mod.rs @@ -10,7 +10,7 @@ pub use flag::EpochFlag; mod snr; pub use snr::SNR; -#[cfg(docrs)] +#[cfg(docsrs)] use crate::Bibliography; pub use record::{LliFlags, ObservationData, Record}; @@ -308,7 +308,7 @@ impl HeaderFields { use std::collections::BTreeMap; #[cfg(feature = "obs")] -#[cfg_attr(docrs, doc(cfg(feature = "obs")))] +#[cfg_attr(docsrs, doc(cfg(feature = "obs")))] #[derive(Debug, Copy, Clone)] pub enum Combination { GeometryFree, @@ -323,7 +323,7 @@ pub enum Combination { /// Refer to [Bibliography::ESAGnssCombination] and [Bibliography::ESABookVol1] /// for more information. #[cfg(feature = "obs")] -#[cfg_attr(docrs, doc(cfg(feature = "obs")))] +#[cfg_attr(docsrs, doc(cfg(feature = "obs")))] pub trait Combine { fn combine( &self, @@ -334,7 +334,7 @@ pub trait Combine { /// GNSS code bias estimation trait. /// Refer to [Bibliography::ESAGnssCombination] and [Bibliography::ESABookVol1]. #[cfg(feature = "obs")] -#[cfg_attr(docrs, doc(cfg(feature = "obs")))] +#[cfg_attr(docsrs, doc(cfg(feature = "obs")))] pub trait Dcb { /// Returns Differential Code Bias estimates, sorted per (unique) /// signals combinations and for each individual SV. diff --git a/sp3/src/lib.rs b/sp3/src/lib.rs index eacb210a..f5d2eb00 100644 --- a/sp3/src/lib.rs +++ b/sp3/src/lib.rs @@ -1,5 +1,5 @@ //! SP3 precise orbit file parser. -#![cfg_attr(docrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] extern crate gnss_rs as gnss; use itertools::Itertools; @@ -31,7 +31,7 @@ mod reader; mod velocity; mod version; -#[cfg(doc_cfg)] +#[cfg(docsrs)] mod bibliography; use header::{ diff --git a/tutorials/BDS/esbjerg.sh b/tutorials/BDS/esbjerg.sh index d66258ab..b1b71d8d 100755 --- a/tutorials/BDS/esbjerg.sh +++ b/tutorials/BDS/esbjerg.sh @@ -18,7 +18,8 @@ CONF=tutorials/config/survey/cpp_lsq.json # -f: force new synthesis # -P: filter example ./target/release/rinex-cli \ - -P $FILTER -f -q \ + -f -q -o "BDS-B2i-B3" \ + -P $FILTER \ --fp $DATA_DIR/CRNX/V3/ESBC00DNK_R_20201770000_01D_30S_MO.crx.gz \ --fp $DATA_DIR/NAV/V3/ESBC00DNK_R_20201770000_01D_MN.rnx.gz \ --fp $DATA_DIR/SP3/Sta21114.sp3.gz \ @@ -28,6 +29,7 @@ CONF=tutorials/config/survey/cpp_lsq.json # Since we're using strict identical options, # the report is preserved and new solutions are appended. ./target/release/rinex-cli \ + -f -q -o "BDS-B2i-B3" \ -P $FILTER \ --fp $DATA_DIR/CRNX/V3/ESBC00DNK_R_20201770000_01D_30S_MO.crx.gz \ --fp $DATA_DIR/NAV/V3/ESBC00DNK_R_20201770000_01D_MN.rnx.gz \ diff --git a/tutorials/BDS/nya100-brdc.sh b/tutorials/BDS/nya100-brdc.sh deleted file mode 100755 index 4256301c..00000000 --- a/tutorials/BDS/nya100-brdc.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Real time surveying (BRDC) -DATA_DIR=test_resources - -# Comment out one step to remove it from the synthesized report. -# Change the configuration to modify the navigation setup. -DATA_DIR=test_resources - -FILTER="BDS" -CONF=tutorials/config/survey/spp_lsq.json - -# Analysis + ppp solutions (silent) -./target/release/rinex-cli \ - --fp $DATA_DIR/CRNX/V3/NYA100NOR_S_20241240000_01D_30S_MO.crx.gz \ - --fp $DATA_DIR/NAV/V3/NYA100NOR_S_20241240000_01D_CN.rnx.gz - - exit 0 - -# cggtts solutions (+open). -# Since we're using strict identical options, -# the report is preserved and new solutions are appended. -# The report is automatically opened. -./target/release/rinex-cli \ - -P $FILTER \ - --fp $DATA_DIR/CRNX/V3/NYA100NOR_S_20241240000_01D_30S_MO.crx.gz \ - --fp $DATA_DIR/NAV/V3/NYA100NOR_S_20241240000_01D_GN.rnx.gz \ - ppp --cggtts -c $CONF diff --git a/tutorials/CGGTTS/README.md b/tutorials/CGGTTS/README.md new file mode 100644 index 00000000..a6c65077 --- /dev/null +++ b/tutorials/CGGTTS/README.md @@ -0,0 +1,5 @@ +CGGTTS +====== + +All our examples survey usually attach CGGTTS solutions as well, +but this folder is 100% dedicated to such opmode. diff --git a/tutorials/CGGTTS/mojdnk-brdc.sh b/tutorials/CGGTTS/mojdnk-brdc.sh new file mode 100755 index 00000000..38b1d07f --- /dev/null +++ b/tutorials/CGGTTS/mojdnk-brdc.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Real time surveying (BRDC) +# Compare this to post processed +3weeks +DATA_DIR=test_resources + +# Example: +# E1 or E5 PR +FILTER="Gal;C1C,C5Q" +CONF=tutorials/config/survey/cpp_kf.json + +# Analysis + ppp solutions +# -f: force new report synthesis +#  -o: custom name +./target/release/rinex-cli \ + -P $FILTER \ + -f -q -o "BRDC-GalE1E5" \ + --fp $DATA_DIR/CRNX/V3/MOJN00DNK_R_20201770000_01D_30S_MO.crx.gz \ + --fp $DATA_DIR/NAV/V3/MOJN00DNK_R_20201770000_01D_MN.rnx.gz \ + ppp --cggtts -c $CONF From 1ae0f2b853b57833d3c92008a669acb35bf5c00d Mon Sep 17 00:00:00 2001 From: "Guillaume W. Bres" Date: Sun, 18 Aug 2024 17:50:50 +0200 Subject: [PATCH 2/2] upgrade rtk Signed-off-by: Guillaume W. Bres --- rinex-cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rinex-cli/Cargo.toml b/rinex-cli/Cargo.toml index b7a00f50..dbd2a85c 100644 --- a/rinex-cli/Cargo.toml +++ b/rinex-cli/Cargo.toml @@ -45,7 +45,7 @@ hifitime = { version = "4.0.0-alpha", features = ["serde", "std"] } gnss-rs = { version = "2.2.1", features = ["serde"] } -gnss-rtk = { version = "0.7.0", features = ["serde"] } +gnss-rtk = { version = "0.7.1", features = ["serde"] } # gnss-rtk = { path = "../../rtk-rs/gnss-rtk", features = ["serde"] } # gnss-rtk = { git = "https://github.com/rtk-rs/gnss-rtk", branch = "main", features = ["serde"] }