## 26  Coloumb Friction 2

Minimum-Time Control of Systems With Coloumb Friction: Near Global Optima Via Mixed Integer Linear Programming, Brian J. Driessen, Structural Dynamics Department, Sandia National Labs.

4. Numerical Examples

### 26.1  Problem Formulation

Find u over t in [0; t_F ] to minimize

 J = tf

subject to:

m1*
 d2q1 dt2
= (−k1k2)*q1 + k2*q2 − mmu*sign(
 dq1 dt
) +u1
m2*
 d2q2 dt2
= k2*q1 − k2*q2 − mmu*sign(
 dq2 dt
) +u2
 q1:2(0) = [0  0]
 dq1:2 dt
0 = [−1  −2]
 q1:2(tf) = [1  2]
 dq1:2 dt
tf = [0  0]
 −4 <= u1:2 <= 4
 k1:2 = [0.95  0.85]
 m1:2 = [1.1  1.2]
 mmu = 1.0

Reference: [15]

### 26.2  Problem setup

```toms t
toms t_f

p = tomPhase('p', t, 0, t_f, 40, [], 'gauss');
setPhase(p);

tomStates q1 q1dot q2 q2dot
tomControls u1 u2

% Initial guess
x0 = {t_f == 1};

% Box constraints
cbox = {1.8 <= t_f <= 4
-4  <= collocate(u1) <= 4
-4  <= collocate(u2) <= 4};

% Boundary constraints
cbnd = {initial({q1 == 0; q1dot == -1
q2 == 0; q2dot == -2})
final({q1 == 1; q1dot == 0
q2 == 2; q2dot == 0})};

k1 = 0.95; k2 = 0.85;
m1 = 1.1;  m2 = 1.2;
mmu = 1;

% ODEs and path constraints
ceq = collocate({dot(q1) == q1dot
m1*dot(q1dot) == (-k1-k2)*q1+k2*q2-mmu*sign(q1dot)+u1
dot(q2)       == q2dot
m2*dot(q2dot) == k2*q1-k2*q2-mmu*sign(q2dot)+u2});

% Objective
objective = t_f;
```

### 26.3  Solve the problem

```options = struct;
options.name = 'Coloumb Friction 2';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t     = subs(collocate(t),solution);
q1    = subs(collocate(q1),solution);
q2    = subs(collocate(q2),solution);
q1dot = subs(collocate(q1dot),solution);
q2dot = subs(collocate(q2dot),solution);
u1    = subs(collocate(u1),solution);
u2    = subs(collocate(u2),solution);
q1dot_f = q1dot(end);
q2dot_f = q2dot(end);
```
```Problem type appears to be: lpcon
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2011-02-05
=====================================================================================
Problem: ---  1: Coloumb Friction 2             f_k       2.125397251986161700
sum(|constr|)      0.000006640472891742
f(x_k) + sum(|constr|)      2.125403892459053300
f(x_0)      1.800000000000000000

Solver: snopt.  EXIT=0.  INFORM=1.
SNOPT 7.2-5 NLP code
Optimality conditions satisfied

FuncEv    1 ConstrEv   33 ConJacEv   32 Iter   27 MinorIter  388
CPU time: 0.531250 sec. Elapsed time: 0.531000 sec.
```

### 26.4  Plot result

```subplot(2,1,1)
plot(t,q1,'*-',t,q2,'*-');
legend('q1','q2');
title(sprintf('Coloumb Friction 2, q1dot_f = %g, q2dot_f = %g',q1dot_f,q2dot_f));

subplot(2,1,2)
plot(t,u1,'+-',t,u2,'+-');
legend('u1','u2');
title('Coloumb Friction 2 controls');
```