##
APPENDIX B - DYNAMICS OF TWO LINK MANIPULATORS

B.1 Equations of Motion

Work in Motion Planning generally requires that the forward and inverse dynamic equations be used. The equations of motion were formulated for the two link case using the Lagrange-Euler formulation. To ensure that the equations are quite general, they were formulated to include gravity and a payload mass, although neither is used in this thesis.

The computer algebra package Macsyma [Symbolics Inc., 1985] was used to do the algebra. This was done for two reasons. The extent of the calculations was large, and prone to errors if done by hand. Thus, Macsyma was used to help provide error free calculation of results. Also, a set of routines was available for reducing the number of terms in the expression. These routines also produce Fortran code with a near minimum number of mathematical operations.

B.2 Formulation Of The Equations of Motion:

Many techniques exist for determining the equations of motion [Shahinpoor, 1987][Fu, Gonzalez, Lee, 1987][Spong, Vidyasagar, 1989][Craig, 1986][Brady et. al., 1982]. For example, the Newton-Euler formulation involves determining equations of motion based on balanced forces acting upon each link. This method results in an equation for each body, or link in the robot, which makes the system of equations bulky and hard to work with. Another method, which provides easy formulation, is the Bond Graph method which describes a robot in terms of a ‘power flow graph’ [Shahinpoor 1987]. One disadvantage is that this method requires a sophisticated program to handle the Bond Graph representation. The ideal solution for this work is a set of explicit closed form equations. The Lagrange-Euler method uses the conservation of energy in a system, with a Lagrangian, to determine the equations of motion. This method works very well, and has a simple formulation, and therefore will be used for dynamic calculations in this thesis.

B.3 Lagrange-Euler Formulation:

The schematic for the manipulator is shown below.

Figure B.1: Schematic Diagram of Two Link Manipulator

The schematic shows two links and a payload. The first link has a mass ‘M1’ and a moment of inertia ‘I1’, the second link has a mass ‘M2’ and a moment of inertia ‘I2’. The payload has a mass ‘Mp’ and a moment of inertia ‘Ip’. The joint that drives the first link has an angular displacement of ‘θ1’ with a torque of ‘τ1’, and joint 2 has a displacement of ‘θ2’, and a torque of ‘τ2’. The entire system is exposed to a gravity of ‘g’.

The Lagrange-Euler dynamic formulation may be seen below, in a general form.

To simplify the equations, the moment of inertia will be assumed to be only effective in the plane of motion. Thus, the inertia tensor will be a diagonal matrix, and the inertial will only have an effect about the axis of rotation. The Inertia tensor is simplified further if the payload has a negligible moment of inertia, thus reducing the number of non-zero inertia tensors to two.

The specific values to be used with the formulation are shown below. These come from both the Robot Kinematics (Appendix A), and some basic definitions,

The definitions to this point are sufficient for Macsyma to deal with. The next stage is to use Macsyma to produce the equations of motion.

B.4 Macsyma

The computer algebra package, Macsyma [Symbolics Inc., 1985], was used to perform the mathematics of the problem. Macsyma is an artificial intelligence based tool capable of symbolic algebra, symbolic calculus, symbolic approximation methods, and numerical methods. Development of the package was begun in the late 1960’s at MIT, using the LISP programming language. The package became generally available to the public in the 1980’s.

B.5 Using Macsyma on the Lagrange-Euler Problem:

The problem was set up using a Macsyma batch file (this file follows, with comments). The file contains both the basic definitions, and operations that were done. The file instructs Macsyma to output the record of the work to another file. Excerpts from this batch file appear at the end of this appendix.

Macsyma will read the instructions from the batch file and operate on them. The resultant equations are quite lengthy, and thus some facilities available in Macsyma for equation reduction are used. The routines were standard for trigonometric and algebraic reduction (i.e., ‘trigsimp()’ and ‘ratsimp()’).

