Skip to content

Commit

Permalink
Dev (#264)
Browse files Browse the repository at this point in the history
* update & fix warnings
* upgrade rtk

---------

Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres committed Aug 18, 2024
1 parent 64e92df commit 36e2a0d
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 91 deletions.
2 changes: 1 addition & 1 deletion rinex-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
2 changes: 1 addition & 1 deletion rinex-cli/src/positioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions rinex-cli/src/positioning/ppp/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
);
Expand All @@ -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,
);
Expand Down
30 changes: 15 additions & 15 deletions rinex/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -145,7 +145,7 @@ pub use split::Split;
#[macro_use]
extern crate serde;

#[cfg(docrs)]
#[cfg(docsrs)]
pub use bibliography::Bibliography;

/*
Expand Down Expand Up @@ -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<dyn Iterator<Item = Carrier> + '_> {
Expand Down Expand Up @@ -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
/// ```
Expand Down Expand Up @@ -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
/// ```
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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<String, BTreeMap<SV, BTreeMap<(Epoch, EpochFlag), f64>>> {
if let Some(r) = self.record.as_obs() {
Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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.
/// ```
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<dyn Iterator<Item = &Station> + '_> {
Expand Down
75 changes: 39 additions & 36 deletions rinex/src/navigation/ephemeris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<f64, 3> {
// Positive angles mean counterclockwise rotation
Expand All @@ -114,38 +114,44 @@ impl EphemerisHelper {
}

/// Calculate ecef position [km].
/// Applies to GPS, Galileo, BeiDou (MEO).
fn ecef_position(&self) -> Vector3<f64> {
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<f64> {
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::<f64, 3, 4>::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::<f64, 3, 4>::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
Expand Down Expand Up @@ -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,
Expand All @@ -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]
Expand Down Expand Up @@ -368,15 +374,12 @@ impl Ephemeris {
/// Return ToE expressed as [Epoch]
pub fn toe(&self, sv_ts: TimeScale) -> Option<Epoch> {
// 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)),
Expand Down Expand Up @@ -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<f64> {
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())
Expand Down
2 changes: 1 addition & 1 deletion rinex/src/navigation/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
8 changes: 4 additions & 4 deletions rinex/src/observation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions sp3/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -31,7 +31,7 @@ mod reader;
mod velocity;
mod version;

#[cfg(doc_cfg)]
#[cfg(docsrs)]
mod bibliography;

use header::{
Expand Down
4 changes: 3 additions & 1 deletion tutorials/BDS/esbjerg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
Loading

0 comments on commit 36e2a0d

Please sign in to comment.