Inverted double pendulum on a cart

36 ビュー (過去 30 日間)
Aravind Krishnamoorthi
Aravind Krishnamoorthi 2017 年 10 月 12 日
コメント済み: Nikola Stojiljkovic 2021 年 11 月 22 日
Hello all . I am trying to solve the inverted double pendulum on a cart problem. I have all the equations of motion for the problem. Since i am new to matlab i am not sure about how to go about the problem. I initialized the parameters for the problem. I am attaching the picture of the equations of motion in matrix form . I need to find theta double dot.
I am also attaching the code for your reference.
if true
tspan=[0 5]; %time spane
ic=[0:0.1:pi];%initial conditions
% parameters
mo=2;
m1=1;
m2=1;
l1=0.5;
L1=1;
l2=0.5;
L2=1;
g=9.8;
I1=0.0126;
I2=0.0185;
%equations of motion
d1=mo+m1+m2;
d2=m1*l1+m2*L1;
d3=m2*l2;
d4=m1*l1*l1+m2*L2*L2+I1;
d5=m2*L1*l2;
d6=m2*l2*l2+I2;
d7=(m1*l1+m2*L1)*g;
d8=m2*l2*g;
D=[d1 d2*cos(x1) d3*cos(x3); d2*cos(x1) d4 d5*cos(x1-x3); d3*cos(x2) d5*cos(x1-x3) d6]
C=[0 -d2*sin(x1)*x2 -d3*sin(x2)*x4; 0 0 d5*sin(x1-x3)*x4; 0 d5*sin(x1-x3)*x2 0]
G=[0;-d7*sin(x1);-d8*sin(x3)]
H=[1 0 0].'
I= inv(D);
J=I*(-G+H);
[t,x]= ode45(pend,tspan,ic);
plot (t,x),
grid on
xlabel('Time(s)');
legend('theta1', 'theta2')
end
  2 件のコメント
Roqye Rostmi
Roqye Rostmi 2021 年 8 月 27 日
Hi I am working on this problem too. i need simulate these equations of motion in matlab simulink but i don't know how! The equations that i have :
Nikola Stojiljkovic
Nikola Stojiljkovic 2021 年 11 月 22 日
@Roqye Rostmi Hello, have you worked the problem out? I am working on a project and i would very much appritiate some help, as i am on a tight deadline...

サインインしてコメントする。

回答 (1 件)

Meeshawn Marathe
Meeshawn Marathe 2017 年 10 月 16 日
Please go through your code. The states chosen are not correct. You would have to convert the equation of motion to a set of first order equations. Let x be the cart displacement and theta1 and theta2 be the angular deviations of the rods from the upright position. Your state vector should look like:
y = [x1 x2 theta1 theta3 theta2 theta4]',
where,
x2=d(x1)/dt,
theta3=d(theta1)/dt,
theta4=d(theta2)/dt
Hence the state equation becomes dy/dt = f(y,u). Now d(theta3)/dt and d(theta4)/dt can be found out by rearranging the equation (2). Use an ODE solver (ex: ode45) and pass the arguments appropriately. The odefun will have 6 state equations based on dy/dt = f(y,u).
  1 件のコメント
Aravind Krishnamoorthi
Aravind Krishnamoorthi 2017 年 10 月 16 日
Thank you Meeshwan will try it out.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by