The Macsyma libraries do not necessarily produce optimum Fortran output. The Fortran output from Macsyma makes no attempt to reduce mathematical operations by replacing clusters of similar expressions, and it does not improve factorization. A set of computer algebra routines, developed by Budgell [1990a, 1990b], were used for removing common expressions. This optimization took place as a two part operation. The first stage involved removing terms that could be pre-calculated, as if they were constants. To do this a function called ‘crunch()’ was used which would replace the unused terms with variables, and place the terms in a list. The modified equation, and the new list of redundant expressions could then be converted to Fortran code. A second routine was used, called ‘fortbigopt()’. It would take an algebraic expression, replace redundant operations with a variable, then produce Fortran Code which evaluates the redundant expressions, and then evaluates the main expression.

• ‘crunch()’ will extract clusters of constants in an expression, and replace them with single terms.

• ‘fortbigopt()’ produces Fortran code for an equation, or list of equations. This code is headed by a set of pre-calculations of redundant terms. Then the actual calculation of the expressions.

The run time for the entire job (start to end) is under 5 minutes on a sun 3/260. The Fortran code produced had a near optimal run time, and may be viewed as part of the Macsyma output.

B.6 Macsyma Batch File:

/*************************************************************/

/* This is the calculation of the Lagrange-Euler formulation */

/* of the two link manipulator with a point mass payload */

/* This macsyma batch file was written by Hugh Jack */

/* June 18th, 1990. */

/*************************************************************/

/* Import Peter Budgell’s equation reduction routines */

load(“/usr/people/peter/beam/util”);

/* Define the column width as 132 and name an output file */

linel:132;

writefile(“lagrange.dump”);

/*************************************************************/

/* Define the general constraints associated with the */

/* manipulator, including joint coordinates, joint */

/* velocities, gravity. The dependency of the joint angles */

/* is also defined. */

/*************************************************************/

/* The gravity vector */

g:matrix([0],

[gravity],

[0]);

/* Define the time dependency of the joint angles */

depends([t1, t2], t);

/* Define the joint coordinate vector */

theta:matrix([t1],

[t2]);

/* Find the Joint Velocities as a function of the coordinates*/

theta_vel:diff(theta, t);

/*************************************************************/

/* Define the payload parameters, and find the Kinetic Energy*/

/* associated with it */

/*************************************************************/

/* Define the position of the payload in cartesian space */

/* and then as a vector */

x_cp:l1*cos(t1)+l2*cos(t1+t2);

y_cp:l1*sin(t1)+l2*sin(t1+t2);

z_cp:0;

xcp:matrix([x_cp],

[y_cp],

[z_cp]);

/* Find the jacobian of the manipulator payload */

jcp:matrix([diff(x_cp, t1), diff(x_cp, t2)],

[diff(y_cp, t1), diff(y_cp, t2)],

[diff(z_cp, t1), diff(z_cp, t2)]);

/* Find the velocity of the payload using the jacobian */

vcp:jcp.theta_vel;

/* The Inertia tensor for the payload */

ip:matrix([0, 0, 0],

[0, 0, 0],

[0, 0, 0]);

/* The angular velocity of the payload */

wp:matrix([0],

[0],

[diff(t1+t2, t)]);

/* The kinetic energy of the payload */

kp:mp/2*transpose(vcp).vcp + 1/2*transpose(wp).ip.wp;

/* The Potential Energy of the Payload */

pp:mp*transpose(g).xcp;

/*************************************************************/

/* Define the link 2 parameters, and find the Kinetic Energy */

/* associated with it */

/*************************************************************/

/* Define the position of joint 2 in cartesian space */

/* and then as a vector */

x_c2:l1*cos(t1)+l2/2*cos(t1+t2);

y_c2:l1*sin(t1)+l2/2*sin(t1+t2);

z_c2:0;

xc2:matrix([x_c2],

[y_c2],

[z_c2]);

/* Find the jacobian of the manipulator joint 2 */

jc2:matrix([diff(x_c2, t1), diff(x_c2, t2)],

[diff(y_c2, t1), diff(y_c2, t2)],

[diff(z_c2, t1), diff(z_c2, t2)]);

/* Find the velocity of joint 2 using the jacobian */

vc2:jc2.theta_vel;

/* The Inertia tensor for joint 2 */

