Skip to content

Commit 04136fd

Browse files
committed
spelling, linting, and general cleanup
1 parent 3fa1958 commit 04136fd

4 files changed

Lines changed: 113 additions & 114 deletions

File tree

core/src/messages.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::sim::TestDataRecord;
2727
///
2828
/// ## Usage
2929
/// - `PassThrough` → GNSS data is delivered at its native logging rate.
30-
/// - `FixedInterval` → Downsample the GNSS stream to a constant interval,
30+
/// - `FixedInterval` → Down-sample the GNSS stream to a constant interval,
3131
/// simulating jamming that allows only low-rate fixes.
3232
/// - `DutyCycle` → Alternate between ON and OFF windows of fixed length,
3333
/// simulating periodic outages.
@@ -49,13 +49,14 @@ use crate::sim::TestDataRecord;
4949
/// // Alternate 5 s ON, 15 s OFF, starting in ON state at t=0
5050
/// let sched = GnssScheduler::DutyCycle { on_s: 5.0, off_s: 15.0, start_phase_s: 0.0 };
5151
/// ```
52-
#[derive(Clone, Debug, Serialize, Deserialize)]
52+
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
5353
#[serde(tag = "kind", rename_all = "snake_case")]
5454
pub enum GnssScheduler {
5555
/// Pass every GNSS fix through to the filter with no rate reduction.
5656
///
5757
/// Useful as a baseline when you want to test only fault injection without
5858
/// simulating outages or reduced update rates.
59+
#[default]
5960
PassThrough,
6061
/// Emit GNSS measurements at a fixed interval, discarding those in between.
6162
///
@@ -160,7 +161,7 @@ mod serialization_tests {
160161
///
161162
/// - `None`: deliver the fix unchanged.
162163
/// - `Degraded`: add AR(1)-correlated noise to position and velocity, and
163-
/// inflate the advertised covariance. Simulates low-SNR or multipath conditions.
164+
/// inflate the advertised covariance. Simulates low-SNR or multi-path conditions.
164165
/// - `SlowBias`: apply a slowly drifting offset in N/E position and velocity.
165166
/// Simulates soft spoofing where the trajectory is nudged gradually away
166167
/// from truth.
@@ -216,7 +217,7 @@ pub enum GnssFaultModel {
216217
None,
217218

218219
/// (2) Degraded accuracy: AR(1)-correlated noise on position and velocity,
219-
/// plus inflated advertised covariance. Models low-SNR or multipath cases.
220+
/// plus inflated advertised covariance. Models low-SNR or multi-path cases.
220221
Degraded {
221222
/// AR(1) correlation coefficient for position error (close to 1.0).
222223
rho_pos: f64,
@@ -840,7 +841,20 @@ fn apply_fault(
840841
vel_std_mps,
841842
);
842843
for m in models {
843-
// out = apply_fault(m, st, t, dt, out.0, out.1, out.2, out.3, out.4, out.5, out.6);
844+
out = apply_fault(
845+
m,
846+
st,
847+
t,
848+
dt,
849+
out.0,
850+
out.1,
851+
out.2,
852+
out.3,
853+
out.4,
854+
out.5,
855+
vert_std_m,
856+
out.6,
857+
);
844858
}
845859
out
846860
}
@@ -872,7 +886,7 @@ fn apply_fault(
872886
///
873887
/// # Returns
874888
/// A `EventStream` containing an interleaved sequence of IMU and (optionally
875-
/// downsampled/corrupted) GNSS events, ordered by `elapsed_s`.
889+
/// down-sampled/corrupted) GNSS events, ordered by `elapsed_s`.
876890
///
877891
/// # Scheduling semantics
878892
/// - [`GnssScheduler::PassThrough`]: emit a GNSS event at every record step.
@@ -933,15 +947,15 @@ pub fn build_event_stream(records: &[TestDataRecord], cfg: &GnssDegradationConfi
933947
let mut next_emit_time = match cfg.scheduler {
934948
GnssScheduler::PassThrough => 0.0,
935949
GnssScheduler::FixedInterval {
936-
interval_s,
937950
phase_s,
951+
..
938952
} => phase_s,
939953
GnssScheduler::DutyCycle { start_phase_s, .. } => start_phase_s,
940954
};
941955
let mut duty_on = true;
942956

943957
for w in records_with_elapsed.windows(2) {
944-
let (t0, r0) = (&w[0].0, &w[0].1);
958+
let (t0, _) = (&w[0].0, &w[0].1);
945959
let (t1, r1) = (&w[1].0, &w[1].1);
946960
let dt = t1 - t0;
947961

core/src/sim.rs

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,13 @@ use std::io::{self};
1919
use std::path::Path;
2020

2121
use anyhow::{Result, bail};
22-
use chrono::{DateTime, Datelike, Duration, Utc};
22+
use chrono::{DateTime, Duration, Utc};
2323
use nalgebra::{DMatrix, DVector, Vector3};
2424
use serde::{Deserialize, Serialize};
25-
use world_magnetic_model::GeomagneticField;
26-
use world_magnetic_model::time::{Date, Month};
27-
use world_magnetic_model::uom::si::angle::radian;
28-
use world_magnetic_model::uom::si::f32::{Angle, Length};
29-
use world_magnetic_model::uom::si::length::meter;
3025

3126
use crate::earth::METERS_TO_DEGREES;
3227
use crate::filter::{
33-
GPSPositionAndVelocityMeasurement, RelativeAltitudeMeasurement, StrapdownParams, UKF,
28+
StrapdownParams, UKF,
3429
};
3530
use crate::messages::{Event, EventStream};
3631
use crate::{IMUData, StrapdownState, forward};
@@ -409,18 +404,18 @@ impl From<(&DateTime<Utc>, &DVector<f64>, &DMatrix<f64>)> for NavigationResult {
409404
"Covariance matrix must be 15x15"
410405
);
411406
let covariance = DVector::from_vec(covariance.diagonal().iter().map(|&x| x).collect());
412-
let wmm_date: Date = Date::from_calendar_date(
413-
timestamp.year(),
414-
Month::try_from(timestamp.month() as u8).unwrap(),
415-
timestamp.day() as u8,
416-
)
417-
.expect("Invalid date for world magnetic model");
418-
let magnetic_field = GeomagneticField::new(
419-
Length::new::<meter>(state[2] as f32),
420-
Angle::new::<radian>(state[0] as f32),
421-
Angle::new::<radian>(state[1] as f32),
422-
wmm_date,
423-
);
407+
// let wmm_date: Date = Date::from_calendar_date(
408+
// timestamp.year(),
409+
// Month::try_from(timestamp.month() as u8).unwrap(),
410+
// timestamp.day() as u8,
411+
// )
412+
// .expect("Invalid date for world magnetic model");
413+
// let magnetic_field = GeomagneticField::new(
414+
// Length::new::<meter>(state[2] as f32),
415+
// Angle::new::<radian>(state[0] as f32),
416+
// Angle::new::<radian>(state[1] as f32),
417+
// wmm_date,
418+
// );
424419
NavigationResult {
425420
timestamp: *timestamp,
426421
latitude: state[0].to_degrees(),
@@ -517,41 +512,33 @@ impl From<(&DateTime<Utc>, &UKF)> for NavigationResult {
517512
/// # Arguments
518513
/// - `timestamp`: The timestamp of the navigation solution.
519514
/// - `state`: A reference to the StrapdownState instance containing the navigation state.
520-
/// - `imu_data`: An IMUData struct containing the IMU measurements.
521-
/// - `magnetic_vector`: Magnetic field strength measurement in micro teslas (body frame x, y, z).
522-
/// - `pressure`: Pressure in millibars.
515+
///
523516
/// # Returns
524517
/// A NavigationResult struct containing the navigation solution.
525518
impl
526519
From<(
527520
&DateTime<Utc>,
528521
&StrapdownState,
529-
&IMUData,
530-
&Vector3<f64>,
531-
&f64,
532522
)> for NavigationResult
533523
{
534524
fn from(
535-
(timestamp, state, imu_data, magnetic_vector, pressure): (
525+
(timestamp, state): (
536526
&DateTime<Utc>,
537-
&StrapdownState,
538-
&IMUData,
539-
&Vector3<f64>,
540-
&f64,
527+
&StrapdownState
541528
),
542529
) -> Self {
543-
let wmm_date: Date = Date::from_calendar_date(
544-
timestamp.year(),
545-
Month::try_from(timestamp.month() as u8).unwrap(),
546-
timestamp.day() as u8,
547-
)
548-
.expect("Invalid date for world magnetic model");
549-
let magnetic_field = GeomagneticField::new(
550-
Length::new::<meter>(state.altitude as f32),
551-
Angle::new::<radian>(state.latitude as f32),
552-
Angle::new::<radian>(state.longitude as f32),
553-
wmm_date,
554-
);
530+
//let wmm_date: Date = Date::from_calendar_date(
531+
// timestamp.year(),
532+
// Month::try_from(timestamp.month() as u8).unwrap(),
533+
// timestamp.day() as u8,
534+
//)
535+
//.expect("Invalid date for world magnetic model");
536+
//let magnetic_field = GeomagneticField::new(
537+
// Length::new::<meter>(state.altitude as f32),
538+
// Angle::new::<radian>(state.latitude as f32),
539+
// Angle::new::<radian>(state.longitude as f32),
540+
// wmm_date,
541+
//);
555542
NavigationResult {
556543
timestamp: timestamp.clone(),
557544
latitude: state.latitude.to_degrees(),

geonav/src/lib.rs

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use std::path::PathBuf;
1010

1111
use nalgebra;
1212
use nalgebra::{DMatrix, DVector, Vector3};
13-
use rand::Rng;
14-
use statrs::distribution::{Continuous, Normal};
1513
use strapdown::IMUData;
1614
use strapdown::earth::METERS_TO_DEGREES;
1715
use strapdown::filter::{
@@ -40,28 +38,28 @@ pub enum ReliefResolution {
4038
ThreeSeconds,
4139
OneSecond,
4240
}
43-
impl ReliefResolution {
44-
/// Convert the resolution to a string. This can be used for calling the GMT library
45-
fn as_str(&self) -> &'static str {
46-
match self {
47-
ReliefResolution::OneDegree => "01d",
48-
ReliefResolution::ThirtyMinutes => "30m",
49-
ReliefResolution::TwentyMinutes => "20m",
50-
ReliefResolution::FifteenMinutes => "15m",
51-
ReliefResolution::TenMinutes => "10m",
52-
ReliefResolution::SixMinutes => "06m",
53-
ReliefResolution::FiveMinutes => "05m",
54-
ReliefResolution::FourMinutes => "04m",
55-
ReliefResolution::ThreeMinutes => "03m",
56-
ReliefResolution::TwoMinutes => "02m",
57-
ReliefResolution::OneMinute => "01m",
58-
ReliefResolution::ThirtySeconds => "30s",
59-
ReliefResolution::FifteenSeconds => "15s",
60-
ReliefResolution::ThreeSeconds => "03s",
61-
ReliefResolution::OneSecond => "01s",
62-
}
63-
}
64-
}
41+
// impl ReliefResolution {
42+
// /// Convert the resolution to a string. This can be used for calling the GMT library
43+
// fn as_str(&self) -> &'static str {
44+
// match self {
45+
// ReliefResolution::OneDegree => "01d",
46+
// ReliefResolution::ThirtyMinutes => "30m",
47+
// ReliefResolution::TwentyMinutes => "20m",
48+
// ReliefResolution::FifteenMinutes => "15m",
49+
// ReliefResolution::TenMinutes => "10m",
50+
// ReliefResolution::SixMinutes => "06m",
51+
// ReliefResolution::FiveMinutes => "05m",
52+
// ReliefResolution::FourMinutes => "04m",
53+
// ReliefResolution::ThreeMinutes => "03m",
54+
// ReliefResolution::TwoMinutes => "02m",
55+
// ReliefResolution::OneMinute => "01m",
56+
// ReliefResolution::ThirtySeconds => "30s",
57+
// ReliefResolution::FifteenSeconds => "15s",
58+
// ReliefResolution::ThreeSeconds => "03s",
59+
// ReliefResolution::OneSecond => "01s",
60+
// }
61+
// }
62+
// }
6563
/// Resolution values for gravity maps
6664
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6765
pub enum GravityResolution {
@@ -77,24 +75,24 @@ pub enum GravityResolution {
7775
TwoMinutes,
7876
OneMinute,
7977
}
80-
impl GravityResolution {
81-
/// Convert the resolution to a string. This can be used for calling the GMT library
82-
fn as_str(&self) -> &'static str {
83-
match self {
84-
GravityResolution::OneDegree => "01d",
85-
GravityResolution::ThirtyMinutes => "30m",
86-
GravityResolution::TwentyMinutes => "20m",
87-
GravityResolution::FifteenMinutes => "15m",
88-
GravityResolution::TenMinutes => "10m",
89-
GravityResolution::SixMinutes => "06m",
90-
GravityResolution::FiveMinutes => "05m",
91-
GravityResolution::FourMinutes => "04m",
92-
GravityResolution::ThreeMinutes => "03m",
93-
GravityResolution::TwoMinutes => "02m",
94-
GravityResolution::OneMinute => "01m",
95-
}
96-
}
97-
}
78+
// impl GravityResolution {
79+
// /// Convert the resolution to a string. This can be used for calling the GMT library
80+
// fn as_str(&self) -> &'static str {
81+
// match self {
82+
// GravityResolution::OneDegree => "01d",
83+
// GravityResolution::ThirtyMinutes => "30m",
84+
// GravityResolution::TwentyMinutes => "20m",
85+
// GravityResolution::FifteenMinutes => "15m",
86+
// GravityResolution::TenMinutes => "10m",
87+
// GravityResolution::SixMinutes => "06m",
88+
// GravityResolution::FiveMinutes => "05m",
89+
// GravityResolution::FourMinutes => "04m",
90+
// GravityResolution::ThreeMinutes => "03m",
91+
// GravityResolution::TwoMinutes => "02m",
92+
// GravityResolution::OneMinute => "01m",
93+
// }
94+
// }
95+
// }
9896
/// Resolution values for magnetic maps
9997
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10098
pub enum MagneticResolution {
@@ -109,23 +107,23 @@ pub enum MagneticResolution {
109107
ThreeMinutes,
110108
TwoMinutes,
111109
}
112-
impl MagneticResolution {
113-
/// Convert the resolution to a string. This can be used for calling the GMT library
114-
fn as_str(&self) -> &'static str {
115-
match self {
116-
MagneticResolution::OneDegree => "01d",
117-
MagneticResolution::ThirtyMinutes => "30m",
118-
MagneticResolution::TwentyMinutes => "20m",
119-
MagneticResolution::FifteenMinutes => "15m",
120-
MagneticResolution::TenMinutes => "10m",
121-
MagneticResolution::SixMinutes => "06m",
122-
MagneticResolution::FiveMinutes => "05m",
123-
MagneticResolution::FourMinutes => "04m",
124-
MagneticResolution::ThreeMinutes => "03m",
125-
MagneticResolution::TwoMinutes => "02m",
126-
}
127-
}
128-
}
110+
// impl MagneticResolution {
111+
// /// Convert the resolution to a string. This can be used for calling the GMT library
112+
// fn as_str(&self) -> &'static str {
113+
// match self {
114+
// MagneticResolution::OneDegree => "01d",
115+
// MagneticResolution::ThirtyMinutes => "30m",
116+
// MagneticResolution::TwentyMinutes => "20m",
117+
// MagneticResolution::FifteenMinutes => "15m",
118+
// MagneticResolution::TenMinutes => "10m",
119+
// MagneticResolution::SixMinutes => "06m",
120+
// MagneticResolution::FiveMinutes => "05m",
121+
// MagneticResolution::FourMinutes => "04m",
122+
// MagneticResolution::ThreeMinutes => "03m",
123+
// MagneticResolution::TwoMinutes => "02m",
124+
// }
125+
// }
126+
// }
129127
/// Enum for the different types of maps. A GeoMap is defined by its measurement type and resolution.
130128
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
131129
pub enum GeophysicalMeasurementType {
@@ -369,7 +367,7 @@ impl GeoMap {
369367
let w22: f64 = ((lon - lon1) * (lat - lat1)) / ((lon2 - lon1) * (lat2 - lat1));
370368
Some(w11 * q11 + w12 * q12 + w21 * q21 + w22 * q22)
371369
}
372-
// TODO: #95 Implement direct GMT interface using syscalls
370+
// TODO: #95 Implement direct GMT interface using system shell calls
373371
}
374372
//================= Map Information ========================================================================
375373

@@ -387,7 +385,7 @@ pub struct GeophysicalMeasurement<'a> {
387385
///
388386
/// The geophysical feedback model is different from traditional measurement models in that it needs to relate
389387
/// a scalar (or vector) measurement to the position states. We can somewhat do this via a map, but the scalar
390-
/// values on the map are not neccessarily unique. This means that we cannot directly use the measurement to
388+
/// values on the map are not necessarily unique. This means that we cannot directly use the measurement to
391389
/// provide feedback and instead must use it to weight sigma points that do contain position information.
392390
///
393391
/// Working hypothesis: we can treat the UKF as a hybrid KF/PF where the sigma point / particles can be weighted
@@ -642,7 +640,7 @@ pub fn run_geophysical_navigation(
642640
+ record.grav_z.powf(2.0))
643641
.sqrt()
644642
- state[15];
645-
let geo_measurement = GeophysicalMeasurement {
643+
let _geo_measurement = GeophysicalMeasurement {
646644
map: &geo_map,
647645
noise_std: measurement_standard_deviation,
648646
measurement: freeair,
@@ -656,7 +654,7 @@ pub fn run_geophysical_navigation(
656654
(record.mag_x.powf(2.0) + record.mag_y.powf(2.0) + record.mag_z.powf(2.0))
657655
.sqrt()
658656
- state[15];
659-
let geo_measurement = GeophysicalMeasurement {
657+
let _geo_measurement = GeophysicalMeasurement {
660658
map: &geo_map,
661659
noise_std: measurement_standard_deviation,
662660
measurement: mag_anom,

sim/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use strapdown::messages::{
66
GnssDegradationConfig, GnssFaultModel, GnssScheduler, build_event_stream,
77
};
88
use strapdown::sim::{
9-
NavigationResult, TestDataRecord, closed_loop, dead_reckoning, initialize_ukf,
9+
NavigationResult, TestDataRecord, closed_loop, initialize_ukf,
1010
};
1111

1212
const LONG_ABOUT: &str = "STRAPDOWN: A simulation and analysis tool for strapdown inertial navigation systems.

0 commit comments

Comments
 (0)