PROPT Path Tracking Robot: 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

Notice.png

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

toms t
p = tomPhase('p', t, 0, 2, 100, [], 'fem1s'); % Use splines with FEM constraints
%p = tomPhase('p', t, 0, 2, 100, [], 'fem1');  % Use linear finite elements
%p = tomPhase('p', t, 0, 2, 100); % Use Gauss point collocation
setPhase(p);

tomStates x1 x2 x3 x4
tomControls u1 u2

% Box constraints
cbox = {
    -10 <= collocate(u1) <= 10
    -10 <= collocate(u2) <= 10};

% Boundary constraints
cbnd = {initial({x1 == 0; x2 == 0
    x3 == 0.5; x4 == 0})
    final({x1 == 0.5; x2 == 0.5
    x3 == 0; x4 == 0.5})};

% ODEs and path constraints
w1 = 100; w2 = 100;
w3 = 500; w4 = 500;

err1 = w1*(x1-t/2.*(t<1)-1/2*(t>=1)).^2;
err2 = w2*(x2-(t-1)/2.*(t>=1)).^2;
err3 = w3*(x3-1/2*(t<1)).^2;
err4 = w4*(x4-1/2*(t>=1)).^2;

toterr = integrate(err1+err2+err3+err4);

ceq = collocate({
    dot(x1) == x3
    dot(x2) == x4
    dot(x3) == u1
    dot(x4) == u2});

% Objective
objective = toterr;

Solve the problem

options = struct;
options.name = 'Path Tracking Robot';
solution = ezsolve(objective, {cbox, cbnd, ceq}, [], options);
t  = subs(icollocate(t),solution);
x1 = subs(icollocate(x1),solution);
x2 = subs(icollocate(x2),solution);
x3 = subs(icollocate(x3),solution);
x4 = subs(icollocate(x4),solution);
u1 = subs(icollocate(u1),solution);
u2 = subs(icollocate(u2),solution);
Problem type appears to be: qp
Time for symbolic processing: 0.16121 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem:  1: Path Tracking Robot                f_k       1.031157512955303400
                                       sum(|constr|)      0.000000055682846425
                              f(x_k) + sum(|constr|)      1.031157568638149800
                                              f(x_0)      0.000000000000000000

Solver: CPLEX.  EXIT=0.  INFORM=1.
CPLEX Barrier QP solver
Optimal solution found

FuncEv   10 GradEv   10 ConstrEv   10 Iter   10 
CPU time: 0.249602 sec. Elapsed time: 0.061000 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');

PathTrackingRobot 01.png