Disturbance observer for 2DOF robot manipulator

Hello, I want to design a disturbance observer (DOB) for a 2-degree-of-freedom (2-DOF) robotic manipulator. I'm using MATLAB for simulation and implementation. Could anyone provide guidance or share a detailed example on how to model the 2-DOF robotic manipulator and implement the disturbance observer in MATLAB? Specifically, how to design and implement a DOB for this system and tips on parameter tuning and simulation in MATLAB. Also, can somone tell me if this equations for 2DOF arm are correct:
, where , , ,
From which it follows:
Any help or example code would be greatly appreciated! Thanks.

3 Comments

There are a lot of different 2DOF manipulators out there where both joints can be rotational, translational or a combination, as well as a single joint with spherical actuator. Based on the configuration, the dynamic equation changes.
However the equation you show is a generic one that can fit to any system since it is not specified what each element of A and b matrices are. Generally A and b matrices for robotic manipulators are a function of position and velocity. You should be able to find a lot of resources online to derive the equation of motion. For instance here is one from fileexchange.
What is the Disturbance Observer for?
The compact equations you posted are typical 2nd-order ODEs that can be used to describe the motion of many mechanical systems. But the symbols alone cannot describe the 2-DOF Robotic Manipulator.
If the MATLAB codes are available, would you know how to design the Disturbance Observer?
Keep in mind that the Disturbance Observer alone cannot control the motion of the Robotic Manipulator.
Thanks for your answers. I would like to set the desired path of the manipulator's tip using a disturbance observer by applying direct kinematics.

Sign in to comment.

Answers (1)

