Changeset 223 in flair-src for trunk/lib/FlairFilter
- Timestamp:
- Feb 27, 2018, 12:20:03 PM (7 years ago)
- Location:
- trunk/lib/FlairFilter/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairFilter/src/AhrsComplementaryFilter.cpp
r198 r223 35 35 namespace flair { namespace filter { 36 36 37 AhrsComplementaryFilter::AhrsComplementaryFilter(const Imu* parent,string name): isInit(false),Ahrs(parent,name) {37 AhrsComplementaryFilter::AhrsComplementaryFilter(const Imu* parent,string name): Ahrs(parent,name) { 38 38 39 39 QHat.q0=1; … … 76 76 input->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr); 77 77 78 delta_t=(float)(data->DataTime()-previous_time)/1000000000.; 79 previous_time=data->DataTime(); 78 delta_t=(float)(data->DataDeltaTime())/1000000000.; 80 79 81 80 Vector3Df aBar,aHat,aTilde; … … 89 88 magRef=this->magRef->Value(); 90 89 91 if( isInit==true) {90 if(delta_t!=0) { 92 91 // CORRECTION FROM ACCELEROMETER 93 92 aBar = rawAcc; … … 153 152 ahrsData->SetQuaternionAndAngularRates(QHat,rawGyr - BHat); 154 153 155 } else { 156 isInit=true; 157 } 154 } 158 155 159 156 ahrsData->SetDataTime(data->DataTime()); -
trunk/lib/FlairFilter/src/AhrsComplementaryFilter.h
r198 r223 63 63 void UpdateFrom(const core::io_data *data); 64 64 65 core::Time previous_time;66 67 bool isInit;68 65 core::Quaternion QHat; 69 66 core::Vector3Df BHat; -
trunk/lib/FlairFilter/src/AhrsKalman_impl.cpp
r167 r223 65 65 66 66 AhrsKalman_impl::AhrsKalman_impl(const Layout* layout,AhrsData *inAhrsData): ahrsData(inAhrsData) { 67 is_init=false;68 67 euler.yaw=0; 69 68 … … 90 89 input->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr); 91 90 92 delta_t=(float)(data->DataTime()-previous_time)/1000000000.; 93 previous_time=data->DataTime(); 91 delta_t=(float)(data->DataDeltaTime())/1000000000.; 94 92 95 93 if(Q_angle->ValueChanged() || Q_gyro->ValueChanged() || R_angle->ValueChanged()) { … … 98 96 } 99 97 100 if( is_init==true) {98 if(delta_t!=0) { 101 99 //execute kalman roll filter 102 100 ars_predict(&ars_roll, rawGyr.x, delta_t); … … 116 114 ahrsData->SetQuaternionAndAngularRates(euler.ToQuaternion(), 117 115 rawGyr-Vector3Df(ars_roll.x_bias,ars_pitch.x_bias,0)); 118 } else {119 is_init=true;120 116 } 121 122 117 ahrsData->SetDataTime(data->DataTime()); 123 118 } -
trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp
r214 r223 56 56 } 57 57 58 first_update = true;59 58 this->order=order; 60 59 this->nbRow=nbRow; … … 91 90 92 91 if (T->Value() == 0) { 93 delta_t = (float)(data->Data Time() - previous_time) / 1000000000.;92 delta_t = (float)(data->DataDeltaTime()) / 1000000000.; 94 93 for(uint32_t i=0;i<nbRow;i++) { 95 94 for(uint32_t j=0;j<nbCol;j++) { … … 114 113 } 115 114 116 if (first_update == true) { 117 first_update = false; 118 } else { 115 if (delta_t!=0) { 119 116 for(uint32_t i=0;i<nbRow;i++) { 120 117 for(uint32_t j=0;j<nbCol;j++) { … … 129 126 130 127 output->SetDataTime(data->DataTime()); 131 previous_time = data->DataTime();132 128 } 133 129 -
trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp
r214 r223 32 32 string name, 33 33 const Matrix *init_value) { 34 first_update = true;35 34 this->self = self; 36 35 … … 94 93 } else { 95 94 if (T->Value() == 0) { 96 delta_t = (float)(data->Data Time() - previous_time) / 1000000000.;95 delta_t = (float)(data->DataDeltaTime()) / 1000000000.; 97 96 } else { 98 97 delta_t = T->Value(); 99 98 } 100 99 101 for (int i = 0; i < input->Rows(); i++) { 102 for (int j = 0; j < input->Cols(); j++) { 103 output->SetValueNoMutex( 104 i, j, (input->ValueNoMutex(i, j) - prev_value->ValueNoMutex(i, j)) / 105 delta_t); 106 prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 100 if(delta_t!=0) { 101 for (int i = 0; i < input->Rows(); i++) { 102 for (int j = 0; j < input->Cols(); j++) { 103 output->SetValueNoMutex( 104 i, j, (input->ValueNoMutex(i, j) - prev_value->ValueNoMutex(i, j)) / 105 delta_t); 106 prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 107 } 107 108 } 108 109 } … … 113 114 114 115 output->SetDataTime(data->DataTime()); 115 previous_time = data->DataTime();116 116 } -
trunk/lib/FlairFilter/src/JoyReference_impl.cpp
r214 r223 69 69 70 70 z_ref = 0; 71 previous_time = 0;72 71 trim_roll = 0; 73 72 trim_pitch = 0; … … 154 153 } 155 154 156 if (previous_time == 0) 157 previous_time = data->DataTime(); // pour la premiere iteration 158 float delta_t = (float)(data->DataTime() - previous_time) / 1000000000.; 159 previous_time = data->DataTime(); 155 float delta_t = (float)(data->DataDeltaTime()) / 1000000000.; 160 156 161 157 if (button_roll->Clicked() == true) { -
trunk/lib/FlairFilter/src/LowPassFilter_impl.cpp
r214 r223 67 67 " Hz", 0, 10000, 0.1, 2, 1); 68 68 69 previous_time=GetTime();70 69 this->self = self; 71 70 } … … 87 86 88 87 if (T->Value() == 0) { 89 delta_t = (float)(data->Data Time() - previous_time) / 1000000000.;88 delta_t = (float)(data->DataDeltaTime() ) / 1000000000.; 90 89 } else { 91 90 delta_t = T->Value(); 92 91 } 93 for (int i = 0; i < input->Rows(); i++) { 94 for (int j = 0; j < input->Cols(); j++) { 95 float cutoff=freq->Value(); 96 if (cutoff == 0 || freq->ValueChanged()) { 97 output->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 98 } else { 99 output->SetValueNoMutex(i, j, (1 - 2 * PI * cutoff * delta_t) * 100 output->ValueNoMutex(i, j) + 101 2 * PI * cutoff * delta_t * 102 input->ValueNoMutex(i, j)); 92 93 if(delta_t!=0) { 94 for (int i = 0; i < input->Rows(); i++) { 95 for (int j = 0; j < input->Cols(); j++) { 96 float cutoff=freq->Value(); 97 if (cutoff == 0 || freq->ValueChanged()) { 98 output->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 99 } else { 100 output->SetValueNoMutex(i, j, (1 - 2 * PI * cutoff * delta_t) * 101 output->ValueNoMutex(i, j) + 102 2 * PI * cutoff * delta_t * 103 input->ValueNoMutex(i, j)); 104 } 103 105 } 104 106 } … … 109 111 110 112 output->SetDataTime(data->DataTime()); 111 previous_time = data->DataTime();112 113 } -
trunk/lib/FlairFilter/src/PidThrust_impl.cpp
r214 r223 84 84 85 85 if (T->Value() == 0) { 86 delta_t = (float)(data->Data Time() - previous_time) / 1000000000.;86 delta_t = (float)(data->DataDeltaTime()) / 1000000000.; 87 87 } else { 88 88 delta_t = T->Value(); … … 121 121 self->output->SetValue(0, 0, total - offset_g * offset_g); 122 122 self->output->SetDataTime(data->DataTime()); 123 124 previous_time = data->DataTime();125 123 } -
trunk/lib/FlairFilter/src/Pid_impl.cpp
r214 r223 79 79 80 80 if (T->Value() == 0) { 81 delta_t = (float)(data->Data Time() - previous_time) / 1000000000.;81 delta_t = (float)(data->DataDeltaTime() ) / 1000000000.; 82 82 } else { 83 83 delta_t = T->Value(); … … 113 113 self->output->SetValue(0, 0, total); 114 114 self->output->SetDataTime(data->DataTime()); 115 116 previous_time = data->DataTime();117 115 } -
trunk/lib/FlairFilter/src/unexported/AhrsKalman_impl.h
r18 r223 79 79 ars_Gyro1DKalman ars_roll; 80 80 ars_Gyro1DKalman ars_pitch; 81 flair::core::Time previous_time;82 bool is_init;83 81 flair::gui::DoubleSpinBox *Q_angle,*Q_gyro,*R_angle; 84 82 flair::core::Euler euler; -
trunk/lib/FlairFilter/src/unexported/ButterworthLowPass_impl.h
r214 r223 131 131 flair::gui::DoubleSpinBox *cutoff, *T; 132 132 PoleFilter **f; 133 bool first_update;134 flair::core::Time previous_time;135 133 uint32_t order; 136 134 uint32_t nbRow, nbCol; -
trunk/lib/FlairFilter/src/unexported/EulerDerivative_impl.h
r214 r223 45 45 private: 46 46 flair::gui::DoubleSpinBox *T; 47 flair::core::Time previous_time;48 47 bool first_update; 49 48 flair::core::Matrix *prev_value; -
trunk/lib/FlairFilter/src/unexported/JoyReference_impl.h
r214 r223 80 80 flair::core::Quaternion q_z = flair::core::Quaternion(1, 0, 0, 0); 81 81 float trim_roll, trim_pitch; 82 flair::core::Time previous_time;83 82 84 83 flair::filter::JoyReference *self; -
trunk/lib/FlairFilter/src/unexported/LowPassFilter_impl.h
r214 r223 42 42 43 43 private: 44 flair::core::Time previous_time;45 44 flair::gui::DoubleSpinBox *freq, *T; 46 45 const flair::filter::LowPassFilter *self; -
trunk/lib/FlairFilter/src/unexported/PidThrust_impl.h
r214 r223 46 46 private: 47 47 flair::filter::PidThrust *self; 48 flair::core::Time previous_time;49 48 bool first_update; 50 49 -
trunk/lib/FlairFilter/src/unexported/Pid_impl.h
r214 r223 46 46 private: 47 47 flair::filter::Pid *self; 48 flair::core::Time previous_time;49 48 50 49 // matrix
Note:
See TracChangeset
for help on using the changeset viewer.