Changeset 15 in flair-src for trunk/lib/FlairFilter/src/NestedSat_impl.cpp
- Timestamp:
- 04/08/16 15:40:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairFilter/src/NestedSat_impl.cpp
r10 r15 28 28 using namespace flair::filter; 29 29 30 NestedSat_impl::NestedSat_impl(NestedSat * self,const LayoutPosition* position,string name)31 {32 this->self=self;33 k=1;30 NestedSat_impl::NestedSat_impl(NestedSat *self, const LayoutPosition *position, 31 string name) { 32 this->self = self; 33 k = 1; 34 34 35 //init matrix36 self->input=new cvmatrix(self,3,1,floatType,name);35 // init matrix 36 self->input = new cvmatrix(self, 3, 1, floatType, name); 37 37 38 GroupBox* reglages_groupbox=new GroupBox(position,name); 39 sat=new DoubleSpinBox(reglages_groupbox->NewRow(),"sat ref:",0,9000000,1); 40 kp=new DoubleSpinBox(reglages_groupbox->NewRow(),"kp:",0,9000000,1); 41 dsat=new DoubleSpinBox(reglages_groupbox->NewRow(),"sat dref:",0,9000000,1); 42 kd=new DoubleSpinBox(reglages_groupbox->NewRow(),"kd:",0,9000000,0.1); 43 usat=new DoubleSpinBox(reglages_groupbox->NewRow(),"sat u:",0,1,.1); 38 GroupBox *reglages_groupbox = new GroupBox(position, name); 39 sat = 40 new DoubleSpinBox(reglages_groupbox->NewRow(), "sat ref:", 0, 9000000, 1); 41 kp = new DoubleSpinBox(reglages_groupbox->NewRow(), "kp:", 0, 9000000, 1); 42 dsat = new DoubleSpinBox(reglages_groupbox->NewRow(), "sat dref:", 0, 9000000, 43 1); 44 kd = new DoubleSpinBox(reglages_groupbox->NewRow(), "kd:", 0, 9000000, 0.1); 45 usat = new DoubleSpinBox(reglages_groupbox->NewRow(), "sat u:", 0, 1, .1); 44 46 } 45 47 46 NestedSat_impl::~NestedSat_impl(void) 47 { 48 NestedSat_impl::~NestedSat_impl(void) {} 49 50 void NestedSat_impl::UpdateFrom(const io_data *data) { 51 float cons, dcons, law; 52 cvmatrix *input = (cvmatrix *)data; 53 54 input->GetMutex(); 55 56 cons = Sat(input->ValueNoMutex(0, 0), k * sat->Value()); 57 dcons = (cons - input->ValueNoMutex(1, 0)) * kp->Value(); 58 dcons = Sat(dcons, k * dsat->Value()); 59 law = (input->ValueNoMutex(2, 0) - dcons) * kd->Value(); 60 law = Sat(law, usat->Value()); 61 62 input->ReleaseMutex(); 63 64 self->output->SetValue(0, 0, law); 65 self->output->SetDataTime(data->DataTime()); 48 66 } 49 67 50 void NestedSat_impl::UpdateFrom(const io_data *data) 51 { 52 float cons,dcons,law; 53 cvmatrix *input=(cvmatrix*)data; 54 55 input->GetMutex(); 56 57 cons=Sat(input->ValueNoMutex(0,0),k*sat->Value()); 58 dcons=(cons-input->ValueNoMutex(1,0))*kp->Value(); 59 dcons=Sat(dcons,k*dsat->Value()); 60 law=(input->ValueNoMutex(2,0)-dcons)*kd->Value(); 61 law=Sat(law,usat->Value()); 62 63 input->ReleaseMutex(); 64 65 self->output->SetValue(0,0,law); 66 self->output->SetDataTime(data->DataTime()); 68 float NestedSat_impl::Sat(float value, float borne) { 69 if (value < -borne) 70 return -borne; 71 if (value > borne) 72 return borne; 73 return value; 67 74 } 68 69 float NestedSat_impl::Sat(float value,float borne)70 {71 if(value<-borne) return -borne;72 if(value>borne) return borne;73 return value;74 }
Note:
See TracChangeset
for help on using the changeset viewer.