Inverted double pendulum on a cart
36 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aravind Krishnamoorthi
el 12 de Oct. de 2017
Comentada: Nikola Stojiljkovic
el 22 de Nov. de 2021
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 comentarios
Roqye Rostmi
el 27 de Ag. de 2021
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
el 22 de Nov. de 2021
@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...
Respuestas (1)
Meeshawn Marathe
el 16 de Oct. de 2017
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).
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!