@HD, inititally you can use this code:
clc
clear
close all
% Time---------------------------------------------------------------------
tf=10;
N=2000*tf;
Nt=tf/N;
t=0:tf/N:tf;
% DoF----------------------------------------------------------------------
n=2;
% Start and end points-----------------------------------------------------
xi=0;
yi=1.73;
xf=1.5;
yf=0;
% Parameters---------------------------------------------------------------
a1=1;
a2=1;
ac1=a1/2;
ac2=a2/2;
m1=2;
m2=2;
mp=0.25;
g0=9.81;
Izz1=1/12*m1*a1^2;
Izz2=1/12*m2*a2^2;
% Inverse kinematics-------------------------------------------------------
xin2=real(acos((xi^2+yi^2-a1^2-a2^2)/(2*a1*a2)));
xin1=real(atan2(yi,xi))-real(atan2(a2*sin(xin2),(a1+a2*cos(xin2))));
xin3=0;
xin4=0;
xdes2=real(acos((xf^2+yf^2-a1^2-a2^2)/(2*a1*a2)));
xdes1=real(atan2(yf,xf))-real(atan2(a2*sin(xdes2),(a1+a2*cos(xdes2))));
xdes3=0;
xdes4=0;
x_0=[xin1;xin2;xin3;xin4];
x_des=[xdes1;xdes2;xdes3;xdes4];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solution-----------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:1:length(t)
Time=t(i);
x(:,1)=x_0;
% States---------------------------------------------------------------
q1=x(1,i);
q2=x(2,i);
dq1=x(3,i);
dq2=x(4,i);
q=[q1;q2];
dq=[dq1;dq2];
% Dynamics-------------------------------------------------------------
M=[Izz1+Izz2+a1^2*m2+ac1^2*m1+ac2^2*m2+a1^2*mp+a2^2*mp+2*a1*ac2*m2*cos(q2)+2*a1*a2*mp*cos(q2),mp*a2^2+a1*mp*cos(q2)*a2+m2*ac2^2+a1*m2*cos(q2)*ac2+Izz2;...
mp*a2^2+a1*mp*cos(q2)*a2+m2*ac2^2+a1*m2*cos(q2)*ac2+Izz2,mp*a2^2+m2*ac2^2+Izz2];
g=[g0*m2*(ac2*cos(q1+q2)+a1*cos(q1))+g0*mp*(a2*cos(q1+q2)+a1*cos(q1))+ac1*g0*m1*cos(q1);...
g0*cos(q1+q2)*(ac2*m2+a2*mp)];
C=[-a1*dq2*sin(q2)*(ac2*m2+a2*mp),-a1*sin(q2)*(dq1+dq2)*(ac2*m2+a2*mp);...
a1*dq1*sin(q2)*(ac2*m2+a2*mp),0];
Df=diag([0.1,0.1]);
% Input----------------------------------------------------------------
Kp=5*eye(2);
Kd=10*eye(2);
u(:,i)=-Kp*(q-x_des(1:2))-Kd*(dq-x_des(3:4))+g;
% System---------------------------------------------------------------
f=[dq;inv(M)*(u(:,i)-C*dq-g-Df*dq)];
x(:,i+1)=x(:,i)+f*Nt;
% Error----------------------------------------------------------------
xe2=a1*cos(q1)+a2*cos(q1+q2);
ye2=a1*sin(q1)+a2*sin(q1+q2);
error(i)=sqrt((xe2-xf)^2+(ye2-yf)^2);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plots--------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
End_Effector_error_m=error(length(t))
End_Effector_error_m = 0.0041
figure(1)
hold all;grid on;box on
plot(t,x(1,1:length(t)),'b','LineWidth',1.5)
line([0,tf],[x_des(1),x_des(1)],'LineStyle','--','Color',[1 0 0])
xlabel('t[s]')
ylabel('q_1(t)[rad]')
figure(2)
hold all;grid on;box on
plot(t,x(2,1:length(t)),'b','LineWidth',1.5)
line([0,tf],[x_des(2),x_des(2)],'LineStyle','--','Color',[1 0 0])
xlabel('t[s]')
ylabel('q_2(t)[rad]')
figure(3)
hold all;grid on;box on
plot(t,x(3,1:length(t)),'b','LineWidth',1.5)
line([0,tf],[x_des(3),x_des(3)],'LineStyle','--','Color',[1 0 0])
xlabel('t[s]')
ylabel('dq_1(t)/dt[rad/s]')
figure(4)
hold all;grid on;box on
plot(t,x(4,1:length(t)),'b','LineWidth',1.5)
line([0,tf],[x_des(4),x_des(4)],'LineStyle','--','Color',[1 0 0])
xlabel('t[s]')
ylabel('dq_2(t)/dt[rad/s]')
figure(5)
hold all;grid on;box on
plot(t,u(1,1:length(t)),'b','LineWidth',1.5)
xlabel('t[s]')
ylabel('u_1(t)')
figure(6)
hold all;grid on;box on
plot(t,u(2,1:length(t)),'b','LineWidth',1.5)
xlabel('t[s]')
ylabel('u_2(t)')
q1=x(1,:);
q2=x(2,:);
xe1=a1*cos(q1);
ye1=a1*sin(q1);
xe2=a1*cos(q1)+a2*cos(q1+q2);
ye2=a1*sin(q1)+a2*sin(q1+q2);
figure(7)
hold all
plot(xi,yi,'*r')
plot(xf,yf,'om')
plot(xe2,ye2,'-k','LineWidth',2)
for i=1:round(N/50):N
line([0;xe1(i)],[0;ye1(i)],'Color',[0 0 1])
line([xe1(i);xe2(i)],[ye1(i);ye2(i)],'Color',[1 0 0])
end
xlabel('x(t)[m]')
ylabel('y(t)[m]')
axis equal
box on
grid on
legend('start point','end point','trajectory')
figure(8)
hold all;grid on;box on
plot(t,error(1:length(t)),'b','LineWidth',1.5)
xlabel('t[s]')
ylabel('|error(t)|')
For the observer you need to linearize the nonlinear model of manipulador and use it.
Regards

Products

Release

R2018a

Asked:

HD
on 9 Jul 2024

Moved:

on 18 Jul 2024

Community Treasure Hunt

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

Start Hunting!