@@ -435,11 +435,11 @@ impl UKF {
435435 /// sigma points. The measurement model is specific to a given implementation of the UKF
436436 /// and must be provided by the user as the model determines the shape and quantities of
437437 /// the measurement vector and the measurement sigma points. Measurement models should be
438- /// implemented as traits and applied to the UKF as needed.
439- ///
440- /// This module contains some standard GNSS-aided measurements models (`position_measurement_model`,
441- /// `velocity_measurement_model`, and `position_and_velocity_measurement_model`) that can be
442- /// used. See the `sim` module for a canonical example of a GPS-aided INS implementation
438+ /// implemented as traits and applied to the UKF as needed.
439+ ///
440+ /// This module contains some standard GNSS-aided measurements models (`position_measurement_model`,
441+ /// `velocity_measurement_model`, and `position_and_velocity_measurement_model`) that can be
442+ /// used. See the `sim` module for a canonical example of a GPS-aided INS implementation
443443 /// that uses these models.
444444 ///
445445 /// **Note**: Canonical INS implementations use a position measurement model. Typically,
@@ -688,10 +688,7 @@ pub trait GPS {
688688 ///
689689 /// # Returns
690690 /// * A vector of measurement sigma points either (N x 3) or (N x 2) depending on the `with_altitude` flag
691- fn position_measurement_model (
692- & self ,
693- with_altitude : bool ,
694- ) -> Vec < DVector < f64 > > ;
691+ fn position_measurement_model ( & self , with_altitude : bool ) -> Vec < DVector < f64 > > ;
695692 /// UKF velocity-based measurement model
696693 ///
697694 /// Velocity measurement model. This model is used to update the state based on
@@ -704,10 +701,7 @@ pub trait GPS {
704701 ///
705702 /// # Returns
706703 /// * A vector of measurement sigma points either (N x 3) or (N x 2) depending on the `with_altitude` flag
707- fn velocity_measurement_model (
708- & self ,
709- with_altitude : bool ,
710- ) -> Vec < DVector < f64 > > ;
704+ fn velocity_measurement_model ( & self , with_altitude : bool ) -> Vec < DVector < f64 > > ;
711705 /// GPS or Position-based measurement model
712706 ///
713707 /// GPS-aided INS measurement model for a combined position-velocity measuremet.
@@ -722,53 +716,39 @@ pub trait GPS {
722716 ///
723717 /// # Returns
724718 /// * A vector of measurement sigma points either (N x 6) or (N x 4) depending on the `with_altitude` flag
725- fn position_and_velocity_measurement_model (
726- & self ,
727- with_altitude : bool ,
728- ) -> Vec < DVector < f64 > > ;
719+ fn position_and_velocity_measurement_model ( & self , with_altitude : bool ) -> Vec < DVector < f64 > > ;
729720 /// Position measurement noise model
730- fn position_measurement_noise (
731- & self ,
732- with_altitude : bool ,
733- ) -> DMatrix < f64 > ;
721+ fn position_measurement_noise ( & self , with_altitude : bool ) -> DMatrix < f64 > ;
734722 /// Velocity measurement noise model
735- fn velocity_measurement_noise (
736- & self ,
737- with_altitude : bool ,
738- ) -> DMatrix < f64 > ;
723+ fn velocity_measurement_noise ( & self , with_altitude : bool ) -> DMatrix < f64 > ;
739724 /// Position and velocity measurement noise model
740- fn position_and_velocity_measurement_noise (
741- & self ,
742- with_altitude : bool ,
743- ) -> DMatrix < f64 > ;
725+ fn position_and_velocity_measurement_noise ( & self , with_altitude : bool ) -> DMatrix < f64 > ;
744726}
745- impl GPS for UKF {
746- fn position_measurement_model ( & self ,
747- with_altitude : bool ,
748- ) -> Vec < DVector < f64 > > {
727+ impl GPS for UKF {
728+ fn position_measurement_model ( & self , with_altitude : bool ) -> Vec < DVector < f64 > > {
749729 let sigma_points = self . get_sigma_points ( ) ;
750730 let mut measurement_sigma_points = Vec :: < DVector < f64 > > :: with_capacity ( sigma_points. len ( ) ) ;
751731 for sigma_point in sigma_points {
752- let mut measurement_sigma_point = DVector :: < f64 > :: zeros ( if with_altitude { 3 } else { 2 } ) ;
732+ let mut measurement_sigma_point =
733+ DVector :: < f64 > :: zeros ( if with_altitude { 3 } else { 2 } ) ;
753734 if with_altitude {
754- measurement_sigma_point[ 0 ] = sigma_point. nav_state . latitude ;
735+ measurement_sigma_point[ 0 ] = sigma_point. nav_state . latitude ;
755736 measurement_sigma_point[ 1 ] = sigma_point. nav_state . longitude ;
756- measurement_sigma_point[ 2 ] = sigma_point. nav_state . altitude ;
737+ measurement_sigma_point[ 2 ] = sigma_point. nav_state . altitude ;
757738 } else {
758- measurement_sigma_point[ 0 ] = sigma_point. nav_state . latitude ;
759- measurement_sigma_point[ 1 ] = sigma_point. nav_state . longitude ;
739+ measurement_sigma_point[ 0 ] = sigma_point. nav_state . latitude ;
740+ measurement_sigma_point[ 1 ] = sigma_point. nav_state . longitude ;
760741 }
761742 measurement_sigma_points. push ( measurement_sigma_point) ;
762743 }
763744 measurement_sigma_points
764745 }
765- fn velocity_measurement_model ( & self ,
766- with_altitude : bool ,
767- ) -> Vec < DVector < f64 > > {
746+ fn velocity_measurement_model ( & self , with_altitude : bool ) -> Vec < DVector < f64 > > {
768747 let sigma_points = self . get_sigma_points ( ) ;
769748 let mut measurement_sigma_points = Vec :: < DVector < f64 > > :: with_capacity ( sigma_points. len ( ) ) ;
770749 for sigma_point in sigma_points {
771- let mut measurement_sigma_point = DVector :: < f64 > :: zeros ( if with_altitude { 3 } else { 2 } ) ;
750+ let mut measurement_sigma_point =
751+ DVector :: < f64 > :: zeros ( if with_altitude { 3 } else { 2 } ) ;
772752 if with_altitude {
773753 measurement_sigma_point[ 0 ] = sigma_point. nav_state . velocity_north ; // Northward
774754 measurement_sigma_point[ 1 ] = sigma_point. nav_state . velocity_east ; // Eastward
@@ -781,18 +761,16 @@ impl GPS for UKF {
781761 }
782762 measurement_sigma_points
783763 }
784- fn position_and_velocity_measurement_model ( & self ,
785- with_altitude : bool ,
786- ) -> Vec < DVector < f64 > > {
764+ fn position_and_velocity_measurement_model ( & self , with_altitude : bool ) -> Vec < DVector < f64 > > {
787765 let sigma_points = self . get_sigma_points ( ) ;
788766 let mut measurement_sigma_points = Vec :: < DVector < f64 > > :: with_capacity ( sigma_points. len ( ) ) ;
789767 for sigma_point in sigma_points {
790768 if with_altitude {
791769 // Position and velocity with altitude
792770 let measurement_sigma_point = DVector :: < f64 > :: from_vec ( vec ! [
793- sigma_point. nav_state. latitude, // Latitude
794- sigma_point. nav_state. longitude, // Longitude
795- sigma_point. nav_state. altitude, // Altitude
771+ sigma_point. nav_state. latitude, // Latitude
772+ sigma_point. nav_state. longitude, // Longitude
773+ sigma_point. nav_state. altitude, // Altitude
796774 sigma_point. nav_state. velocity_north, // Northward velocity
797775 sigma_point. nav_state. velocity_east, // Eastward velocity
798776 sigma_point. nav_state. velocity_down, // Downward velocity
@@ -801,8 +779,8 @@ impl GPS for UKF {
801779 } else {
802780 // Position and velocity without altitude
803781 let measurement_sigma_point = DVector :: < f64 > :: from_vec ( vec ! [
804- sigma_point. nav_state. latitude, // Latitude
805- sigma_point. nav_state. longitude, // Longitude
782+ sigma_point. nav_state. latitude, // Latitude
783+ sigma_point. nav_state. longitude, // Longitude
806784 sigma_point. nav_state. velocity_north, // Northward velocity
807785 sigma_point. nav_state. velocity_east, // Eastward velocity
808786 ] ) ;
@@ -815,61 +793,50 @@ impl GPS for UKF {
815793 fn position_measurement_noise ( & self , with_altitude : bool ) -> DMatrix < f64 > {
816794 // Default implementation returns an identity matrix, can be overridden
817795 match with_altitude {
818- true => DMatrix :: from_diagonal ( & DVector :: from_vec (
819- vec ! [
820- 5.0 * METERS_TO_DEGREES ,
821- 5.0 * METERS_TO_DEGREES ,
822- 5.0 ]
823- ) ) ,
824- false => DMatrix :: from_diagonal ( & DVector :: from_vec (
825- vec ! [
826- 5.0 * METERS_TO_DEGREES ,
827- 5.0 * METERS_TO_DEGREES
828- ]
829- ) )
796+ true => DMatrix :: from_diagonal ( & DVector :: from_vec ( vec ! [
797+ 5.0 * METERS_TO_DEGREES ,
798+ 5.0 * METERS_TO_DEGREES ,
799+ 5.0 ,
800+ ] ) ) ,
801+ false => DMatrix :: from_diagonal ( & DVector :: from_vec ( vec ! [
802+ 5.0 * METERS_TO_DEGREES ,
803+ 5.0 * METERS_TO_DEGREES ,
804+ ] ) ) ,
830805 }
831806 }
832807 /// Velocity measurement noise covariance matrix
833808 fn velocity_measurement_noise ( & self , with_altitude : bool ) -> DMatrix < f64 > {
834809 // Default implementation returns an identity matrix, can be overridden
835810 match with_altitude {
836- true => DMatrix :: from_diagonal ( & DVector :: from_vec (
837- vec ! [
838- 0.1 , // Northward velocity noise (m/s)
839- 0.1 , // Eastward velocity noise (m/s)
840- 0.1 , // Downward velocity noise (m/s)
841- ]
842- ) ) ,
843- false => DMatrix :: from_diagonal ( & DVector :: from_vec (
844- vec ! [
845- 0.1 , // Northward velocity noise (m/s)
846- 0.1 , // Eastward velocity noise (m/s)
847- ]
848- ) )
811+ true => DMatrix :: from_diagonal ( & DVector :: from_vec ( vec ! [
812+ 0.1 , // Northward velocity noise (m/s)
813+ 0.1 , // Eastward velocity noise (m/s)
814+ 0.1 , // Downward velocity noise (m/s)
815+ ] ) ) ,
816+ false => DMatrix :: from_diagonal ( & DVector :: from_vec ( vec ! [
817+ 0.1 , // Northward velocity noise (m/s)
818+ 0.1 , // Eastward velocity noise (m/s)
819+ ] ) ) ,
849820 }
850821 }
851822 /// Position and velocity measurement noise covariance matrix
852823 fn position_and_velocity_measurement_noise ( & self , with_altitude : bool ) -> DMatrix < f64 > {
853824 // Default implementation returns an identity matrix, can be overridden
854825 match with_altitude {
855- true => DMatrix :: from_diagonal ( & DVector :: from_vec (
856- vec ! [
857- 5.0 * METERS_TO_DEGREES , // Latitude noise (degrees)
858- 5.0 * METERS_TO_DEGREES , // Longitude noise (degrees)
859- 5.0 , // Altitude noise (meters)
860- 0.1 , // Northward velocity noise (m/s)
861- 0.1 , // Eastward velocity noise (m/s)
862- 0.1 , // Downward velocity noise (m/s)
863- ]
864- ) ) ,
865- false => DMatrix :: from_diagonal ( & DVector :: from_vec (
866- vec ! [
867- 5.0 * METERS_TO_DEGREES , // Latitude noise (degrees)
868- 5.0 * METERS_TO_DEGREES , // Longitude noise (degrees)
869- 0.1 , // Northward velocity noise (m/s)
870- 0.1 , // Eastward velocity noise (m/s)
871- ]
872- ) )
826+ true => DMatrix :: from_diagonal ( & DVector :: from_vec ( vec ! [
827+ 5.0 * METERS_TO_DEGREES , // Latitude noise (degrees)
828+ 5.0 * METERS_TO_DEGREES , // Longitude noise (degrees)
829+ 5.0 , // Altitude noise (meters)
830+ 0.1 , // Northward velocity noise (m/s)
831+ 0.1 , // Eastward velocity noise (m/s)
832+ 0.1 , // Downward velocity noise (m/s)
833+ ] ) ) ,
834+ false => DMatrix :: from_diagonal ( & DVector :: from_vec ( vec ! [
835+ 5.0 * METERS_TO_DEGREES , // Latitude noise (degrees)
836+ 5.0 * METERS_TO_DEGREES , // Longitude noise (degrees)
837+ 0.1 , // Northward velocity noise (m/s)
838+ 0.1 , // Eastward velocity noise (m/s)
839+ ] ) ) ,
873840 }
874841 }
875842}
0 commit comments