Changeset 223 in flair-src
- Timestamp:
- Feb 27, 2018, 12:20:03 PM (7 years ago)
- Location:
- trunk/lib
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/io_data.cpp
r51 r223 46 46 void io_data::SetDataTime(Time time) { 47 47 GetMutex(); 48 if(pimpl_->time!=TIME_INFINITE) pimpl_->deltaTime = time-pimpl_->time; 49 pimpl_->time = time; 50 ReleaseMutex(); 51 } 52 53 void io_data::SetDataTime(Time time,Time deltaTime) { 54 GetMutex(); 55 pimpl_->deltaTime = deltaTime; 48 56 pimpl_->time = time; 49 57 ReleaseMutex(); … … 56 64 ReleaseMutex(); 57 65 return tmp; 66 } 67 68 Time io_data::DataDeltaTime(void) const { 69 Time tmp; 70 GetMutex(); 71 tmp = pimpl_->deltaTime; 72 ReleaseMutex(); 73 return tmp; 74 } 75 76 void io_data::GetDataTime(Time &time,Time &deltaTime) const{ 77 GetMutex(); 78 deltaTime=pimpl_->deltaTime ; 79 time=pimpl_->time ; 80 ReleaseMutex(); 58 81 } 59 82 -
trunk/lib/FlairCore/src/io_data.h
r51 r223 116 116 117 117 /*! 118 * \brief Set data time 119 * 118 * \brief Set data time, also caluculates the delta time based on last call 119 * 120 * TIME_INFINITE represents an unitialized time 121 * 120 122 * \param time time 121 123 */ 122 124 void SetDataTime(Time time); 125 126 /*! 127 * \brief Set data time and delta time (thus delta time is not based on last call) 128 * 129 * TIME_INFINITE represents an unitialized time 130 * 131 * \param time time 132 * \param deltaTime delta time 133 */ 134 void SetDataTime(Time time,Time deltaTime); 123 135 124 136 /*! 125 137 * \brief Data time 126 138 * 139 * TIME_INFINITE represents an unitialized time. 140 * 127 141 * \return data time 128 142 */ 129 143 Time DataTime(void) const; 144 145 /*! 146 * \brief Data delta time 147 * 148 * TIME_INFINITE represents an unitialized time. 149 * 150 * \return data delta time 151 */ 152 Time DataDeltaTime(void) const; 153 154 /*! 155 * \brief Get data time and delta time 156 * 157 * TIME_INFINITE represents an unitialized time 158 * 159 * \param time time 160 * \param deltaTime delta time 161 */ 162 void GetDataTime(Time &time,Time &deltaTime) const; 130 163 131 164 /*! -
trunk/lib/FlairCore/src/io_data_impl.cpp
r122 r223 31 31 is_consistent = false; 32 32 circle_ptr = NULL; 33 deltaTime=TIME_INFINITE;//init 34 time=TIME_INFINITE;//init 33 35 } 34 36 -
trunk/lib/FlairCore/src/unexported/io_data_impl.h
r15 r223 37 37 flair::core::DataType const &datatype); 38 38 size_t size; 39 flair::core::Time time ;39 flair::core::Time time,deltaTime; 40 40 void **circle_ptr; 41 41 -
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 -
trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp
r218 r223 93 93 parent->pimpl_->AddTrackable(this); 94 94 } 95 95 96 previousTime=TIME_INFINITE; 96 97 } 97 98 … … 143 144 Time time = GetTime(); 144 145 //Printf("%s %lld %lld\n",caller->self->ObjectName().c_str(),time,t.msg_time.tv_sec*1000000+t.msg_time.tv_usec); 145 146 Time vrpnTime=t.msg_time.tv_sec*1000000000+t.msg_time.tv_usec*1000; 147 Time deltaTime; 148 if(caller->previousTime!=TIME_INFINITE) { 149 deltaTime=vrpnTime-caller->previousTime; 150 } else { 151 deltaTime=TIME_INFINITE; 152 } 153 caller->previousTime=vrpnTime; 154 146 155 // check if something is nan 147 156 for (int i = 0; i < 3; i++) { … … 178 187 caller->output->SetValueNoMutex(6, 0, pos.z); 179 188 180 caller->output->SetDataTime(time );189 caller->output->SetDataTime(time,deltaTime); 181 190 caller->output->ReleaseMutex(); 182 191 -
trunk/lib/FlairSensorActuator/src/unexported/VrpnObject_impl.h
r214 r223 67 67 vrpn_Tracker_Remote *tracker; 68 68 void Update(void); 69 flair::core::Time previousTime; 69 70 }; 70 71
Note:
See TracChangeset
for help on using the changeset viewer.