i2:matrix([0, 0, 0],

[0, 0, 0],

[0, 0, i_2]);

/* The angular velocity of joint 2 */

w2:matrix([0],

[0],

[diff(t1+t2, t)]);

/* The kinetic energy of joint 2 */

k2:m2/2*transpose(vc2).vc2 + 1/2*transpose(w2).i2.w2;

/* The Potential Energy of joint 2 */

p2:m2*transpose(g).xc2;

/*************************************************************/

/* Define the link 1 parameters, and find the Kinetic Energy */

/* associated with it */

/*************************************************************/

/* Define the position of joint 1 in cartesian space */

/* and then as a vector */

x_c1:l1/2*cos(t1);

y_c1:l1/2*sin(t1);

z_c1:0;

xc1:matrix([x_c1],

[y_c1],

[z_c1]);

/* Find the jacobian of the manipulator joint 1 */

jc1:matrix([diff(x_c1, t1), diff(x_c1, t2)],

[diff(y_c1, t1), diff(y_c1, t2)],

[diff(z_c1, t1), diff(z_c1, t2)]);

/* Find the velocity of joint 1 using the jacobian */

vc1:jc1.theta_vel;

/* The Inertia tensor for joint 1 */

i1:matrix([0, 0, 0],

[0, 0, 0],

[0, 0, i_1]);

/* The angular velocity of joint 1 */

w1:matrix([0],

[0],

[diff(t1, t)]);

/* The kinetic energy of joint 1 */

k1:m1/2*transpose(vc1).vc1 + 1/2*transpose(w1).i1.w1;

/* The Potential Energy of joint 1 */

p1:m1*transpose(g).xc1;

/*************************************************************/

/* The lagrangian will be calculated here, for use in */

/* calculating the joint torques. */

/*************************************************************/

/* Find the lagrangian */

lagrange:expand(kp+k2+k1-pp-p2-p1);

/*************************************************************/

/* The joint torques are calculate here */

/*************************************************************/

/* Find torque 1 */

tor_1:diff(diff(lagrange, diff(t1, t)), t) - diff(lagrange, t1);

/* Find Torque 2 */

tor_2:diff(diff(lagrange, diff(t2, t)), t) - diff(lagrange, t2);

/*************************************************************/

/* This is where peters routines are used for simplification */

/* and the routines are turned into fortran code. */

/*************************************************************/

/* Create buffer for storing reduced expression terms */

zz:[];

/* Make a list of independent variables in expression */

dont:[t1, t2];

/* For the expression of torque for joint 1 */

/* Simplify Trigonometric terms of equation */

tt1:trigsimp(tor_1);

/* Expand all trigonometric expressions in equation */

tt1:trigexpand(tt1);

/* simplify equation by collecting common terms */

tt1:ratsimp(tt1);

/* Budgell’s method for removing common terms */

tt1:crunch(tt1, dont, ‘r);

/* Same as above, but for joint 2 */

tt2:trigsimp(tor_2);

tt2:trigexpand(tt2);

tt2:ratsimp(tt2);

tt2:crunch(tt2, dont, ‘r);

/* Show expressions */

zz;

/* Turn this stuff into fortran code */

/* This will produce fortran code for the equation constants */

fortbigopt(zz);

/* This will produce the fortran code for the equations of */

/* motion (not including calculations of constants) */

fortbigopt([‘torque1=tt1, ‘torque2=tt2]);

/*************************************************************/

/* The forward kinematics are also a concern, but are very */

/* simple to derive once the inverse kinematic equations */

/* have been found. */

/*************************************************************/

/* Next The Forward Dynamics May be found by solving these */

/* two parametric equations */

solve([‘torque1 = tt1, ‘torque2 = tt2],[diff(t1,t,2),diff(t2,t,2)]);

/* The forward kinematic results will now be simplified and */

/* turned into Fortran code. */

ratsimp(%);

trigsimp(%);

%[1];

fortbigopt(%);

B.7 The Results From Macsyma:

