1616//! measurements in the local level frame (i.e. a GPS fix).
1717use crate :: earth:: METERS_TO_DEGREES ;
1818use crate :: linalg:: matrix_square_root;
19- use crate :: { IMUData , StrapdownState , wrap_to_2pi, wrap_to_360} ;
19+ use crate :: { IMUData , StrapdownState , forward , wrap_to_2pi, wrap_to_360} ;
2020use nalgebra:: { DMatrix , DVector , Rotation3 , SVector } ;
2121use rand;
2222use rand_distr:: { Distribution , Normal } ;
@@ -146,11 +146,11 @@ impl SigmaPoint {
146146 /// let imu_data = IMUData::new_from_vec(vec![0.0, 0.0, 0.0], vec![0.0, 0.0, 0.0]);
147147 /// let dt = 0.1;
148148 ///
149- /// sigma_point.forward(& imu_data, dt, None);
149+ /// sigma_point.forward(imu_data, dt, None);
150150 /// ```
151- pub fn forward ( & mut self , imu_data : & IMUData , dt : f64 , noise : Option < Vec < f64 > > ) {
151+ pub fn forward ( & mut self , imu_data : IMUData , dt : f64 , noise : Option < Vec < f64 > > ) {
152152 // Propagate the strapdown state using the strapdown equations
153- self . nav_state . forward ( imu_data, dt) ;
153+ self . nav_state = forward ( self . nav_state , imu_data, dt) ;
154154 let noise_vect = match noise {
155155 None => return , // UKF mode, does not use noise in propagation
156156 Some ( v) => v, // Particle filter mode, uses noise in propagation
@@ -465,7 +465,7 @@ impl UKF {
465465 let mut sigma_points = self . get_sigma_points ( ) ;
466466 for sigma_point in & mut sigma_points {
467467 println ! ( "{}" , sigma_point. get_string( ) ) ;
468- sigma_point. forward ( imu_data, dt, None ) ;
468+ sigma_point. forward ( * imu_data, dt, None ) ;
469469 }
470470 // Update the mean state as mu_bar
471471 let mut mu_bar = DVector :: < f64 > :: zeros ( self . state_size ) ;
@@ -624,7 +624,7 @@ impl ParticleFilter {
624624 /// * `imu_data` - The IMU measurements to propagate the particles with.
625625 pub fn propagate ( & mut self , imu_data : & IMUData , dt : f64 ) {
626626 for particle in & mut self . particles {
627- particle. forward ( imu_data, dt, None ) ;
627+ particle. forward ( * imu_data, dt, None ) ;
628628 }
629629 }
630630 /// Update the weights of the particles based on a measurement
@@ -907,8 +907,6 @@ impl GPS for UKF {
907907/// Tests
908908#[ cfg( test) ]
909909mod tests {
910- use std:: os:: unix:: process;
911-
912910 use crate :: earth;
913911
914912 use super :: * ;
@@ -935,7 +933,7 @@ mod tests {
935933 gyro : Vector3 :: new ( 0.0 , 0.0 , 0.0 ) ,
936934 } ;
937935 let dt = 1.0 ;
938- sigma_point. forward ( & imu_data, dt, None ) ;
936+ sigma_point. forward ( imu_data. clone ( ) , dt, None ) ;
939937
940938 let position = [ 0.0 , 0.0 , 0.0 ] ;
941939 let velocity = [ 0.0 , 0.0 , 0.0 ] ;
@@ -955,7 +953,7 @@ mod tests {
955953 0.01 , 0.01 , 0.01 , // IMU biases noise
956954 0.01 , 0.01 , 0.01 , // Measurement bias noise
957955 ] ;
958- sigma_point. forward ( & imu_data, dt, Some ( noise) ) ;
956+ sigma_point. forward ( imu_data. clone ( ) , dt, Some ( noise) ) ;
959957 // Check that the state has changed
960958 assert ! ( sigma_point. nav_state. latitude != position[ 0 ] ) ;
961959 assert ! ( sigma_point. nav_state. longitude != position[ 1 ] ) ;
0 commit comments