@@ -570,22 +570,17 @@ pub fn closed_loop(records: &[TestDataRecord]) -> Vec<NavigationResult> {
570570 // Iterate through the records, updating the UKF with each IMU measurement
571571 let total: usize = records. len ( ) ;
572572 let mut i: usize = 1 ;
573- println ! ( "Initialized UKF: \n {:?}" , ukf) ;
574- // clip to first 10 records for testing
575- //let records = records.iter().take(10).collect::<Vec<_>>();
576-
577573 for record in records. iter ( ) . skip ( 1 ) {
578- println ! ( "Processing record {}/{}" , i, total) ;
579574 // Print progress every 100 iterations
580-
581- // if i % 10 == 0 || i == total - 1 {
582- // print!(
583- // "\rProcessing data {:.2}%...",
584- // (i as f64 / total as f64) * 100.0
585- // );
586- // use std::io::Write;
587- // std::io::stdout().flush().ok();
588- // }
575+ if i % 10 == 0 || i == total - 1 {
576+ print ! (
577+ " \r Processing data {:.2}%..." ,
578+ ( i as f64 / total as f64 ) * 100.0
579+ ) ;
580+ //print_ukf(&ukf, record );
581+ use std:: io:: Write ;
582+ std:: io:: stdout ( ) . flush ( ) . ok ( ) ;
583+ }
589584 // Calculate time difference from the previous record
590585 let current_timestamp = record. time ;
591586 let dt = ( current_timestamp - previous_timestamp) . as_seconds_f64 ( ) ;
@@ -605,8 +600,7 @@ pub fn closed_loop(records: &[TestDataRecord]) -> Vec<NavigationResult> {
605600 ) ;
606601 // Update the UKF with the IMU data
607602 ukf. predict ( & imu_data, dt) ;
608- println ! ( "predicted!" ) ;
609- print_ukf ( & ukf, record) ;
603+
610604 // If GPS data is available, update the UKF with the GPS measurement
611605 if !record. latitude . is_nan ( ) && !record. longitude . is_nan ( ) && !record. altitude . is_nan ( ) {
612606 let measurement = DVector :: from_vec ( vec ! [
@@ -638,7 +632,7 @@ pub fn closed_loop(records: &[TestDataRecord]) -> Vec<NavigationResult> {
638632 results
639633}
640634pub fn print_ukf ( ukf : & UKF , record : & TestDataRecord ) {
641- println ! ( "UKF position: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4e}, {:.4e}, {:.4} | Error: {:.4e}, {:.4e}, {:.4}" ,
635+ println ! ( "\r UKF position: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4e}, {:.4e}, {:.4} | Error: {:.4e}, {:.4e}, {:.4}" ,
642636 ukf. get_mean( ) [ 0 ] . to_degrees( ) ,
643637 ukf. get_mean( ) [ 1 ] . to_degrees( ) ,
644638 ukf. get_mean( ) [ 2 ] ,
@@ -649,7 +643,7 @@ pub fn print_ukf(ukf: &UKF, record: &TestDataRecord) {
649643 ukf. get_mean( ) [ 1 ] . to_degrees( ) - record. longitude,
650644 ukf. get_mean( ) [ 2 ] - record. altitude
651645 ) ;
652- println ! ( "UKF velocity: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4}, {:.4}, {:.4} | Error: {:.4}, {:.4}, {:.4}" ,
646+ println ! ( "\r UKF velocity: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4}, {:.4}, {:.4} | Error: {:.4}, {:.4}, {:.4}" ,
653647 ukf. get_mean( ) [ 3 ] ,
654648 ukf. get_mean( ) [ 4 ] ,
655649 ukf. get_mean( ) [ 5 ] ,
@@ -660,7 +654,7 @@ pub fn print_ukf(ukf: &UKF, record: &TestDataRecord) {
660654 ukf. get_mean( ) [ 4 ] - record. speed * record. bearing. sin( ) ,
661655 ukf. get_mean( ) [ 5 ] - 0.0 // Assuming no vertical velocity
662656 ) ;
663- println ! ( "UKF attitude: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4}, {:.4}, {:.4} | Error: {:.4}, {:.4}, {:.4}" ,
657+ println ! ( "\r UKF attitude: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4}, {:.4}, {:.4} | Error: {:.4}, {:.4}, {:.4}" ,
664658 ukf. get_mean( ) [ 6 ] ,
665659 ukf. get_mean( ) [ 7 ] ,
666660 ukf. get_mean( ) [ 8 ] ,
@@ -671,15 +665,15 @@ pub fn print_ukf(ukf: &UKF, record: &TestDataRecord) {
671665 ukf. get_mean( ) [ 7 ] - record. pitch,
672666 ukf. get_mean( ) [ 8 ] - record. yaw
673667 ) ;
674- println ! ( "UKF accel biases: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4e}, {:.4e}, {:.4e}" ,
668+ println ! ( "\r UKF accel biases: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4e}, {:.4e}, {:.4e}" ,
675669 ukf. get_mean( ) [ 9 ] ,
676670 ukf. get_mean( ) [ 10 ] ,
677671 ukf. get_mean( ) [ 11 ] ,
678672 ukf. get_covariance( ) [ ( 9 , 9 ) ] ,
679673 ukf. get_covariance( ) [ ( 10 , 10 ) ] ,
680674 ukf. get_covariance( ) [ ( 11 , 11 ) ]
681675 ) ;
682- println ! ( "UKF gyro biases: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4e}, {:.4e}, {:.4e}" ,
676+ println ! ( "\r UKF gyro biases: ({:.4}, {:.4}, {:.4}) | Covariance: {:.4e}, {:.4e}, {:.4e}" ,
683677 ukf. get_mean( ) [ 12 ] ,
684678 ukf. get_mean( ) [ 13 ] ,
685679 ukf. get_mean( ) [ 14 ] ,
0 commit comments