The results of the Macsyma run may be seen below. The Fortran code may also be seen, within the output. It may be noted that the count of basic operations accompanies this. From these numbers it is possible to obtain some idea of how optimal the solution is, by comparison. Brady et. al., [1982, pg.78] state that the minimum number of multiplies for the Inverse Dynamics of a 2 degree of freedom robot is 20, and minimum number of adds is 14 (this is for the Raibert-Horn Method). As can be seen, Macsyma was able to obtain 30 multiplies and 17 adds for the Inverse Dynamics. Thus, the results from Macsyma are near optimum. Note that these counts do not include the constant calculation subroutine which proceeds the actual dynamics calculations, it had 24 multiplies and 16 adds.

When finding the Forward Dynamics, Macsyma was able to reduce the equations satisfactorily. The Constants, which are to be precalculated, are the same as those for the Inverse Dynamics, thus the counts of adds and multiplies are identical. To evaluate the Forward Dynamic expressions Macsyma used 33 adds, and 57 multiplies.

The Fortran results from Macsyma were removed from the output file and converted from Fortran to ‘C’ and inserted into the ‘C’ Code of the dynamics simulation program. The code was kept broken into three parts. The first subroutine was for the calculation of constants which needed to be calculated only once in the execution of the program. The second subroutine is the Inverse Dynamics, which needs to be called whenever the equations of motion need to be reevaluated. The third subroutine is called to calculate the Forward Dynamics.

B.8 Verifying the Results:

The accuracy of the results was a slight concern, thus two informal tests were conducted to ensure their validity. In one test the arm was allowed to swing freely, with no forces at the actuators. The frequency of the joint swing was compared to theoretical estimates, and found to be appropriately equivalent. The simulation was also seen to conserve energy. The static properties were also tested by applying a force to the first joint, and letting the arm hang near the statically balanced position. The arm vibrated about the static equilibrium, thus showing the arm was statically modelled.

B.9 Macsyma Output:

The following pages contain selected portions of the Macsyma job to derive the forward and inverse dynamics.

•

• Basic Calculations and Definitons

•

(c42) /*************************************************************/

/* This is where peters routines are used for simplification */

/* and the routines are turned into fortran code. */

/*************************************************************/

/* Create buffer for storing reduced expression terms */

zz:[];

(d42) []

(c43) /* Make a list of independant variables in expression */

dont:[t1, t2];

(d43) [t1, t2]

(c44) /* For the expression of torque for joint 1 */

/* Simplify Trigonometric terms of equation */

tt1:trigsimp(tor_1);

2

d t2 dt2 2

(d44) (((4 l1 l2 mp + 2 l1 l2 m2) sin(t1) ---- + (- 4 l1 l2 mp - 2 l1 l2 m2) cos(t1) (---)

2 dt

dt

2

dt1 dt2 d t1

+ (- 8 l1 l2 mp - 4 l1 l2 m2) cos(t1) --- --- + (8 l1 l2 mp + 4 l1 l2 m2) sin(t1) ----) sin(t2 + t1)

dt dt 2

dt

2

d t2 dt2 2 dt1 dt2

+ ((4 l1 l2 mp + 2 l1 l2 m2) cos(t1) ---- + (4 l1 l2 mp + 2 l1 l2 m2) sin(t1) (---) + (8 l1 l2 mp + 4 l1 l2 m2) sin(t1) --- ---

2 dt dt dt

dt

2 2

d t1 2 2 d t2

+ (8 l1 l2 mp + 4 l1 l2 m2) cos(t1) ---- + 4 gravity l2 mp + 2 gravity l2 m2) cos(t2 + t1) + (4 l2 mp + l2 m2 + 4 i_2) ----

2 2

dt dt

2

2 2 2 2 2 d t1

+ ((4 l2 + 4 l1 ) mp + (l2 + 4 l1 ) m2 + l1 m1 + 4 i_2 + 4 i_1) ----

2

dt

+ (4 gravity l1 mp + 4 gravity l1 m2 + 2 gravity l1 m1) cos(t1))/4

(c45) /* Expand all trigonometric expressions in equation */

tt1:trigexpand(tt1);

2

d t2 dt2 2

