diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index f7a7e2946..e43cda93f 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2301,7 +2301,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item { // VTP To.Do: Check why get_PVT is triggered twice. Leave only one get_PVT. - flag_pvt_valid = d_user_pvt_solver->get_PVT(d_gnss_observables_map, false, false, false); + //flag_pvt_valid = d_user_pvt_solver->get_PVT(d_gnss_observables_map, false, false, false); } if (flag_pvt_valid == true) diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 8f7c827c8..589e6ae08 100755 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -473,7 +473,7 @@ bool Rtklib_Solver::save_matfile() const { // READ DUMP FILE const std::string dump_filename = d_dump_filename; - const int32_t number_of_double_vars = 23; //+2 MAGL + const int32_t number_of_double_vars = 21; const int32_t number_of_uint32_vars = 2; const int32_t number_of_uint8_vars = 3; const int32_t number_of_float_vars = 2; @@ -1879,8 +1879,6 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ vtl_data.rx_dts(0) = rx_position_and_time[3]; vtl_data.rx_dts(1) = pvt_sol.dtr[5] / 1e6; // [ppm] to [s] - //new_vtl_data.debug_print(); - //vtl_data.kf_state.print("kf_state_input"); vtl_engine.vtl_loop(vtl_data); } diff --git a/src/algorithms/PVT/libs/vtl_engine.cc b/src/algorithms/PVT/libs/vtl_engine.cc index 6cae756df..7384e2659 100755 --- a/src/algorithms/PVT/libs/vtl_engine.cc +++ b/src/algorithms/PVT/libs/vtl_engine.cc @@ -44,25 +44,32 @@ bool Vtl_Engine::vtl_loop(Vtl_Data new_data) } double delta_t_vtl = (new_data.sample_counter - refSampleCounter) / 5000000.0; refSampleCounter = new_data.sample_counter; + static double delta_t_cmd = 0; + bool flag_cmd = false; + delta_t_cmd = delta_t_cmd+delta_t_vtl; // update timer for vtl trk command + if(delta_t_cmd>=0.3){ + flag_cmd = true; + delta_t_cmd = 0; // reset timer for vtl trk command + } // ################## Kalman filter initialization ###################################### //State variables arma::mat kf_dx = arma::zeros(n_of_states, 1); // covariances (static) - kf_R = arma::zeros(2 * new_data.sat_number, 2 * new_data.sat_number); + kf_R = arma::zeros(3 * new_data.sat_number, 3 * new_data.sat_number); double kf_dt = delta_t_vtl; //0.05; kf_Q = arma::eye(n_of_states, n_of_states); kf_F = arma::eye(n_of_states, n_of_states); bool test = kf_F_fill(kf_F,kf_dt); - //kf_H = arma::zeros(2 * new_data.sat_number, n_of_states); - kf_y = arma::zeros(2 * new_data.sat_number, 1); - kf_yerr = arma::zeros(2 * new_data.sat_number, 1); + //kf_H = arma::zeros(3 * new_data.sat_number, n_of_states); + kf_y = arma::zeros(3 * new_data.sat_number, 1); + kf_yerr = arma::zeros(3 * new_data.sat_number, 1); kf_xerr = arma::zeros(n_of_states, 1); - kf_S = arma::zeros(2 * new_data.sat_number, 2 * new_data.sat_number); // kf_P_y innovation covariance matrix - kf_K = arma::zeros(n_of_states, 2 * new_data.sat_number); ; + kf_S = arma::zeros(3 * new_data.sat_number, 3 * new_data.sat_number); // kf_P_y innovation covariance matrix + kf_K = arma::zeros(n_of_states, 3 * new_data.sat_number); ; // ################## Kalman Tracking ###################################### counter++; //uint64_t //new_data.kf_state.print("new_data kf initial"); @@ -84,25 +91,22 @@ bool Vtl_Engine::vtl_loop(Vtl_Data new_data) kf_x(9) = new_data.rx_dts(0) * SPEED_OF_LIGHT_M_S; kf_x(10) = new_data.rx_dts(1) * SPEED_OF_LIGHT_M_S; - kf_dx=kf_x-kf_dx; + kf_dx = kf_x-kf_dx; kf_dx = kf_F * kf_dx; // state prediction } else { // receiver solution from previous KF step - // kf_x(0) = x_u; - // kf_x(1) = y_u; - // kf_x(2) = z_u; - // kf_x(3) = xDot_u; - // kf_x(4) = yDot_u; - // kf_x(5) = zDot_u; - // kf_x(6) = xDot2_u; - // kf_x(7) = yDot2_u; - // kf_x(8) = zDot2_u; - // kf_x(9) = cdeltat_u; - // kf_x(10) = cdeltatDot_u; - - //kf_P_x = new_data.kf_P; + double acc_x = 0; + double acc_y = 0; + double acc_z = 0; + test = model3DoF(acc_x,acc_y,acc_z,kf_x,kf_dt,counter); + kf_x(6) = acc_x; + kf_x(7) = acc_y; + kf_x(8) = acc_z; + // kf_x(6) = (kf_x(6)-kf_dx(6))/kf_dt; + // kf_x(7) = (kf_x(7)-kf_dx(7))/kf_dt; + // kf_x(8) = (kf_x(8)-kf_dx(8))/kf_dt; } // State error Covariance Matrix Q (PVT) @@ -113,28 +117,28 @@ bool Vtl_Engine::vtl_loop(Vtl_Data new_data) kf_Q(3, 3) = 8.0; kf_Q(4, 4) = 8.0; kf_Q(5, 5) = 8.0; - kf_Q(6, 6) = .1; - kf_Q(7, 7) = .1; - kf_Q(8, 8) = .1; + kf_Q(6, 6) = .10; + kf_Q(7, 7) = .10; + kf_Q(8, 8) = .10; kf_Q(9, 9) = 4.0; - kf_Q(10, 10) = 100.0; + kf_Q(10, 10) = 10.0; // Measurement error Covariance Matrix R assembling for (int32_t i = 0; i < new_data.sat_number; i++) { // It is diagonal 2*NSatellite x 2*NSatellite (NSat psudorange error;NSat pseudo range rate error) - kf_R(i, i) = 20.0;//*50.0/new_data.sat_CN0_dB_hz(i); //TODO: fill with real values. - kf_R(i + new_data.sat_number, i + new_data.sat_number) = 1.0;//*50.0/new_data.sat_CN0_dB_hz(i); + kf_R(i, i) = 80.0;//*50.0/new_data.sat_CN0_dB_hz(i); //TODO: fill with real values. + kf_R(i + new_data.sat_number, i + new_data.sat_number) = 20.0;//*50.0/new_data.sat_CN0_dB_hz(i); + kf_R(i + 2*new_data.sat_number, i + 2*new_data.sat_number) = 400.0;//*50.0/new_data.sat_CN0_dB_hz(i); - // if(50.0*50.0/new_data.sat_CN0_dB_hz(i)>70||5.0*50.0/new_data.sat_CN0_dB_hz(i)>7){ + // if(80.0*50.0/new_data.sat_CN0_dB_hz(i)>90||20.0*50.0/new_data.sat_CN0_dB_hz(i)>25){ // kf_R(i, i) = 10e4; // kf_R(i + new_data.sat_number, i + new_data.sat_number) = 10e4; + // kf_R(i + 2*new_data.sat_number, i + 2*new_data.sat_number) = 10e4; + // cout<<"channel: "<.5){ - kf_xerr.print("kf_xERR: "); - cout<<"kf_dt: "<5){ - // dump_vtl_file << "pr_m" - // << "," << new_data.pr_m(0) << "," << new_data.pr_m(1) << "," << new_data.pr_m(2) - // << "," << new_data.pr_m(3) << "," << new_data.pr_m(4)<<"," << new_data.pr_m(5) << endl; - // dump_vtl_file << "prDot_m" - // << "," << new_data.doppler_hz(0)<< "," << new_data.doppler_hz(1)<< "," << new_data.doppler_hz(2) - // << "," << new_data.doppler_hz(3) << "," << new_data.doppler_hz(4)<< "," << new_data.doppler_hz(5)<< endl; - // dump_vtl_file << "sat_position" - // << "," << kf_xerr(0) << "," << kf_xerr(1) << "," << "," << kf_xerr(5) - // << "," << kf_xerr(6) << "," << kf_xerr(7) << endl; - // dump_vtl_file << "sat_velocity" - // << "," << kf_xerr(0) << "," << kf_xerr(1) << "," << kf_xerr(2) << "," << kf_xerr(3) << "," << kf_xerr(4) << "," << kf_xerr(5) - // << "," << kf_xerr(6) << "," << kf_xerr(7) << endl; - } - dump_vtl_file << "kf_state" - << "," << kf_x(0) << "," << kf_x(1) << "," << kf_x(2) << "," << kf_x(3) << "," << kf_x(4) << "," << kf_x(5) << "," << kf_x(6) << "," << kf_x(7)<< "," << kf_x(8) <<"," << kf_x(9) <<"," << kf_x(10)<< endl; - dump_vtl_file << "kf_xerr" - << "," << kf_xerr(0) << "," << kf_xerr(1) << "," << kf_xerr(2) << "," << kf_xerr(3) << "," << kf_xerr(4) << "," << kf_xerr(5) << "," << kf_xerr(6) << "," << kf_xerr(7)<< "," << kf_xerr(8) <<"," << kf_xerr(9) <<"," << kf_xerr(10)<< endl; - dump_vtl_file << "rtklib_state" - << "," << new_data.rx_p(0) << "," << new_data.rx_p(1) << "," << new_data.rx_p(2) << "," << new_data.rx_v(0) << "," << new_data.rx_v(1) << "," << new_data.rx_v(2) << "," << new_data.rx_dts(0) << "," << new_data.rx_dts(1) << "," << delta_t_vtl << endl; - // dump_vtl_file << "filt_dopp_sat" - // << "," << doppler_hz_filt(0) << "," << doppler_hz_filt(1) << "," << doppler_hz_filt(2) << "," << doppler_hz_filt(3) << "," << doppler_hz_filt(4) <5){ + // // dump_vtl_file << "pr_m" + // // << "," << kf_yerr(0)<< "," << kf_yerr(1)<< "," << kf_yerr(2) + // // << "," << kf_yerr(3) << "," << kf_yerr(4)<< "," << kf_yerr(5)<1500){ + if(u>6){ + t_disparo=t_disparo+dt; + std::cout<<"u : "< Vtl_Engine::get_position_ecef_m() { std::vector temp = {42,42,42}; diff --git a/src/algorithms/PVT/libs/vtl_engine.h b/src/algorithms/PVT/libs/vtl_engine.h index dd13d6f4d..751e30362 100755 --- a/src/algorithms/PVT/libs/vtl_engine.h +++ b/src/algorithms/PVT/libs/vtl_engine.h @@ -66,6 +66,7 @@ private: arma::colvec d; arma::colvec rho_pri; arma::colvec rhoDot_pri; + arma::colvec rhoDot2_pri; arma::colvec rho_pri_filt; arma::colvec rhoDot_pri_filt; arma::colvec doppler_hz_filt; @@ -103,7 +104,9 @@ private: bool kf_H_fill(arma::mat &kf_H, int sat_number, arma::colvec ax, arma::colvec ay, arma::colvec az, double kf_dt); // Observation Matrix constructor bool kf_F_fill(arma::mat &kf_F,double kf_dt); // System Matrix constructor bool obsv_calc(arma::mat &rho_pri,arma::mat &rhoDot_pri,arma::colvec &ax, arma::colvec &ay, arma::colvec &az,int sat_number,arma::mat sat_p,arma::mat sat_v,arma::mat kf_x); // Observables calculation - bool kf_measurements(arma::mat &kf_yerr, int sat_number, arma::mat rho_pri, arma::mat rhoDot_pri, arma::colvec pr_m, arma::colvec doppler_hz, arma::mat kf_x); + bool kf_measurements(arma::mat &kf_yerr, int sat_number, arma::mat rho_pri, arma::mat rhoDot_pri, arma::mat rhoDot2_pri, arma::colvec pr_m, arma::colvec doppler_hz, arma::mat kf_x); + bool model3DoF(double &acc_x,double &acc_y,double &acc_z,arma::mat kf_x,double dt, int counter); + double EmpujeLkTable(double t_disparo); }; /** \} */ diff --git a/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc index 1c9dd18e9..0bcec91a6 100644 --- a/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc @@ -656,20 +656,30 @@ void kf_tracking::msg_handler_pvt_to_trk(const pmt::pmt_t &msg) double old_doppler = d_x_old_old(2); double old_doppler_rate = d_x_old_old(3); double old_code_phase_chips = d_x_old_old(0); + + if(cmd->enable_carrier_nco_cmd){ + if(cmd->enable_code_nco_cmd){ + if(abs(d_x_old_old(2) - tmp_x(2))>50){ + std::cout <<"channel: "<< this->d_channel + << " tracking_cmd TOO FAR: " + << abs(d_x_old_old(2) - tmp_x(2))<< "Hz" + << " \n"; + }else{ + std::cout <<"channel: "<< this->d_channel + << " tracking_cmd NEAR: " + << abs(d_x_old_old(2) - tmp_x(2))<< "Hz" + << " \n"; + } + d_x_old_old(2) = tmp_x(2); //replace DOPPLER + // d_x_old_old(3) = tmp_x(3); //replace DOPPLER RATE - if(abs(d_x_old_old(2) - tmp_x(2))>50){ - // std::cout << " tracking_cmd TOO FAR: " - // << abs(d_x_old_old(2) - tmp_x(2))<< "Hz" - // << " \n"; - }else{ - // std::cout << " tracking_cmd NEAR: " - // << abs(d_x_old_old(2) - tmp_x(2))<< "Hz" - // << " \n"; - //d_x_old_old(2) = tmp_x(2); //replace the Code Phase state + }else{ + // std::cout<<"yet to soon"<sample_counter; @@ -698,7 +708,7 @@ void kf_tracking::msg_handler_pvt_to_trk(const pmt::pmt_t &msg) else { dump_tracking_file << "doppler_corr" - << ","<< this->d_channel << "," << x_tmp(2) << "," << old_doppler << "," << old_doppler_rate << "," << old_code_phase_chips << "\n"; + << ","<< this->d_channel << "," << tmp_x(2) << "," << old_doppler << "," << tmp_x(3)<< "," << old_doppler_rate << "\n"; dump_tracking_file.close(); } }