필터 지우기
필터 지우기

Converting a Non-Linear equation to canonical form

조회 수: 3 (최근 30일)
Japnit Sethi
Japnit Sethi 2020년 5월 19일
댓글: Walter Roberson 2020년 5월 21일
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
Japnit Sethi
Japnit Sethi 2020년 5월 21일
편집: Japnit Sethi 2020년 5월 21일
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 2020년 5월 21일
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)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by