PROPT Two-Link Robotic Arm: Difference between revisions
From TomWiki
Jump to navigationJump to search
(Created page with "{{Part Of Manual|title=the PROPT Manual|link=PROPT Manual}} ITERATIVE DYNAMIC PROGRAMMING, REIN LUUS 12.4.2 Example 2: Two-link robotic arm CHAPMAN & HALL/CRC Monogr...") |
No edit summary |
||
Line 12: | Line 12: | ||
<math> J = t_F </math> | <math> J = t_F </math> | ||
subject to: | subject to: | ||
<math> \frac{dx_1}{dt} = \frac{sin(x_3)*(\frac{9}{4}*cos(x_3)*x_1^2+2*x_2^2) + \frac{4}{3}*(u_1-u_2) - \frac{3}{2}*cos(x_3)*u_2 } {\frac{31}{36} + \frac{9}{4}*sin(x_3)^2} </math> | <math> \frac{dx_1}{dt} = \frac{sin(x_3)*(\frac{9}{4}*cos(x_3)*x_1^2+2*x_2^2) + \frac{4}{3}*(u_1-u_2) - \frac{3}{2}*cos(x_3)*u_2 } {\frac{31}{36} + \frac{9}{4}*sin(x_3)^2} </math> | ||
<math> \frac{dx_2}{dt} = -\frac{sin(x_3)*(\frac{7}{2}*x_1^2+\frac{9}{4}*cos(x3)*x_2^2) - \frac{7}{3}*u_2 + \frac{3}{2}*cos(x_3)*(u_1-u_2) }{\frac{31}{36} + \frac{9}{4}*sin(x_3)^2} </math> | <math> \frac{dx_2}{dt} = -\frac{sin(x_3)*(\frac{7}{2}*x_1^2+\frac{9}{4}*cos(x3)*x_2^2) - \frac{7}{3}*u_2 + \frac{3}{2}*cos(x_3)*(u_1-u_2) }{\frac{31}{36} + \frac{9}{4}*sin(x_3)^2} </math> | ||
<math> \frac{dx_3}{dt} = x_2-x_1 </math> | <math> \frac{dx_3}{dt} = x_2-x_1 </math> | ||
<math> \frac{dx_4}{dt} = x_1 </math> | <math> \frac{dx_4}{dt} = x_1 </math> | ||
The initial condition are: | The initial condition are: | ||
<math> x(0) = [0 \ 0 \ 0.5 \ 0] </math> | <math> x(0) = [0 \ 0 \ 0.5 \ 0] </math> | ||
<math> x(t_F) = [0 \ 0 \ 0.5 \ 0.522] </math> | <math> x(t_F) = [0 \ 0 \ 0.5 \ 0.522] </math> | ||
<math> -1 <= u(1:2) <= 1 </math> | <math> -1 <= u(1:2) <= 1 </math> | ||
<source lang="matlab"> | <source lang="matlab"> |
Revision as of 08:13, 9 November 2011
This page is part of the PROPT Manual. See PROPT Manual. |
ITERATIVE DYNAMIC PROGRAMMING, REIN LUUS
12.4.2 Example 2: Two-link robotic arm
CHAPMAN & HALL/CRC Monographs and Surveys in Pure and Applied Mathematics
Problem Formulation
Find u over t in [0; t_F ] to minimize
subject to:
The initial condition are:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t t_f
p = tomPhase('p', t, 0, t_f, 30);
setPhase(p);
tomStates x1 x2 x3 x4
tomControls u1 u2
% Initial guess
x0 = {t_f == 3
icollocate({x1 == 0; x2 == 0
x3 == 0.5; x4 == 0.522})
collocate({u1 == 1-2*t/t_f
u2 == 1-2*t/t_f})};
% Box constraints
cbox = {2.6 <= t_f <= 100
-1 <= collocate(u1) <= 1
-1 <= collocate(u2) <= 1};
% Boundary constraints
cbnd = {initial({x1 == 0; x2 == 0
x3 == 0.5; x4 == 0})
final({x1 == 0; x2 == 0
x3 == 0.5; x4 == 0.522})};
% ODEs and path constraints
ceq = collocate({
dot(x1) == ( sin(x3).*(9/4*cos(x3).*x1.^2+2*x2.^2) ...
+4/3*(u1-u2) - 3/2*cos(x3).*u2 )./ (31/36 + 9/4*sin(x3).^2)
dot(x2) == -( sin(x3).*(7/2*x1.^2 + 9/4*cos(x3).*x2.^2) ...
- 7/3*u2 + 3/2*cos(x3).*(u1-u2) )./ (31/36 + 9/4*sin(x3).^2)
dot(x3) == x2-x1
dot(x4) == x1});
% Objective
objective = t_f;
Solve the problem
options = struct;
options.name = 'Two Link Robotic Arm';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),solution);
x3 = subs(collocate(x3),solution);
x4 = subs(collocate(x4),solution);
u1 = subs(collocate(u1),solution);
u2 = subs(collocate(u2),solution);
Problem type appears to be: lpcon Time for symbolic processing: 0.41192 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Two Link Robotic Arm f_k 2.983364855223867600 sum(|constr|) 0.000000154455553673 f(x_k) + sum(|constr|) 2.983365009679421300 f(x_0) 3.000000000000000000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 20 ConJacEv 20 Iter 16 MinorIter 278 CPU time: 0.062400 sec. Elapsed time: 0.062000 sec.
Plot result
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-',t,x3,'*-',t,x4,'*-');
legend('x1','x2','x3','x4');
title('Two Link Robotic Arm state variables');
subplot(2,1,2)
plot(t,u1,'+-',t,u2,'+-');
legend('u1','u2');
title('Two Link Robotic Arm control');