PROPT Path Tracking Robot (Two-Phase): Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
<math> J = \int_0^{2} (\sum_{i=1}^{2} (w_i*(q_i(t) - q_{i,ref})^2) + \sum_{i=1}^{2} (w_{2+i}*(\frac{dq}{dt}_i(t) - \frac{dq}{dt}_{i,ref})^2) \mathrm{d}t </math> | <math> J = \int_0^{2} (\sum_{i=1}^{2} (w_i*(q_i(t) - q_{i,ref})^2) + \sum_{i=1}^{2} (w_{2+i}*(\frac{dq}{dt}_i(t) - \frac{dq}{dt}_{i,ref})^2) \mathrm{d}t </math> | ||
subject to: | subject to: | ||
<math> \frac{d^2q_1}{dt^2} = u_1 </math> | <math> \frac{d^2q_1}{dt^2} = u_1 </math> | ||
<math> \frac{d^2q_2}{dt^2} = u_2 </math> | <math> \frac{d^2q_2}{dt^2} = u_2 </math> | ||
A transformation gives: | A transformation gives: | ||
<math> \frac{dx_1}{dt} = x_3 </math> | <math> \frac{dx_1}{dt} = x_3 </math> | ||
<math> \frac{dx_2}{dt} = x_4 </math> | <math> \frac{dx_2}{dt} = x_4 </math> | ||
<math> \frac{dx_3}{dt} = u_1 </math> | <math> \frac{dx_3}{dt} = u_1 </math> | ||
<math> \frac{dx_4}{dt} = u_2 </math> | <math> \frac{dx_4}{dt} = u_2 </math> | ||
<math> x_{1:4}(0) = [0 \ 0 \ 0.5 \ 0] </math> | <math> x_{1:4}(0) = [0 \ 0 \ 0.5 \ 0] </math> | ||
<math> x_{1:4}(2) = [0.5 \ 0.5 \ 0 \ 0.5] </math> | <math> x_{1:4}(2) = [0.5 \ 0.5 \ 0 \ 0.5] </math> | ||
<math> w_{1:4} = [100 \ 100 \ 500 \ 500] </math> | <math> w_{1:4} = [100 \ 100 \ 500 \ 500] </math> | ||
<math> x_1{1,ref} = \frac{t}{2} \ (0<t<1), \ \frac{1}{2} \ (1<t<2) </math> | <math> x_1{1,ref} = \frac{t}{2} \ (0<t<1), \ \frac{1}{2} \ (1<t<2) </math> | ||
<math> x_2{1,ref} = 0 \ (0<t<1), \ \frac{t-1}{2} \ (1<t<2) </math> | <math> x_2{1,ref} = 0 \ (0<t<1), \ \frac{t-1}{2} \ (1<t<2) </math> | ||
<math> x_3{1,ref} = \frac{1}{2} \ (0<t<1), \ 0 \ (1<t<2) </math> | <math> x_3{1,ref} = \frac{1}{2} \ (0<t<1), \ 0 \ (1<t<2) </math> | ||
<math> x_4{1,ref} = 0 \ (0<t<1), \ \frac{1}{2} \ (1<t<2) </math> | <math> x_4{1,ref} = 0 \ (0<t<1), \ \frac{1}{2} \ (1<t<2) </math> | ||
<math> |u| < 10 </math> | <math> |u| < 10 </math> | ||
<source lang="matlab"> | <source lang="matlab"> |
Revision as of 08:11, 9 November 2011
This page is part of the PROPT Manual. See PROPT Manual. |
User's Guide for DIRCOL
2.7 Optimal path tracking for a simple robot. A robot with two rotational joints and simplified equations of motion has to move along a prescribed path with constant velocity.
Problem Formulation
Find u over t in [0; 2 ] to minimize
subject to:
A transformation gives:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
t_F = 2;
toms t1
p1 = tomPhase('p1', t1, 0, t_F/2, 25);
toms t2
p2 = tomPhase('p2', t2, t_F/2, t_F/2, 25);
setPhase(p1);
tomStates x1p1 x2p1 x3p1 x4p1
tomControls u1p1 u2p1
% Box constraints
cbox1 = {-10 <= collocate(u1p1) <= 10
-10 <= collocate(u2p1) <= 10};
% Boundary constraints
w1 = 100; w2 = 100;
w3 = 500; w4 = 500;
err1p1 = w1*(x1p1-t1/2).^2;
err2p1 = w2*(x2p1).^2;
err3p1 = w3*(x3p1-1/2).^2;
err4p1 = w4*(x4p1).^2;
cbnd1 = initial({x1p1 == 0; x2p1 == 0
x3p1 == 0.5; x4p1 == 0});
% ODEs and path constraints
ceq1 = collocate({dot(x1p1) == x3p1
dot(x2p1) == x4p1; dot(x3p1) == u1p1
dot(x4p1) == u2p1});
% Objective
objective1 = integrate(err1p1+err2p1+err3p1+err4p1);
% Phase 2
setPhase(p2);
tomStates x1p2 x2p2 x3p2 x4p2
tomControls u1p2 u2p2
% Box constraints
cbox2 = {-10 <= collocate(u1p2) <= 10
-10 <= collocate(u2p2) <= 10};
% Boundary constraints
err1p2 = w1*(x1p2-1/2).^2;
err2p2 = w2*(x2p2-(t2-1)/2).^2;
err3p2 = w3*(x3p2).^2;
err4p2 = w4*(x4p2-1/2).^2;
cbnd2 = final({x1p2 == 0.5
x2p2 == 0.5
x3p2 == 0
x4p2 == 0.5});
% ODEs and path constraints
ceq2 = collocate({
dot(x1p2) == x3p2
dot(x2p2) == x4p2
dot(x3p2) == u1p2
dot(x4p2) == u2p2});
% Objective
objective2 = integrate(err1p2+err2p2+err3p2+err4p2);
% Objective
objective = objective1 + objective2;
% Link phase
link = {final(p1,x1p1) == initial(p2,x1p2)
final(p1,x2p1) == initial(p2,x2p2)
final(p1,x3p1) == initial(p2,x3p2)
final(p1,x4p1) == initial(p2,x4p2)};
Solve the problem
options = struct;
options.name = 'Path Tracking Robot (Two-Phase)';
options.solver = 'sqopt7';
constr = {cbox1, cbnd1, ceq1, cbox2, cbnd2, ceq2, link};
solution = ezsolve(objective, constr, [], options);
t = subs(collocate(p1,t1),solution);
t = [t;subs(collocate(p2,t2),solution)];
x1 = subs(collocate(p1,x1p1),solution);
x1 = [x1;subs(collocate(p2,x1p2),solution)];
x2 = subs(collocate(p1,x2p1),solution);
x2 = [x2;subs(collocate(p2,x2p2),solution)];
x3 = subs(collocate(p1,x3p1),solution);
x3 = [x3;subs(collocate(p2,x3p2),solution)];
x4 = subs(collocate(p1,x4p1),solution);
x4 = [x4;subs(collocate(p2,x4p2),solution)];
u1 = subs(collocate(p1,u1p1),solution);
u1 = [u1;subs(collocate(p2,u1p2),solution)];
u2 = subs(collocate(p1,u2p1),solution);
u2 = [u2;subs(collocate(p2,u2p2),solution)];
Problem type appears to be: qp Time for symbolic processing: 0.25294 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: 1: Path Tracking Robot (Two-Phase) f_k 1.049952991376699200 sum(|constr|) 0.000000000261665098 f(x_k) + sum(|constr|) 1.049952991638364300 f(x_0) 0.000000000000000000 Solver: SQOPT. EXIT=0. INFORM=1. SQOPT 7.2-5 QP solver Optimality conditions satisfied Iter 297 CPU time: 0.046800 sec. Elapsed time: 0.123000 sec.
Plot result
subplot(2,1,1);
plot(t,x1,'*-',t,x2,'*-',t,x3,'*-',t,x4,'*-');
legend('x1','x2','x3','x4');
title('Path Tracking Robot state variables');
subplot(2,1,2);
plot(t,u1,'*-',t,u2,'*-');
legend('u1','u2');
title('Path Tracking Robot control variables');