Borrar filtros
Borrar filtros

Converting a Non-Linear equation to canonical form

3 visualizaciones (últimos 30 días)
Japnit Sethi
Japnit Sethi el 19 de Mayo de 2020
Comentada: Walter Roberson el 21 de Mayo de 2020
I have an equation of Motion for a 2 link robotic arm such as:
EOM2 =
a2*(m2*lc2^2 + l1*m2*cos(q2)*lc2 + I2) - v2*(- (-l1*lc2*m2*sin(q2))*q_dot1 - (-l1*lc2*m2*sin(q2))*q_dot2) + a1*(m2*l1^2 + 2*m2*cos(q2)*l1*lc2 + m1*lc1^2 + m2*lc2^2 + I1 + I2) + g*m2*(lc2*cos(q1 + q2) + l1*cos(q1)) - q_dot2*v1*l1*lc2*m2*sin(q2) + g*lc1*m1*cos(q1)
I want to convert the EOM into a canonical form such that EOM = Y.θ where Y consists of symbolic variables like a,v and q. Here, a includes a1, and a2, v includes v1 and v2, and q includes q1, q2,, q_dot1, q_dot2, and any function that includes q like sin(q1) or sin(q1 +q2), cos(q2) and so on.
My approach was to first do it by hand and thus my Answer is:
% Y(a,v,q) Regressor matrix
Y1_Matrix = [a(1), cos(q(2))*a(1), cos(q(2))*a(2), a(1) + a(2), a(2), sin(q(2))*v(1)*q_dot(2),...
sin(q(2))*(q_dot(1)+q_dot(2))*v(2), cos(q(1)), cos(q(1)+q(2))];
Y2_Matrix = [0, 0, sin(q(2))*v(1)*q_dot(1)+a(1)*cos(q(2)), a(1) + a(2), a(1) + a(2), 0, 0, 0, cos(q(1)+q(2))];
Y_Matrix = [Y1_Matrix;Y2_Matrix]; % 2X9
% Theta is vector
Theta_Vector = [m2*l1^2 + m1*lc1^2 + I1 + I2;
2*m2*l1*lc2;
l1*m2*lc2;
m2*lc2^2;
I2;
-m2*l1*lc2;
-m2*l1*lc2;
g*m2*l1+g*lc1*m1;
g*m2*lc2]; % 9X1
EOM3 = Y_Matrix*Theta_Vector
I also found that there is a `collect()` function one could use to collect coefficients of variables such as:
collect(EOM2, [a(1), a(2), v(1), v(2), q(1), q(2), cos(q(1) + q(2)), cos(q(1)), sin(q(1)), cos(q(2)), sin(q(2))])
But the above approach becomes tedious when dealing with higher order robotic arm in future !!!
Questions:
  1. I wanted to see if there is a more elegant and faster approach to do so, specifically with anything related to q where I have to keep track of so many symbolic variables !!
  2. Also can I convert the collected coefficients directly into a Y.θ matrix*vector form without it reqriting myself ?
a2*(m2*lc2^2 + I2) + a1*(m2*lc2^2 + l1*m2*cos(q2)*lc2 + I2) + q_dot1*v1*l1*lc2*m2*sin(q2) + g*lc2*m2*cos(q1 + q2)
  11 comentarios
Japnit Sethi
Japnit Sethi el 21 de Mayo de 2020
Editada: Japnit Sethi el 21 de Mayo de 2020
In that scenario I don't necessarily want to split the q1 and q2 independently, I want to split it into 2 matrices such that Y(contains all q terms) and Theta (remaining constants): Y =[q1, q1*q2, 1] Theta = [5; -2; -3]
For my original question, my constants are m1,m2, l1, l2, lc1, lc2,I1, I2 and g
Walter Roberson
Walter Roberson el 21 de Mayo de 2020
Your Y for this example does not contain only symbolic variables in combination: it also contains 1. That was not a permitted option in your original formulation.
[theta, Y] = coeffs(EOM2, vars)

Iniciar sesión para comentar.

Respuestas (0)

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by