Skip to content

Commit aba8da0

Browse files
committed
added new combined measurement model, process noise tuning.
1 parent 0ea19eb commit aba8da0

1 file changed

Lines changed: 34 additions & 22 deletions

File tree

core/src/sim.rs

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use serde::{Deserialize, Serialize};
2424

2525
use crate::earth;
2626
use crate::earth::METERS_TO_DEGREES;
27-
use crate::filter::{StrapdownParams, UKF, GPSPositionMeasurement, GPSVelocityMeasurement, RelativeBarometricAltitudeMeasurement};
27+
use crate::filter::{GPSPositionAndVelocityMeasurement, GPSPositionMeasurement, GPSVelocityMeasurement, RelativeAltitudeMeasurement, StrapdownParams, UKF};
2828
use crate::{IMUData, StrapdownState, forward};
2929
/// Struct representing a single row of test data from the CSV file.
3030
///
@@ -766,7 +766,7 @@ pub fn closed_loop(
766766
gps_interval: Option<usize>
767767
) -> Vec<NavigationResult> {
768768
let gps_interval = gps_interval.unwrap_or(1); // Default to every record if not specified
769-
let reference_pressure = records[0].pressure; // Use the first record's pressure as reference
769+
let reference_altitude = records[0].altitude; // Use the first record's pressure as reference
770770
let mut results: Vec<NavigationResult> = Vec::with_capacity(records.len());
771771
// Initialize the UKF with the first record
772772
let mut ukf = initialize_ukf(
@@ -824,37 +824,31 @@ pub fn closed_loop(
824824
// Update the UKF with the IMU data
825825
ukf.predict(imu_data, dt);
826826
// ---- Perform various measurement updates based on the available data ----
827-
// If GPS data is available, update the UKF with the GPS position measurement
827+
// If GPS data is available, update the UKF with the GPS position and speed measurement
828828
if !record.latitude.is_nan()
829829
&& !record.longitude.is_nan()
830830
&& !record.altitude.is_nan()
831+
&& !record.bearing.is_nan()
832+
&& !record.speed.is_nan()
831833
&& i % gps_interval == 0
832834
{
833-
let measurement = GPSPositionMeasurement {
835+
let measurement = GPSPositionAndVelocityMeasurement {
834836
latitude: record.latitude,
835837
longitude: record.longitude,
836838
altitude: record.altitude,
839+
northward_velocity: record.speed * record.bearing.cos(),
840+
eastward_velocity: record.speed * record.bearing.sin(),
837841
horizontal_noise_std: record.horizontal_accuracy.sqrt(),
838842
vertical_noise_std: record.vertical_accuracy,
843+
velocity_noise_std: record.speed_accuracy,
839844
};
840845
ukf.update(measurement);
841846
}
842-
// If speed information is available, update the UKF with the speed measurement
843-
if !record.speed.is_nan() && i % gps_interval == 0 && !record.bearing.is_nan() {
844-
let speed = GPSVelocityMeasurement {
845-
northward_velocity: record.speed * record.bearing.cos(),
846-
eastward_velocity: record.speed * record.bearing.sin(),
847-
downward_velocity: 0.0, // Assuming no vertical velocity
848-
horizontal_noise_std: record.speed_accuracy.sqrt(),
849-
vertical_noise_std: 0.0,
850-
};
851-
ukf.update(speed);
852-
}
853847
// If barometric altimeter data is available, update the UKF with the altitude measurement
854-
if !record.relative_altitude.is_nan() {
855-
let altitude = RelativeBarometricAltitudeMeasurement {
856-
pressure: record.pressure,
857-
reference_pressure,
848+
if !record.pressure.is_nan() {
849+
let altitude = RelativeAltitudeMeasurement {
850+
relative_altitude: record.relative_altitude,
851+
reference_altitude: reference_altitude,
858852
};
859853
ukf.update(altitude);
860854
}
@@ -992,9 +986,27 @@ pub fn initialize_ukf(
992986
vec![1e-3; 6] // Default values if not provided
993987
}
994988
};
995-
let mut process_noise_diagonal = vec![1e-9; 9]; // adds a minor amount of noise to base states
996-
process_noise_diagonal.extend(vec![1e-9; 6]); // Process noise for imu biases
997-
let process_noise_diagonal = DVector::from_vec(process_noise_diagonal);
989+
//let mut process_noise_diagonal = vec![1e-9; 9]; // adds a minor amount of noise to base states
990+
//process_noise_diagonal.extend(vec![1e-9; 6]); // Process noise for imu biases
991+
let process_noise_diagonal = DVector::from_vec(
992+
vec![
993+
1e-6, // position noise
994+
1e-6, // position noise
995+
1e-6, // altitude noise
996+
1e-3, // velocity north noise
997+
1e-3, // velocity east noise
998+
1e-3, // velocity down noise
999+
1e-5, // roll noise
1000+
1e-5, // pitch noise
1001+
1e-5, // yaw noise
1002+
1e-6, // acc bias x noise
1003+
1e-6, // acc bias y noise
1004+
1e-6, // acc bias z noise
1005+
1e-8, // gyro bias x noise
1006+
1e-8, // gyro bias y noise
1007+
1e-8, // gyro bias z noise
1008+
],
1009+
);
9981010
//DVector::from_vec(vec![0.0; 15]);
9991011
UKF::new(
10001012
ukf_params,

0 commit comments

Comments
 (0)