Skip to content

Commit b876f05

Browse files
committed
Add geophysical measurement configuration parameters to strapdown-sim config command
Fixes #214
1 parent e6d0e0f commit b876f05

7 files changed

Lines changed: 730 additions & 0 deletions

File tree

GEOPHYSICAL_CONFIG_CHANGES.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Summary: Geophysical Measurement Configuration for strapdown-sim
2+
3+
## Changes Made
4+
5+
This update adds interactive configuration support for geophysical measurements (gravity and magnetic anomaly) to the `strapdown-sim config` command.
6+
7+
### 1. Core Library Changes (`core/src/sim.rs`)
8+
9+
#### Added `geophysical` field to `SimulationConfig`
10+
- New optional field: `pub geophysical: Option<GeophysicalConfig>`
11+
- Updated `Default` implementation to include `geophysical: None`
12+
- This allows the main simulation configuration to include geophysical parameters
13+
14+
### 2. CLI Changes (`sim/src/main.rs`)
15+
16+
#### New Prompt Functions
17+
Added five new interactive prompt functions:
18+
19+
1. **`prompt_enable_geophysical()`** - Asks if user wants to enable geophysical navigation
20+
2. **`prompt_geo_resolution(measurement_type: &str)`** - Prompts for map resolution (15 options from 1° to 1")
21+
3. **`prompt_gravity_config()`** - Configures gravity anomaly measurements:
22+
- Map resolution
23+
- Measurement bias (mGal)
24+
- Noise standard deviation (mGal, default: 100.0)
25+
- Map file path (optional, auto-detect if empty)
26+
4. **`prompt_magnetic_config()`** - Configures magnetic anomaly measurements:
27+
- Map resolution
28+
- Measurement bias (nT)
29+
- Noise standard deviation (nT, default: 150.0)
30+
- Map file path (optional, auto-detect if empty)
31+
5. **`prompt_geo_measurement_frequency()`** - Sets measurement frequency in seconds
32+
33+
#### Updated `create_config_file()` Function
34+
- Added "Geophysical Navigation Configuration" section
35+
- Calls new prompt functions after GNSS degradation config
36+
- Validates that at least one measurement type is enabled
37+
- Builds and includes `GeophysicalConfig` in final `SimulationConfig`
38+
39+
### 3. Documentation
40+
41+
#### New Documentation File (`docs/GEOPHYSICAL_CONFIG.md`)
42+
Comprehensive guide covering:
43+
- Overview of geophysical configuration
44+
- Step-by-step wizard usage
45+
- Configuration file format
46+
- Available resolution options
47+
- Default values
48+
- Example usage
49+
- Notes and requirements
50+
51+
### 4. Example Configuration (`examples/configs/geonav_example.toml`)
52+
Complete example configuration demonstrating:
53+
- Gravity anomaly measurements setup
54+
- Magnetic anomaly measurements setup
55+
- Integration with closed-loop simulation
56+
- TOML format with comments
57+
58+
### 5. Test Script (`test_geo_config_wizard.sh`)
59+
Automated test script to verify the wizard functionality with simulated user input.
60+
61+
## Features
62+
63+
### User-Friendly Configuration
64+
- Interactive prompts with clear options
65+
- Default values for common parameters
66+
- Input validation with helpful error messages
67+
- Option to quit at any point with 'q'
68+
69+
### Flexible Measurement Configuration
70+
- Enable/disable gravity measurements independently
71+
- Enable/disable magnetic measurements independently
72+
- Must enable at least one type if geophysical navigation is activated
73+
- Auto-detection of map files if not specified
74+
75+
### Resolution Options
76+
15 resolution levels available for both gravity and magnetic maps:
77+
- From coarse (1 degree) to fine (1 arcsecond)
78+
- Default: One Minute (good balance of accuracy and file size)
79+
80+
### Integration with Existing Workflow
81+
- Seamlessly integrated into existing config wizard
82+
- Follows same patterns as other configuration sections
83+
- Compatible with all simulation modes
84+
- Works with existing TOML/JSON/YAML config formats
85+
86+
## Usage Example
87+
88+
```bash
89+
# Run the configuration wizard
90+
strapdown-sim config
91+
92+
# When prompted:
93+
# 1. Enable geophysical navigation: y
94+
# 2. Enable gravity measurements: y
95+
# - Select resolution: 11 (OneMinute)
96+
# - Set bias: 0.0
97+
# - Set noise std: 100.0
98+
# - Map file: (press Enter for auto-detect)
99+
# 3. Enable magnetic measurements: y
100+
# - Select resolution: 11 (OneMinute)
101+
# - Set bias: 0.0
102+
# - Set noise std: 150.0
103+
# - Map file: (press Enter for auto-detect)
104+
# 4. Set measurement frequency: 1.0 (seconds)
105+
106+
# Use the generated config
107+
strapdown-sim --config your_config.toml
108+
```
109+
110+
## Configuration File Example
111+
112+
```toml
113+
[geophysical]
114+
gravity_resolution = "OneMinute"
115+
gravity_bias = 0.0
116+
gravity_noise_std = 100.0
117+
magnetic_resolution = "OneMinute"
118+
magnetic_bias = 0.0
119+
magnetic_noise_std = 150.0
120+
geo_frequency_s = 1.0
121+
```
122+
123+
## Benefits
124+
125+
1. **Easier Setup**: No need to manually edit configuration files for geophysical measurements
126+
2. **Reduced Errors**: Input validation prevents common configuration mistakes
127+
3. **Better UX**: Interactive wizard guides users through all options
128+
4. **Documentation**: Clear prompts explain each parameter
129+
5. **Flexibility**: Users can enable only the measurements they need
130+
131+
## Testing
132+
133+
- ✅ Code compiles without errors
134+
- ✅ No clippy warnings in modified files
135+
- ✅ All existing tests pass
136+
- ✅ Markdown documentation passes linting
137+
- ✅ Integration with existing config wizard verified
138+
139+
## Files Modified
140+
141+
1. `/home/james/Code/strapdown-rs/core/src/sim.rs`
142+
2. `/home/james/Code/strapdown-rs/sim/src/main.rs`
143+
144+
## Files Added
145+
146+
1. `/home/james/Code/strapdown-rs/docs/GEOPHYSICAL_CONFIG.md`
147+
2. `/home/james/Code/strapdown-rs/examples/configs/geonav_example.toml`
148+
3. `/home/james/Code/strapdown-rs/test_geo_config_wizard.sh`
149+
150+
## Next Steps
151+
152+
Users can now:
153+
1. Run `strapdown-sim config` to create configurations with geophysical measurements
154+
2. Refer to `docs/GEOPHYSICAL_CONFIG.md` for detailed documentation
155+
3. Use `examples/configs/geonav_example.toml` as a template
156+
4. Test the wizard with `test_geo_config_wizard.sh`

conf/geonav_example.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Example configuration with geophysical measurements
2+
# Generated by strapdown-sim config wizard
3+
4+
input = "data/input/sample.csv"
5+
output = "data/output/geonav_result.csv"
6+
mode = "ClosedLoop"
7+
seed = 42
8+
parallel = false
9+
generate_plot = false
10+
11+
[logging]
12+
level = "info"
13+
14+
[closed_loop]
15+
filter = "Ukf"
16+
17+
[geophysical]
18+
# Gravity anomaly measurements
19+
gravity_resolution = "OneMinute"
20+
gravity_bias = 0.0
21+
gravity_noise_std = 100.0
22+
# gravity_map_file will be auto-detected if not specified
23+
24+
# Magnetic anomaly measurements
25+
magnetic_resolution = "OneMinute"
26+
magnetic_bias = 0.0
27+
magnetic_noise_std = 150.0
28+
# magnetic_map_file will be auto-detected if not specified
29+
30+
# Measurement frequency (seconds)
31+
geo_frequency_s = 1.0
32+
33+
[gnss_degradation]
34+
seed = 42
35+
36+
[gnss_degradation.scheduler]
37+
type = "Always"
38+
39+
[gnss_degradation.fault]
40+
type = "None"

core/src/sim.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,6 +2983,9 @@ pub struct SimulationConfig {
29832983
/// Particle filter specific settings (only used if mode is ParticleFilter)
29842984
#[serde(default, skip_serializing_if = "Option::is_none")]
29852985
pub particle_filter: Option<ParticleFilterConfig>,
2986+
/// Geophysical measurement configuration (optional, requires --features geonav)
2987+
#[serde(default, skip_serializing_if = "Option::is_none")]
2988+
pub geophysical: Option<GeophysicalConfig>,
29862989
/// GNSS degradation configuration (scheduler + fault model)
29872990
#[serde(default)]
29882991
pub gnss_degradation: crate::messages::GnssDegradationConfig,
@@ -3004,6 +3007,7 @@ impl Default for SimulationConfig {
30043007
logging: LoggingConfig::default(),
30053008
closed_loop: Some(ClosedLoopConfig::default()),
30063009
particle_filter: None,
3010+
geophysical: None,
30073011
gnss_degradation: crate::messages::GnssDegradationConfig::default(),
30083012
}
30093013
}

docs/GEOPHYSICAL_CONFIG.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Geophysical Measurement Configuration
2+
3+
This document describes how to configure geophysical measurements (gravity and magnetic anomaly) in the strapdown-sim configuration wizard.
4+
5+
## Overview
6+
7+
The `strapdown-sim config` command now supports interactive configuration of geophysical navigation parameters. This allows you to set up simulations that incorporate gravity and/or magnetic anomaly measurements for GNSS-denied navigation.
8+
9+
## Using the Configuration Wizard
10+
11+
When running `strapdown-sim config`, you'll be prompted with a new section for geophysical navigation configuration after the GNSS degradation settings:
12+
13+
### Step 1: Enable Geophysical Navigation
14+
15+
```text
16+
Enable geophysical navigation (gravity/magnetic anomaly measurements)?
17+
(y)es
18+
(n)o
19+
Choice:
20+
```
21+
22+
Select 'y' to configure geophysical measurements, or 'n' to skip this section.
23+
24+
### Step 2: Configure Gravity Measurements (Optional)
25+
26+
If enabled, you'll be prompted to configure gravity anomaly measurements:
27+
28+
```text
29+
Enable gravity anomaly measurements?
30+
(y)es
31+
(n)o
32+
Choice:
33+
```
34+
35+
If you select 'yes', you'll configure:
36+
37+
- **Map Resolution**: Choose from 15 resolution options (1 degree down to 1 arcsecond)
38+
- **Measurement Bias**: Bias in milliGals (mGal), default is 0.0
39+
- **Noise Standard Deviation**: Measurement noise in mGal, default is 100.0
40+
- **Map File Path**: Path to the gravity map NetCDF file (leave empty for auto-detection)
41+
42+
### Step 3: Configure Magnetic Measurements (Optional)
43+
44+
Similarly, you can configure magnetic anomaly measurements:
45+
46+
```text
47+
Enable magnetic anomaly measurements?
48+
(y)es
49+
(n)o
50+
Choice:
51+
```
52+
53+
If you select 'yes', you'll configure:
54+
55+
- **Map Resolution**: Choose from 15 resolution options (1 degree down to 1 arcsecond)
56+
- **Measurement Bias**: Bias in nanoTeslas (nT), default is 0.0
57+
- **Noise Standard Deviation**: Measurement noise in nT, default is 150.0
58+
- **Map File Path**: Path to the magnetic map NetCDF file (leave empty for auto-detection)
59+
60+
### Step 4: Set Measurement Frequency
61+
62+
Finally, specify the frequency for geophysical measurements:
63+
64+
```text
65+
Geophysical measurement frequency (seconds) [auto]:
66+
```
67+
68+
Enter a positive number for the measurement interval in seconds, or press Enter to use automatic frequency.
69+
70+
## Configuration File Format
71+
72+
The geophysical configuration section in the generated TOML file looks like this:
73+
74+
```toml
75+
[geophysical]
76+
# Gravity anomaly measurements
77+
gravity_resolution = "OneMinute"
78+
gravity_bias = 0.0
79+
gravity_noise_std = 100.0
80+
gravity_map_file = "path/to/gravity_map.nc" # Optional
81+
82+
# Magnetic anomaly measurements
83+
magnetic_resolution = "OneMinute"
84+
magnetic_bias = 0.0
85+
magnetic_noise_std = 150.0
86+
magnetic_map_file = "path/to/magnetic_map.nc" # Optional
87+
88+
# Measurement frequency (seconds)
89+
geo_frequency_s = 1.0
90+
```
91+
92+
## Resolution Options
93+
94+
Available map resolutions (higher numbers = finer resolution):
95+
96+
1. One Degree (1°)
97+
2. Thirty Minutes (30')
98+
3. Twenty Minutes (20')
99+
4. Fifteen Minutes (15')
100+
5. Ten Minutes (10')
101+
6. Six Minutes (6')
102+
7. Five Minutes (5')
103+
8. Four Minutes (4')
104+
9. Three Minutes (3')
105+
10. Two Minutes (2')
106+
11. **One Minute (1')** - Default
107+
12. Thirty Seconds (30")
108+
13. Fifteen Seconds (15")
109+
14. Three Seconds (3")
110+
15. One Second (1")
111+
112+
## Default Values
113+
114+
- **Gravity noise standard deviation**: 100.0 mGal
115+
- **Magnetic noise standard deviation**: 150.0 nT
116+
- **Measurement bias**: 0.0 (for both)
117+
- **Map resolution**: One Minute
118+
- **Measurement frequency**: Auto-detected from data
119+
120+
## Example Usage
121+
122+
1. Run the configuration wizard:
123+
124+
```bash
125+
strapdown-sim config
126+
```
127+
128+
2. Follow the prompts to enable geophysical navigation and configure gravity and/or magnetic measurements.
129+
130+
3. The wizard will generate a configuration file that can be used with:
131+
132+
```bash
133+
strapdown-sim --config your_config.toml
134+
```
135+
136+
## Notes
137+
138+
- At least one measurement type (gravity or magnetic) must be enabled if geophysical navigation is activated
139+
- If both map file paths are left empty, the system will attempt to auto-detect them based on the input file location
140+
- The `geonav` feature must be enabled when building strapdown-sim to use these features
141+
142+
## Example Configuration
143+
144+
See [examples/configs/geonav_example.toml](../configs/geonav_example.toml) for a complete example configuration with geophysical measurements.

0 commit comments

Comments
 (0)