|
88 | 88 | [F(j), z] = lugref(z, v(j), Fc, Fs, vs, sigma_0, sigma_1, sigma_2, ts); |
89 | 89 | end |
90 | 90 |
|
91 | | - % Start from t = 5, at the begining, the F response is unconsistent |
92 | | - % since we don't know hwo to initialize z. |
| 91 | + % Start from t = 5, at the begining, the F response is inconsistent |
| 92 | + % since we don't know how to initialize z. Here, we initialize z with 0. |
93 | 93 | plot(v(5/ts:end), F(5/ts:end), color(i)); |
94 | 94 | end |
95 | 95 |
|
|
112 | 112 |
|
113 | 113 | M = 1; % a unit mass |
114 | 114 |
|
115 | | -u_max = 0.95 * Fs; |
| 115 | +u_max = 0.95 * Fs; % 95 % |
116 | 116 | u1 = generate_ramp_signal(0, u_max, 10, ts); |
117 | 117 | u2 = generate_ramp_signal(u_max, u_max, 5, ts); |
118 | 118 | u3 = generate_ramp_signal(u_max, -u_max, 20, ts); |
119 | 119 | u4 = generate_ramp_signal(-u_max, -u_max, 5, ts); |
120 | 120 | u5 = generate_ramp_signal(-u_max, u_max, 20, ts); |
121 | 121 | u6 = generate_ramp_signal(u_max, u_max, 5, ts); |
122 | 122 |
|
123 | | -u = [u1 u2 u3 u4 u5 u6]; |
| 123 | +u = [u1 u2 u3 u4 u5 u6]; % put them together |
124 | 124 |
|
| 125 | +% Some initializations |
125 | 126 | F = 0; |
126 | 127 | z = 0; |
127 | 128 | x_0 = 0; |
128 | 129 | v = 0; |
129 | 130 |
|
| 131 | +% Do the simulation for all input u |
130 | 132 | for i = 1:length(u) |
131 | 133 | [F(i), z] = lugref(z, v, Fc, Fs, vs, sigma_0, sigma_1, sigma_2, ts); |
132 | 134 |
|
|
151 | 153 |
|
152 | 154 | clear F v u u1 u2 u3 u4 u5 u6; |
153 | 155 |
|
154 | | -k = 2; |
| 156 | +k = 2; % stiffness k = 2 N/m |
155 | 157 |
|
156 | | -ts = 1e-6; % 1e-4 fails!, very stiff system, needs a better ODE solver |
| 158 | +ts = 1e-6; % 1e-4 fails, this is very stiff system, we need a better ODE solver |
157 | 159 | time_span = 30; |
158 | 160 | t = 0 : ts : time_span; |
159 | 161 |
|
| 162 | +% generate_ramp_signal(min_val, max_val, t_max, ts) |
| 163 | +% The velocity is 0.1 m/s, it means if we start from t=0 to t=time_span |
| 164 | +% then our travel distace is 0.1*time_span |
160 | 165 | y = generate_ramp_signal(0, time_span*0.1, time_span, ts); |
161 | | -x = 0; |
162 | 166 |
|
| 167 | +% Some initializations |
| 168 | +x = 0; |
163 | 169 | z = 0; |
164 | 170 | x_0 = 0; |
165 | 171 | v = 0; |
166 | 172 |
|
| 173 | +% Do the simulation |
167 | 174 | for i = 1:length(y) |
168 | 175 | [F(i), z] = lugref(z, v, Fc, Fs, vs, sigma_0, sigma_1, sigma_2, ts); |
169 | 176 | u_spring = k*(y(i) - x(i)); |
|
175 | 182 | x_0 = x(i+1); |
176 | 183 | end |
177 | 184 |
|
178 | | -% compute the speed of the unit-mass |
| 185 | +% Compute the speed of the unit-mass |
179 | 186 | x_dot = gradient(x)/ts; |
180 | 187 |
|
181 | 188 | figure |
|
218 | 225 | % As soon as we detect the first negative gradient of the force, we must |
219 | 226 | % stop. |
220 | 227 |
|
221 | | -ts = 1e-6; % very stiff system, needs a better ODE solver |
| 228 | +ts = 1e-6; % very stiff system, we need a better ODE solver |
222 | 229 | time_span = 2; |
223 | 230 | t = 0 : ts : time_span; |
224 | 231 |
|
225 | 232 | M = 1; % a unit mass |
226 | 233 |
|
| 234 | +% I am just guessing from Fig. 4 |
227 | 235 | F_rate = [1 2 3 4 5 10 20 30 40 45 50]; |
228 | 236 |
|
229 | 237 | for j = 1 : length(F_rate) |
230 | 238 |
|
| 239 | + % Always clear up the old values |
231 | 240 | clear F v x x_dot |
232 | 241 |
|
233 | 242 | u = generate_ramp_signal(0, F_rate(j)*time_span, time_span, ts); |
|
246 | 255 |
|
247 | 256 | x_0 = x(i); |
248 | 257 |
|
| 258 | + % When motion occurs, the resulting force suddenly drops |
| 259 | + % See Fig. 6 (bottom figure) |
249 | 260 | if i > 1 && (F(i)-F(i-1)) < 0 |
250 | 261 | break; |
251 | 262 | end |
|
278 | 289 | % Desired position for the mass, its intial position is x = 0 |
279 | 290 | xd = 1; |
280 | 291 |
|
| 292 | +% Some initializations |
281 | 293 | z = 0; |
282 | 294 | x_0 = 0; |
283 | 295 | v = 0; |
284 | 296 | x = x_0; |
285 | 297 |
|
| 298 | +% The integral of error with respect to time |
286 | 299 | int_e = 0; |
287 | 300 |
|
288 | 301 | for i = 1:length(t) |
|
0 commit comments