Changeset 13 for trunk/extremum_seeking/esc_nn/src
- Timestamp:
- 08/29/12 16:52:52 (12 years ago)
- Location:
- trunk/extremum_seeking/esc_nn/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/extremum_seeking/esc_nn/src/nn_esc_1d.cpp
r5 r13 134 134 135 135 } 136 137 void NNESC1D::reset(){ 138 w_switch_old_ = 0; 139 a_switch_old_ = A; 140 yr_ = 0; 141 min_peak_ = 0; 142 vel_ref_ = 0; 143 w_switch_ = 0; 144 min_peak_detect_init_ = false; 145 } -
trunk/extremum_seeking/esc_nn/src/nn_esc_2d.cpp
r5 r13 20 20 ddelta1_ = 0; 21 21 ddelta2_ = 0; 22 ddelta 2_ = 0;22 ddelta3_ = 0; 23 23 delta_ = 0; 24 24 B_ = 0; … … 51 51 monitor_vals.push_back(min_peak_); 52 52 monitor_vals.push_back(w_switch_); 53 monitor_vals.push_back(yr_+ddelta1_); 54 monitor_vals.push_back(yr_+ddelta2_); 55 monitor_vals.push_back(yr_+ddelta3_); 56 monitor_vals.push_back(yr_+delta_); 53 57 54 58 return monitor_vals; … … 61 65 monitor_names.push_back("minimum peak detector output"); 62 66 monitor_names.push_back("w switch value"); 67 monitor_names.push_back("threshold value 1"); 68 monitor_names.push_back("threshold value 2"); 69 monitor_names.push_back("threshold value 3"); 70 monitor_names.push_back("threshold value 4"); 63 71 64 72 return monitor_names; … … 75 83 ddelta1_ = ddelta1; 76 84 ddelta2_ = ddelta2; 77 ddelta 2_ = ddelta3;85 ddelta3_ = ddelta3; 78 86 delta_ = delta; 79 87 period_ = period; 80 88 w_switch_old_ = 0; 81 89 a_switch1_old_ = A_; 82 a_switch2_old_ = A_;90 a_switch2_old_ = 0; 83 91 a_switch3_old_ = 0; 84 92 vel_ref_.resize(2); … … 99 107 100 108 if(!min_peak_detect_init_){ 101 yr_ = obj_val; 109 min_peak_ = obj_val; 110 yr_ = min_peak_; 102 111 min_peak_detect_init_ = true; 103 112 } 104 113 105 114 double e = yr_ - obj_val; 106 vel_ref_[1] = aSwitch1(e)+aSwitch2(e); 107 vel_ref_[0] = aSwitch2(e)+aSwitch3(e); 108 min_peak_ = minPeakDetect(-e); 109 w_switch_ = wSwitch(-e); 115 double s[3]; 116 s[0] = aSwitch1(e); 117 s[1] = aSwitch2(e); 118 s[2] = aSwitch3(e); 119 120 vel_ref_[1] = s[0]+s[1]; 121 vel_ref_[0] = s[1]+s[2]; 122 123 min_peak_ = minPeakDetect(e); 124 w_switch_ = wSwitch(e); 110 125 yr_ = yr_ + (w_switch_+min_peak_)*period_; 126 111 127 return vel_ref_; 112 128 } 113 double NNESC2D::wSwitch(double e _minus){114 if(e _minus<-delta_){129 double NNESC2D::wSwitch(double e){ 130 if(e>delta_){ 115 131 w_switch_old_ = 0; 116 132 return 0; 117 133 } 118 else if(e _minus>delta_){134 else if(e<-delta_){ 119 135 w_switch_old_ = B_; 120 136 return B_; … … 125 141 } 126 142 127 double NNESC2D::minPeakDetect(double e _minus){128 if(e _minus>0)143 double NNESC2D::minPeakDetect(double e){ 144 if(e<=0) 129 145 return 0; 130 146 else … … 146 162 147 163 double NNESC2D::aSwitch2(double e){ 164 148 165 if( e < -ddelta2_ ){ 149 a_switch2_old_ = 0;150 return 0;151 }152 else if(e>ddelta2_){153 166 a_switch2_old_ = A_; 154 167 return A_; 168 169 } 170 else if(e>ddelta2_){ 171 a_switch2_old_ = 0; 172 return 0; 155 173 } 156 174 else … … 170 188 return a_switch3_old_; 171 189 } 190 191 void NNESC2D::reset(){ 192 w_switch_old_ = 0; 193 a_switch1_old_ = A_; 194 a_switch2_old_ = 0; 195 a_switch3_old_ = 0; 196 vel_ref_.resize(2); 197 vel_ref_[0] = 0; 198 vel_ref_[1] = 0; 199 yr_ = 0; 200 min_peak_ = 0; 201 w_switch_ = 0; 202 min_peak_detect_init_ = false; 203 initialized_ = true; 204 }
Note: See TracChangeset
for help on using the changeset viewer.