Changeset 256 in flair-src


Ignore:
Timestamp:
Jul 23, 2018, 5:03:47 PM (3 years ago)
Author:
Sanahuja Guillaume
Message:

add saturation to euler derivative

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ReleaseNotes

    r237 r256  
    66- file_ui com is only created when sending logs from uav to gcs (reduce overall data exchange between the 2)
    77- resolved https://devel.hds.utc.fr/projects/flair/ticket/37
     8- added a saturation to EulerDerivative: saturate in case of numerical problems
    89
    910-----------------------------------------------------------
  • trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp

    r223 r256  
    6060 
    6161  cvmatrix_descriptor *desc = new cvmatrix_descriptor(output->Rows(), output->Cols());
    62   prev_value = new Matrix(self, desc, output->GetDataType().GetElementDataType(), name);
     62  prev_input = new Matrix(self, desc, output->GetDataType().GetElementDataType(), name);
     63  prev_output = new Matrix(self, desc, output->GetDataType().GetElementDataType(), name);
     64  delete desc;
    6365
    6466
    6567  // init UI
    6668  GroupBox *reglages_groupbox = new GroupBox(position, name);
    67   T = new DoubleSpinBox(reglages_groupbox->NewRow(), "period, 0 for auto:",
    68                         " s", 0, 1, 0.01);
     69  T = new DoubleSpinBox(reglages_groupbox->NewRow(), "period, 0 for auto:"," s", 0, 1, 0.01);
     70  sat = new DoubleSpinBox(reglages_groupbox->NewRow(), "saturation, -1 to disable:",-1,100000,1,1,-1);
    6971}
    7072
     
    8789    for (int i = 0; i < input->Rows(); i++) {
    8890      for (int j = 0; j < input->Cols(); j++) {
    89         prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
     91        prev_input->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
    9092      }
    9193    }
     
    101103      for (int i = 0; i < input->Rows(); i++) {
    102104        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));
     105          float result=(input->ValueNoMutex(i, j) - prev_input->ValueNoMutex(i, j)) / delta_t;
     106          if(sat->Value()!=-1) {
     107            if(result>sat->Value() && result>0) result=sat->Value();
     108            if(result<-sat->Value() && result<0) result=-sat->Value();
     109          }/* filter by acc
     110          float acc=result-prev_output->ValueNoMutex(i, j)/delta_t;
     111          if(acc>20 || acc<-20)  {
     112            printf("%s %f\n",self->ObjectName().c_str(),acc);
     113          } else {*/
     114            output->SetValueNoMutex(i, j, result);
     115          //}
     116          prev_output->SetValueNoMutex(i, j, result);
     117          prev_input->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
     118         
    107119        }
    108120      }
  • trunk/lib/FlairFilter/src/unexported/EulerDerivative_impl.h

    r223 r256  
    4444
    4545private:
    46   flair::gui::DoubleSpinBox *T;
     46  flair::gui::DoubleSpinBox *T,*sat;
    4747  bool first_update;
    48   flair::core::Matrix *prev_value;
     48  flair::core::Matrix *prev_input,*prev_output;
    4949  flair::filter::EulerDerivative *self;
    5050};
Note: See TracChangeset for help on using the changeset viewer.