- Timestamp:
- Feb 28, 2017, 12:45:08 PM (8 years ago)
- Location:
- trunk/lib
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Box.cpp
r15 r147 49 49 } 50 50 51 void Box::SetValueChanged(void) { 51 void Box::SetValueChanged(void) {value_changed = true; } 52 52 53 53 void Box::GetMutex(void) const { ((Layout *)Parent())->mutex->GetMutex(); } -
trunk/lib/FlairCore/src/OneAxisRotation.cpp
r144 r147 57 57 58 58 float OneAxisRotation::GetAngle() const { 59 return pimpl_->GetAngle();59 return Euler::ToRadian(pimpl_->GetAngle()); 60 60 } 61 61 -
trunk/lib/FlairCore/src/OneAxisRotation.h
r144 r147 81 81 */ 82 82 void ComputeRotation(core::RotationMatrix &matrix) const; 83 83 84 /*! 85 * \brief Get angle 86 * 87 * \return angle in radians 88 */ 84 89 float GetAngle() const; 85 90 int GetAxis() const; -
trunk/lib/FlairCore/src/cvmatrix.h
r15 r147 55 55 * Construct an io_data representing a CvMat. \n 56 56 * It uses a cvmatrix_descriptor to get size and elements' names. \n 57 * Names are used for graphs and logs. 57 * Names are used for graphs and logs. \n 58 * All values are initialized to 0. 58 59 * 59 60 * \param parent parent … … 71 72 * 72 73 * Construct an io_data representing a CvMat. \n 73 * Elements are unamed. 74 * Elements are unamed. \n 75 * All values are initialized to 0. 74 76 * 75 77 * \param parent parent -
trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp
r15 r147 47 47 f = new PoleFilter(order); 48 48 49 if (T->Value() != 0) 49 if (T->Value() != 0) { 50 50 f->setup(1. / T->Value(), cutoff->Value()); 51 } 52 51 53 f->reset(); 52 54 53 55 first_update = true; 56 this->order=order; 54 57 } 55 58 … … 59 62 float result; 60 63 cvmatrix *input = (cvmatrix *)data; 61 62 if (T->ValueChanged() || cutoff->ValueChanged()) { 64 float delta_t; 65 66 if (T->ValueChanged()) { 63 67 if (T->Value() != 0) { 64 68 f->setup(1. / T->Value(), cutoff->Value()); 65 } else { 66 first_update = true; 69 settingsChanged(input->Value(0, 0)); 67 70 } 68 71 } 69 72 73 if (T->Value() == 0) { 74 delta_t = (float)(data->DataTime() - previous_time) / 1000000000.; 75 f->setup(1. / delta_t, cutoff->Value()); 76 } else { 77 delta_t=T->Value(); 78 } 79 70 80 // on prend une fois pour toute les mutex et on fait des accès directs 71 81 output->GetMutex(); 72 82 input->GetMutex(); 73 83 74 if (T->Value() == 0) { 75 float delta_t = (float)(data->DataTime() - previous_time) / 1000000000.; 84 if (cutoff->ValueChanged()) { 76 85 f->setup(1. / delta_t, cutoff->Value()); 86 settingsChanged(input->ValueNoMutex(0, 0)); 77 87 } 78 88 … … 90 100 previous_time = data->DataTime(); 91 101 } 102 103 //ne gere pas les oscillations (s'arrete des qu'une valeure est bonne a 5%) 104 void ButterworthLowPass_impl::settingsChanged(float inputValue) { 105 float result=f->filter(inputValue); 106 107 while(result<inputValue*0.95 || result>inputValue*1.05) { 108 result=f->filter(inputValue); 109 } 110 } -
trunk/lib/FlairFilter/src/EulerDerivative.h
r15 r147 45 45 * IODevice::ProcessUpdate is called. \n 46 46 * The optional init_value parameters allow to specify 47 * the size of the input datas and itsinital values.47 * the size of the input datas and output inital values. 48 48 * If unspecified, a 1*1 size is used, and values are 49 49 * initialized with 0. … … 52 52 * \param position position to display settings 53 53 * \param name name 54 * \param init_value initial value 54 * \param init_value initial value, it is safe to destroy it after calling this constructor 55 55 */ 56 56 EulerDerivative(const core::IODevice *parent, -
trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp
r15 r147 33 33 const cvmatrix *init_value) { 34 34 first_update = true; 35 36 if (init_value != NULL) { 37 // init output matrix of same size as init 38 cvmatrix_descriptor *desc =new cvmatrix_descriptor(init_value->Rows(), init_value->Cols()); 35 39 36 if (init_value != NULL) { 37 prev_value = (cvmatrix *)init_value; 40 for (int i = 0; i < init_value->Rows(); i++) { 41 for (int j = 0; j < init_value->Cols(); j++) { 42 desc->SetElementName(i, j, init_value->Name(i, j)); 43 } 44 } 45 output = new cvmatrix(self, desc,init_value->GetDataType().GetElementDataType(), name); 46 for (int i = 0; i < init_value->Rows(); i++) { 47 for (int j = 0; j < init_value->Cols(); j++) { 48 output->SetValue(i, j, init_value->Value(i,j)); 49 } 50 } 38 51 } else { 39 52 // if NULL, assume dimension 1, and init=0 40 53 cvmatrix_descriptor *desc = new cvmatrix_descriptor(1, 1); 41 54 desc->SetElementName(0, 0, "output"); 42 prev_value= new cvmatrix(self, desc, floatType, name);43 prev_value->SetValue(0, 0, 0);55 output = new cvmatrix(self, desc, floatType, name); 56 output->SetValue(0, 0, 0); 44 57 } 58 59 60 cvmatrix_descriptor *desc = new cvmatrix_descriptor(output->Rows(), output->Cols()); 61 prev_value = new cvmatrix(self, desc, output->GetDataType().GetElementDataType(), name); 62 45 63 46 64 // init UI … … 48 66 T = new DoubleSpinBox(reglages_groupbox->NewRow(), "period, 0 for auto:", 49 67 " s", 0, 1, 0.01); 50 51 // init output matrix of same size as init52 cvmatrix_descriptor *desc =53 new cvmatrix_descriptor(prev_value->Rows(), prev_value->Cols());54 55 for (int i = 0; i < prev_value->Rows(); i++) {56 for (int j = 0; j < prev_value->Cols(); j++) {57 desc->SetElementName(i, j, prev_value->Name(i, j));58 }59 }60 61 output = new cvmatrix(self, desc,62 prev_value->GetDataType().GetElementDataType(), name);63 68 } 64 69 … … 76 81 for (int i = 0; i < input->Rows(); i++) { 77 82 for (int j = 0; j < input->Cols(); j++) { 78 output->SetValueNoMutex(i, j, prev_value->ValueNoMutex(i, j));79 83 prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 80 84 } -
trunk/lib/FlairFilter/src/LowPassFilter.h
r15 r147 52 52 * \param position position to display settings 53 53 * \param name name 54 * \param init_value initial value 54 * \param init_value initial value, it is safe to destroy it after calling this constructor 55 55 */ 56 56 LowPassFilter(const core::IODevice *parent, -
trunk/lib/FlairFilter/src/LowPassFilter_impl.cpp
r15 r147 35 35 string name, 36 36 const cvmatrix *init_value) { 37 first_update = true;38 37 39 38 if (init_value != NULL) { 40 prev_value = (cvmatrix *)init_value; 39 // init output matrix of same size as init 40 cvmatrix_descriptor *desc =new cvmatrix_descriptor(init_value->Rows(), init_value->Cols()); 41 42 for (int i = 0; i < init_value->Rows(); i++) { 43 for (int j = 0; j < init_value->Cols(); j++) { 44 desc->SetElementName(i, j, init_value->Name(i, j)); 45 } 46 } 47 output = new cvmatrix(self, desc,init_value->GetDataType().GetElementDataType(), name); 48 for (int i = 0; i < init_value->Rows(); i++) { 49 for (int j = 0; j < init_value->Cols(); j++) { 50 output->SetValue(i, j, init_value->Value(i,j)); 51 } 52 } 41 53 } else { 42 54 // if NULL, assume dimension 1, and init=0 43 55 cvmatrix_descriptor *desc = new cvmatrix_descriptor(1, 1); 44 56 desc->SetElementName(0, 0, "output"); 45 prev_value= new cvmatrix(self, desc, floatType, name);46 prev_value->SetValue(0, 0, 0);57 output = new cvmatrix(self, desc, floatType, name); 58 output->SetValue(0, 0, 0); 47 59 } 48 60 … … 53 65 freq = new DoubleSpinBox(reglages_groupbox->NewRow(), "cutoff frequency", 54 66 " Hz", 0, 10000, 0.1, 2, 1); 55 56 // init output matrix of same size as init 57 cvmatrix_descriptor *desc = 58 new cvmatrix_descriptor(prev_value->Rows(), prev_value->Cols()); 59 60 for (int i = 0; i < prev_value->Rows(); i++) { 61 for (int j = 0; j < prev_value->Cols(); j++) { 62 desc->SetElementName(i, j, prev_value->Name(i, j)); 63 } 64 } 65 66 output = new cvmatrix(self, desc, 67 prev_value->GetDataType().GetElementDataType(), name); 68 69 output->SetValue(0, 0, 0); 67 68 previous_time=GetTime(); 70 69 } 71 70 … … 74 73 void LowPassFilter_impl::UpdateFrom(const io_data *data) { 75 74 float delta_t; 76 float result;77 75 cvmatrix *input = (cvmatrix *)data; 78 76 … … 81 79 input->GetMutex(); 82 80 83 if (first_update == true) { 84 for (int i = 0; i < input->Rows(); i++) { 85 for (int j = 0; j < input->Cols(); j++) { 86 output->SetValueNoMutex(i, j, prev_value->ValueNoMutex(i, j)); 87 prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 88 } 89 } 90 first_update = false; 81 if (T->Value() == 0) { 82 delta_t = (float)(data->DataTime() - previous_time) / 1000000000.; 91 83 } else { 92 if (T->Value() == 0) { 93 delta_t = (float)(data->DataTime() - previous_time) / 1000000000.; 94 } else { 95 delta_t = T->Value(); 96 } 97 for (int i = 0; i < input->Rows(); i++) { 98 for (int j = 0; j < input->Cols(); j++) { 99 100 if (freq->Value() != 0) { 101 output->SetValueNoMutex(i, j, (1 - 2 * PI * freq->Value() * delta_t) * 102 prev_value->ValueNoMutex(i, j) + 103 2 * PI * freq->Value() * delta_t * 104 input->ValueNoMutex(i, j)); 105 } else { 106 output->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 107 } 108 prev_value->SetValueNoMutex(i, j, output->ValueNoMutex(i, j)); 84 delta_t = T->Value(); 85 } 86 for (int i = 0; i < input->Rows(); i++) { 87 for (int j = 0; j < input->Cols(); j++) { 88 float cutoff=freq->Value(); 89 if (cutoff == 0 || freq->ValueChanged()) { 90 output->SetValueNoMutex(i, j, input->ValueNoMutex(i, j)); 91 } else { 92 output->SetValueNoMutex(i, j, (1 - 2 * PI * cutoff * delta_t) * 93 output->ValueNoMutex(i, j) + 94 2 * PI * cutoff * delta_t * 95 input->ValueNoMutex(i, j)); 109 96 } 110 97 } 111 98 } 99 112 100 input->ReleaseMutex(); 113 101 output->ReleaseMutex(); -
trunk/lib/FlairFilter/src/unexported/ButterworthLowPass_impl.h
r15 r147 128 128 129 129 private: 130 void settingsChanged(float inputValue); 130 131 flair::gui::DoubleSpinBox *cutoff, *T; 131 132 PoleFilter *f; 132 133 bool first_update; 133 134 flair::core::Time previous_time; 135 int order; 134 136 }; 135 137 -
trunk/lib/FlairFilter/src/unexported/LowPassFilter_impl.h
r15 r147 43 43 private: 44 44 flair::core::Time previous_time; 45 bool first_update;46 flair::core::cvmatrix *prev_value;47 45 flair::gui::DoubleSpinBox *freq, *T; 48 46 }; -
trunk/lib/FlairMeta/src/MetaVrpnObject.cpp
r135 r147 62 62 pbas = new LowPassFilter(this, GetVrpnClient()->GetLayout()->NewRow(), 63 63 name + " Passe bas", prev_value); 64 delete prev_value; 64 65 65 66 desc = new cvmatrix_descriptor(7, 1); … … 74 75 euler = new EulerDerivative(pbas, GetVrpnClient()->GetLayout()->NewRow(), 75 76 name + "_euler", prev_value); 77 delete prev_value; 76 78 77 79 vx_opti_plot = new DataPlot1D(GetPlotTab()->NewRow(), "vx", -3, 3); -
trunk/lib/FlairSimulator/src/SimuCameraGL.cpp
r146 r147 191 191 192 192 shmem->Write(buf, width * height * 3); 193 Printf("écriture faite!\n");194 193 } 195 194
Note:
See TracChangeset
for help on using the changeset viewer.