(d45) ((cos(t1) sin(t2) + sin(t1) cos(t2)) ((4 l1 l2 mp + 2 l1 l2 m2) sin(t1) ---- + (- 4 l1 l2 mp - 2 l1 l2 m2) cos(t1) (---)

2 dt

dt

2

dt1 dt2 d t1

+ (- 8 l1 l2 mp - 4 l1 l2 m2) cos(t1) --- --- + (8 l1 l2 mp + 4 l1 l2 m2) sin(t1) ----)

dt dt 2

dt

2

d t2 dt2 2

+ (cos(t1) cos(t2) - sin(t1) sin(t2)) ((4 l1 l2 mp + 2 l1 l2 m2) cos(t1) ---- + (4 l1 l2 mp + 2 l1 l2 m2) sin(t1) (---)

2 dt

dt

2

dt1 dt2 d t1

+ (8 l1 l2 mp + 4 l1 l2 m2) sin(t1) --- --- + (8 l1 l2 mp + 4 l1 l2 m2) cos(t1) ---- + 4 gravity l2 mp + 2 gravity l2 m2)

dt dt 2

dt

2 2

2 2 d t2 2 2 2 2 2 d t1

+ (4 l2 mp + l2 m2 + 4 i_2) ---- + ((4 l2 + 4 l1 ) mp + (l2 + 4 l1 ) m2 + l1 m1 + 4 i_2 + 4 i_1) ----

2 2

dt dt

+ (4 gravity l1 mp + 4 gravity l1 m2 + 2 gravity l1 m1) cos(t1))/4

(c46) /* simplify equation by collecting common terms */

tt1:ratsimp(tt1);

2

2 2 2 2 d t2

(d46) ((((4 l1 l2 mp + 2 l1 l2 m2) sin (t1) + (4 l1 l2 mp + 2 l1 l2 m2) cos (t1)) cos(t2) + 4 l2 mp + l2 m2 + 4 i_2) ----

2

dt

2 2 dt2 2

+ ((- 4 l1 l2 mp - 2 l1 l2 m2) sin (t1) + (- 4 l1 l2 mp - 2 l1 l2 m2) cos (t1)) sin(t2) (---)

dt

2 2 dt1 dt2

+ ((- 8 l1 l2 mp - 4 l1 l2 m2) sin (t1) + (- 8 l1 l2 mp - 4 l1 l2 m2) cos (t1)) --- sin(t2) ---

dt dt

2

+ (- 4 gravity l2 mp - 2 gravity l2 m2) sin(t1) sin(t2) + (((8 l1 l2 mp + 4 l1 l2 m2) sin (t1)

2

2 d t1

+ (8 l1 l2 mp + 4 l1 l2 m2) cos (t1)) ---- + (4 gravity l2 mp + 2 gravity l2 m2) cos(t1)) cos(t2)

2

dt

2

2 2 2 2 2 d t1

+ ((4 l2 + 4 l1 ) mp + (l2 + 4 l1 ) m2 + l1 m1 + 4 i_2 + 4 i_1) ----

2

dt

+ (4 gravity l1 mp + 4 gravity l1 m2 + 2 gravity l1 m1) cos(t1))/4

(c47) /* Budgell’s method for removing common terms */

tt1:crunch(tt1, dont, ‘r);

r1 = 4 gravity l1 mp + 4 gravity l1 m2 + 2 gravity l1 m1

2 2 2 2 2

r2 = (4 l2 + 4 l1 ) mp + (l2 + 4 l1 ) m2 + l1 m1 + 4 i_2 + 4 i_1

r3 = 4 gravity l2 mp + 2 gravity l2 m2

r4 = 8 l1 l2 mp + 4 l1 l2 m2

/usr/local/macsyma_309/das/mstuff.o being loaded.

r5 = 4 l1 l2 mp + 2 l1 l2 m2

2 2

r6 = 4 l2 mp + l2 m2 + 4 i_2

2

2 2 d t2 2 2 dt2 2

(d47) (((r5 sin (t1) + r5 cos (t1)) cos(t2) + r6) ---- + (- r5 sin (t1) - r5 cos (t1)) sin(t2) (---)

2 dt

dt

2

2 2 dt1 dt2 2 2 d t1

+ (- r4 sin (t1) - r4 cos (t1)) --- sin(t2) --- - r3 sin(t1) sin(t2) + ((r4 sin (t1) + r4 cos (t1)) ---- + r3 cos(t1)) cos(t2)

dt dt 2

dt

2

d t1

+ r2 ---- + r1 cos(t1))/4

2

dt

(c48) /* Same as above, but for joint 2 */

tt2:trigsimp(tor_2);

2

d t1 dt1 2

(d48) (((4 l1 l2 mp + 2 l1 l2 m2) sin(t1) ---- + (4 l1 l2 mp + 2 l1 l2 m2) cos(t1) (---) ) sin(t2 + t1)

2 dt

dt

2

d t1 dt1 2

+ ((4 l1 l2 mp + 2 l1 l2 m2) cos(t1) ---- + (- 4 l1 l2 mp - 2 l1 l2 m2) sin(t1) (---) + 4 gravity l2 mp + 2 gravity l2 m2)

2 dt

dt

2 2

2 2 d t2 2 2 d t1

cos(t2 + t1) + (4 l2 mp + l2 m2 + 4 i_2) ---- + (4 l2 mp + l2 m2 + 4 i_2) ----)/4

2 2

dt dt

(c49) tt2:trigexpand(tt2);

2 2

2 2 d t2 d t1 dt1 2

(d49) ((4 l2 mp + l2 m2 + 4 i_2) ---- + ((4 l1 l2 mp + 2 l1 l2 m2) cos(t1) ---- + (- 4 l1 l2 mp - 2 l1 l2 m2) sin(t1) (---)

2 2 dt

dt dt

+ 4 gravity l2 mp + 2 gravity l2 m2) (cos(t1) cos(t2) - sin(t1) sin(t2))

2

d t1 dt1 2

+ ((4 l1 l2 mp + 2 l1 l2 m2) sin(t1) ---- + (4 l1 l2 mp + 2 l1 l2 m2) cos(t1) (---) ) (cos(t1) sin(t2) + sin(t1) cos(t2))

2 dt

dt

2

2 2 d t1

+ (4 l2 mp + l2 m2 + 4 i_2) ----)/4

2

dt

(c50) tt2:ratsimp(tt2);

2

2 2 d t2 2 2 dt1 2

(d50) ((4 l2 mp + l2 m2 + 4 i_2) ---- + (((4 l1 l2 mp + 2 l1 l2 m2) sin (t1) + (4 l1 l2 mp + 2 l1 l2 m2) cos (t1)) (---)

2 dt

dt

2

+ (- 4 gravity l2 mp - 2 gravity l2 m2) sin(t1)) sin(t2) + (((4 l1 l2 mp + 2 l1 l2 m2) sin (t1)

2

2 d t1

+ (4 l1 l2 mp + 2 l1 l2 m2) cos (t1)) ---- + (4 gravity l2 mp + 2 gravity l2 m2) cos(t1)) cos(t2)

2

dt

2

2 2 d t1

+ (4 l2 mp + l2 m2 + 4 i_2) ----)/4

2

dt

(c51) tt2:crunch(tt2, dont, ‘r);

2 2

d t2 2 2 dt1 2 2 2 d t1

(d51) (r6 ---- + ((r5 sin (t1) + r5 cos (t1)) (---) - r3 sin(t1)) sin(t2) + ((r5 sin (t1) + r5 cos (t1)) ---- + r3 cos(t1)) cos(t2)

2 dt 2

dt dt

2

d t1

+ r6 ----)/4

2

dt

(c52) /* Show expressions */

zz;

(d52) [r1 = 4 gravity l1 mp + 4 gravity l1 m2 + 2 gravity l1 m1, r2 =

2 2 2 2 2

(4 l2 + 4 l1 ) mp + (l2 + 4 l1 ) m2 + l1 m1 + 4 i_2 + 4 i_1, r3 = 4 gravity l2 mp + 2 gravity l2 m2,

2 2

r4 = 8 l1 l2 mp + 4 l1 l2 m2, r5 = 4 l1 l2 mp + 2 l1 l2 m2, r6 = 4 l2 mp + l2 m2 + 4 i_2]

(c53) /* Turn this stuff into fortran code */

/* This will produce fortran code for the equation constants */

fortbigopt(zz);

•

•

•

b3 = gravity*l1

b1 = 4*mp

r1 = 4*b3*m2+2*b3*m1+b1*b3

pfx4 = l2**2

pfx2 = l1**2

pfx3 = 4*pfx2

pfx1 = 4*i_2

r2 = mp*(4*pfx4+pfx3)+m2*(pfx4+pfx3)+m1*pfx2+pfx1+4*i_1

b4 = gravity*l2

r3 = 2*b4*m2+b1*b4

b2 = l1*l2

b5 = b2*m2

r4 = 8*b2*mp+4*b5

r5 = 2*b5+b1*b2

r6 = m2*pfx4+b1*pfx4+pfx1

(d53) done

(c54) /* This will produce the fortran code for the equations of */

/* motion (not including calculations of constants) */

fortbigopt([‘torque1=tt1, ‘torque2=tt2]);

•

•

•

pfx1 = cos(t1)

pfx4 = pfx1**2

b3 = pfx4*r5

pfx5 = sin(t1)

pfx6 = pfx5**2

b1 = pfx6*r5

pfx11 = b3+b1

pfx12 = ‘DIFF(t2,t,2)

pfx9 = ‘DIFF(t1,t,1)

pfx10 = ‘DIFF(t2,t,1)

pfx8 = sin(t2)

b2 = pfx5*r3

pfx7 = cos(t2)

pfx3 = pfx1*r3

pfx2 = ‘DIFF(t1,t,2)

b5 = pfx4*r4

b4 = pfx6*r4

torque1 = (pfx12*(r6+pfx11*pfx7)+pfx2*r2+pfx1*r1+(-b5-b4)*pfx10*pf

1 x8*pfx9+(-b3-b1)*pfx10**2*pfx8-b2*pfx8+(pfx3+(b5+b4)*pfx2)*pfx7

2 )/4.0

torque2 = (pfx2*r6+pfx12*r6+pfx8*(pfx11*pfx9**2-b2)+(pfx3+pfx11*pf

1 x2)*pfx7)/4.0

(d54) done

(c55) /*************************************************************/

/* The forward kinematics are also a concern, but are very */

/* simple to derive once the inverse kinematic equations */

/* have been found. */

/*************************************************************/

/* Next The Forward Dynamics May be found by solving these */

/* two parametric equations */

solve([‘torque1 = tt1, ‘torque2 = tt2],[diff(t1,t,2),diff(t2,t,2)]);

2

d t1 2 2

(d55) [[---- = - (cos(t2) (- 4 r5 sin (t1) torque2 - 4 r5 cos (t1) torque2) - 4 r6 torque2 + 4 r6 torque1

2

dt

2 2 dt2 2 2 2 dt1 dt2

+ (r5 r6 sin (t1) + r5 r6 cos (t1)) sin(t2) (---) + (r4 r6 sin (t1) + r4 r6 cos (t1)) --- sin(t2) ---

dt dt dt

2 4 2 2 2 2 4 dt1 2 3 2

+ (((r5 sin (t1) + 2 r5 cos (t1) sin (t1) + r5 cos (t1)) (---) - r3 r5 sin (t1) - r3 r5 cos (t1) sin(t1)) cos(t2)

dt

2 2 dt1 2 2 3 2

+ (r5 r6 sin (t1) + r5 r6 cos (t1)) (---) ) sin(t2) + (r3 r5 cos(t1) sin (t1) + r3 r5 cos (t1)) cos (t2) - r1 r6 cos(t1))

dt

2 4 2 2 2 2 4 2 2 2

/((r5 sin (t1) + 2 r5 cos (t1) sin (t1) + r5 cos (t1)) cos (t2) + ((2 r5 - r4) r6 sin (t1) + (2 r5 - r4) r6 cos (t1)) cos(t2)

2

2 d t2 2 2 3

+ r6 - r2 r6), ---- = (cos(t2) (sin (t1) (- 4 r4 torque2 - r1 r5 cos(t1)) - 4 r4 cos (t1) torque2 - r1 r5 cos (t1)

2

dt

2 2

+ (r2 r3 - r3 r6) cos(t1)) - 4 r2 torque2 + ((4 r5 sin (t1) + 4 r5 cos (t1)) cos(t2) + 4 r6) torque1

2 4 2 2 2 2 4 2 2 dt2 2

+ ((r5 sin (t1) + 2 r5 cos (t1) sin (t1) + r5 cos (t1)) cos(t2) + r5 r6 sin (t1) + r5 r6 cos (t1)) sin(t2) (---)

dt

4 2 2 4 dt1 2 2 dt1 dt2

+ ((r4 r5 sin (t1) + 2 r4 r5 cos (t1) sin (t1) + r4 r5 cos (t1)) --- cos(t2) + (r4 r6 sin (t1) + r4 r6 cos (t1)) ---) sin(t2) ---

dt dt dt

4 2 2 4 dt1 2 3

+ (((r4 r5 sin (t1) + 2 r4 r5 cos (t1) sin (t1) + r4 r5 cos (t1)) (---) + (r3 r5 - r3 r4) sin (t1)

dt

2 2 2 dt1 2

+ (r3 r5 - r3 r4) cos (t1) sin(t1)) cos(t2) + (r2 r5 sin (t1) + r2 r5 cos (t1)) (---) + (r3 r6 - r2 r3) sin(t1)) sin(t2)

dt

2 3 2

+ ((r3 r4 - r3 r5) cos(t1) sin (t1) + (r3 r4 - r3 r5) cos (t1)) cos (t2) - r1 r6 cos(t1))

2 4 2 2 2 2 4 2 2 2

/((r5 sin (t1) + 2 r5 cos (t1) sin (t1) + r5 cos (t1)) cos (t2) + ((2 r5 - r4) r6 sin (t1) + (2 r5 - r4) r6 cos (t1)) cos(t2)

2

+ r6 - r2 r6)]]

(c56) /* The forward kinematic results will now be simplified and */

/* turned into Fortran code. */

•

•

•

(c59) fortbigopt(%);

•

•

•

pfx1 = cos(t2)

b7 = pfx1*r5

b9 = 4*b7

b6 = 4*r6

pfx9 = sin(t1)

pfx2 = r5**2

pfx7 = ‘DIFF(t1,t,1)

pfx8 = pfx7**2

pfx10 = sin(t2)

pfx5 = cos(t1)

pfx6 = pfx5*r1*r6

pfx11 = ‘DIFF(t2,t,1)

b8 = pfx10*pfx11

b3 = pfx7*r4

b12 = b3*r6

pfx12 = pfx11**2

b5 = pfx10*pfx12

b4 = r5*r6

b2 = r3*r5

pfx3 = pfx1**2

b1 = pfx3*pfx5

pfx4 = 1/(r6**2+pfx1*(2*r5-r4)*r6-r2*r6+pfx2*pfx3)

‘DIFF(t1,t,2) = pfx4*((b9+b6)*torque2-b6*torque1+pfx10*(pfx1*(b2*p

1 fx9-pfx2*pfx8)-b4*pfx8)+pfx6-b12*b8-b4*b5-b1*b2)

b11 = pfx8*r5

b14 = r2*r3

b10 = r3*r6

b13 = r3*r4

‘DIFF(t2,t,2) = -pfx4*((4*pfx1*r4+4*r2)*torque2+(-b9-b6)*torque1+p

1 fx1*pfx5*(r1*r5-b14+b10)+pfx10*(pfx1*((b13-b2)*pfx9-b11*r4)-b11

2 *r2+(b14-b10)*pfx9)+pfx6+b5*(-pfx1*pfx2-b4)+(-b3*b7-b12)*b8+b1*

3 (b2-b13))

(d59) done

(d60) BATCH DONE

(c61) quit();

[an error occurred while processing this directive]