You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Prescribed Controller for a nonlinear system
20 views (last 30 days)
Show older comments
I'm working on implementing a Strong Prescribed Time (SPT) controller for a manipulator in MATLAB. I've successfully designed the controller for the first example provided in a research paper. However, I'm facing challenges with the second example. Designing the SPT controller for the second example's manipulator dynamics.
The paper (Ding et al., 2023) outlines the SPT controller design procedure and manipulator dynamics.
type Exmp2.m
h=5;
a = -0.15;
history = @(t)[-0.2;0.1;0.1];
% Define the Rh function based on the given conditions
Rh = @(t) (0 <= t & t < h) .* 0 + ...
(h <= t & t <= 2*h) .* ((t-h).^5.*(2*h-t).^5) + ...
(t > 2*h) .* 0;
% Define the PDF gain function based on Rh
W_c = integral(@(s) Rh(s) .* exp(2 * a * s), h, 2 * h);
W = 1 / W_c;
K_a_h = @(t) Rh(t) .* W .* exp(-a * (h - 2 * t));
% Define the delay differential equation
dde = @(t,x,Z)manipulator_dynamics(t,x,Z,K_a_h);
sol = dde23(dde, h, history, [0 40]);
% Plot results
figure;
subplot(3,1,1);
plot(sol.x, sol.y(1,:));
xlabel('Time (s)');
ylabel('x1 (error in q)');
title('State x1 vs Time');
subplot(3,1,2);
plot(sol.x, sol.y(2,:));
xlabel('Time (s)');
ylabel('x2 (error in dq)');
title('State x2 vs Time');
subplot(3,1,3);
plot(sol.x, sol.y(3,:));
xlabel('Time (s)');
ylabel('x3 (error in I)');
title('State x3 vs Time');
% DDE function
function dxdt = manipulator_dynamics(t, x, Z, K_a_h)
x1_d = 0;
x2_d = 0;
x3_d = 0;
a = -0.15; % Example value
tau = 81/83; % Example value
h = 5; % Example value
J = 1.625e-3; % kg·m²
m = 0.506; % kg
L0 = 0.305; % m
R0 = 0.023; % m
B0 = 16.25e-3; % N·m·s/rad
L = 25e-3; % H
R = 5; % Ω
K_tau = 0.9; % N·m/A
G = 9.81; % m/s²
M0 = 0.434; % kg
% Derived parameters
M = J / K_tau + m * L0^2 / (3 * K_tau) + M0 * L0^2 / K_tau + 2 * M0 * R0^2 / (5 * K_tau);
N = m * L0 * G / (2 * K_tau) + M0 * L0 * G / K_tau;
B = B0 / K_tau;
K_B = 0.9;
Vp = 0.1 * sin(50 * pi *t);
z1 = x(1) - x1_d;
z2 = x(2) - x2_d;
z3 = x(3) - x3_d;
z3lag = Z(3,1) - x3_d;
% Control input
u = L * ((-a / (2 * (1 - tau))) * z3 + x3_d ...
+ R / L * x(3) + K_B / L * x(2) ...
- 5 * sign(z3) ...
- (K_a_h(t) / (2 * (1 - tau))) * (sig(z3 * (abs(z3lag)^(2 * (1 - tau)))))^(2 * tau - 1));
% Desired trajectory
q_d = (pi / 2) * sin(t) * (1 - exp(-0.1 * t^2));
% Dynamics
dxdt = [x(2);
(N / M) * sin(q_d) - (N / M) * sin(x(1) + q_d) - (B / M) * x(2) + (1 / M) * x(3);
-(R / L) * x(3) - (K_B / L) * x(2) + (1 / L) * u + Vp / L];
end
function sigx = sig(x)
tau = 81/83;
sigx = sign(x) .* abs(x).^(2 * tau - 1);
end
20 Comments
Sam Chak
on 27 Jun 2024
Hi @controlEE
Your design workflow looks correct. Since the controller u depends on , you need to find first so that you can determine its time derivative later. However, also depends on . Therefore, you need to backstep and find so that you can find its time derivative . When you backstep to the end, you will need .
Just be careful when performing substitutions. Because there are multiple layers of substitutions, if you make a mistake at the beginning (such as ), it will create a chain of mistakes that will propagate forward to the controller u.
%% terms extracted from the original system
F1 = ...;
F2 = ...;
F3 = ...;
G1 = ...;
G2 = ...;
G3 = ...;
%% miscellaneous terms to be used in Eq.(23) and Eq.(26)
a = ...;
h = ...;
rho = ...; % ρ, bounded non-negative function derived to satisfy |ϕ(t,x)| ≤ ρ(t,x)
tau = ...; % τ
K1 = ...;
K2 = ...;
K3 = ...;
z1 = ...;
z2 = ...;
z3 = ...;
... % others
%% terms derived from Eq.(23) and their time derivatives
x1d = 0;
dotx1d = 0;
x2d = ...;
dotx2d = ...;
x3d = ...;
dotx3d = ...;
%% controller, according to Eq.(26)
u = ...;
The perturbing term is not a constant, but a bounded time-varying sine wave. This info is for designing , which is a bounded non-negative function created to satisfy the condition .
By the way, the authors performed coordinate transformation and the x-dot system is expressed in strict-feedback form.
Sam Chak
on 1 Jul 2024
Hi @controlEE
I have briefly reviewed the latest code, focusing on some critical terms. It appears that the authors' backstepping formulas and the "divide-and-conquer" coding guidance I had previously provided are not being followed. For instance, I am unable to locate the terms F1, F2, F3, G1, G2, and G3 within the code. This poses a challenge for me to thoroughly evaluate your implementation.
The code itself is meaningless if the underlying "step-by-step" backstepping control design is flawed. Providing a detailed, annotated step-by-step approach is essential, as it allows your "Supervisor" or "Software Development Manager" to review the code and ensure adherence to standard coding practices.
Regarding the code, the term in x3_d (which is not directly shown in the provided code) appears to be incorrect. Without the detailed "step-by-step" design, it is difficult to trace the reasoning behind this specific implementation of F2. Additionally, the derivation of "xdot_2_desire" is not clearly shown, as the mathematical time derivative is not explicitly presented.
Sam Chak
on 8 Jul 2024
Hi @controlEE
The most probable explanation is that the equations in your code may differ from those used by the authors. Unfortunately, without access to the authors' exact control law design equations for Example 2, we are unable to verify this.
Have you thoroughly checked to ensure that the equations in your code precisely follow the design methodology outlined in the paper? You need to show your every design step as outlined in order to thoroughly check it. Yes, "thoroughly"...
If you lump everything and write a single line equation in the code, it is very dificult to trace the substitutions and check it. I always DIVIDE and CONQUER it...
controlEE
on 21 Jul 2024
Ok , here is the last implementation of the example ;
There is an error in Line 54 , Can you determine what the problem is ?
clear all
close all
clc
dt = 0.001;
tf = 5;
t = 0:dt:tf;
J = 1.625e-3;
m = 0.506;
M0 = 0.434;
L0 = 0.305;
R0 = 0.023;
B0 = 16.25e-3;
L = 25e-3;
R = 5e3;
G = 9.81;
Kt = 0.9;
Kb = Kt;
B = B0/Kt;
Vp = 0.1*sin(50*pi*t);
q = pi/2*sin(t).*(1-exp(-0.1*t.^2));
a = -0.15;
tau = 81/83;
h = 5;
x0 = [-0.2,-0.1,0.1];
x(1,:) = x0;
x1d = zeros(length(t),1);
x1dd = zeros(length(t),1);
dx1d = zeros(length(t),1);
M = J/Kt + m*L0^2/(3*Kt) + M0*L0^2/Kt + 2*M0*R0^2/(5*Kt);
N = m*L0*G/(2*Kt) + M0*L0*G/Kt;
B0 = B0/Kt;
delay = h/dt;
W = @(s) exp(a*s).*(s-h).^5.*(2*h-s).^5;
Wc = 1/(integral(W,h,2*h));
for i=2:length(t)
k = 0;
for j=1:length(x0)
if (t(i-1)-2*(length(x0)-j)*h)>=k*h && (t(i-1)-2*(length(x0)-j)*h)<(2*k+1)*h
Rh(i-1,j) = 0;
dR(i-1,j) = 0;
ddRh(i-1,j) = 0;
elseif (t(i-1)-2*(length(x0)-j)*h)>= (2*k+1)*h && (t(i-1)-2*(length(x0)-j)*h)<2*(k+1)*h
Rh(i-1,j) = (t(i-1)-2*(length(x0)-j)*h-h).^5.*(2*h-(t(i-1)-2*(length(x0)-j)*h));
dRh(i-1,j) = 5*((t(i-1)-2*(length(x0)-j)*h)-h).^4.*(2*h-(t(i-1)-2*(length(x0)-j)*h)).^5-5*((t(i-1)-2*(length(x0)-j)*h)-h).^5.*(2*h-(t(i-1)-2*(length(x0)-j)*h)).^4;
ddRh(i-1,j) = 20*((t(i-1)-2*(length(x0)-j)*h)-h).^3.*(2*h-(t(i-1)-2*(length(x0)-j)*h)).^3*((2*h-(t(i-1)-2*(length(x0)-j)*h)).^2+((t(i-1)-2*(length(x0)-j)*h)-h).^2)-50*((t(i-1)-2*(length(x0)-j)*h)-h).^4.*(2*h-(t(i-1)-2*(length(x0)-j)*h)).^4;
end
if t(i-1)<=2*(length(x0)-j)*h
K(i-1,j) = 0;
dK(i-1,j) = 0;
ddK(i-1,j) = 0;
elseif t(i-1)>=2*(length(x0)-j)*h
K(i-1,j) = Rh(i-1,j)*Wc*exp(-a*(h-2*(t(i-1)-2*(length(x0)-j)*h)));
dK(i-1,j) = exp(-a*(h-2*(t(i-1)-2*(length(x0)-j)*h)))*Wc*(2*a*Rh(i-1,j)+dRh(i-1,j));
ddK(i-1,j) = exp(-a*(h-2*(t(i-1)-2*(length(x0)-j)*h)))*Wc*(2*a*(2*a*Rh(i-1,j)+dRh(i-1,j))+2*a*dRh(i-1,j)+ddRh(i-1,j));
end
end
if(i-1-delay)<0
xd(i-1,:) = x0;
x1d_d(i-1) = x1d(1);
else
xd(i-1,:) = x(i-1-delay,:);
x1d_d(i-1) = x1d(i-1-delay);
end
z1d(i-1) = xd(i-1,1)-x1d_d(i-1);
if (i-1-2*delay)<-delay
xdd(i-1,:) = 0;
z1dd(i-1) = 0;
else
z1dd(i-1) = z1d(i-1);
xdd(i-1,:) = xd(i-1,:);
end
z1(i-1) = x(i-1,1)-x1d(i-1);
x2d(i-1) = -a*z1(i-1)-K(i-1,1)*z1d(i-1);
z2(i-1) = x(i-1,2)-x2d(i-1);
if(i-1-delay)<0
x2d_d(i-1) = -a*z1d(i-1);
else
x2d_d(i-1) = x2d(i-1-delay);
end
z2d(i-1) = xd(i-1,2)-x2d_d(i-1);
dz1d(i-1) = -a*z1d(i-1)+z2d(i-1);
dz1(i-1) = -a*z1(i-1)-K(i-1,1)*z1d(i-1)+z2(i-1);
z1(i) = z1(i-1)+(t(i)-t(i-1))*dz1(i-1);
dx2d(i-1) = -a*(-a*z1(i-1)-K(i-1,1)*z1d(i-1)+z2(i-1))-dK(i-1,1)*z1d(i-1)-K(i-1,1)*(-a*z1d(i-1)+z2d(i-1));
dq(i-1) = pi/2*cos(t(i-1))*(1-exp(-0.1*t(i-1)))+0.2*pi/2*sin(t(i-1))*t(i-1)*exp(-0.1*t(i-1));
x3d(i-1) = M*(-a*z2(i-1)-K(i-1,2)*z2d(i-1)-N/M*sin(q(i-1))+N/M*sin(x(i-1,1)+q(i-1))+B/M*x(i-1,2)+dx2d(i-1));
if(i-1-delay)<0
dx2d_d(i-1) = -a*(-a*z1d(i-1)+z2d(i-1));
qd(i-1) = q(1);
x3d_d(i-1) = M*(-a*z2d(i-1)-N/M*sin(qd(i-1))+N/M*sin(xd(i-1,1)+qd(i-1))+B/M*xd(i-1,2)+dx2d_d(i-1));
else
dx2d_d(i-1) = dx2d(i-1-delay);
x3d_d(i-1) = x3d(i-1-delay);
end
z3d(i-1) = xd(i-1,3)-x3d_d(i-1);
z3(i-1) = x(i-1,3)-x3d(i-1);
dz2(i-1) = -a*z2(i-1)-K(i-1,2)*z2d(i-1)+1/M*z3(i-1);
dz2d(i-1) = -a*z2d(i-1)+1/M*z3d(i-1);
z2(i) = z2(i-1)+(t(i)-t(i-1))*dz2(i-1);
ddx2d(i-1) = -a*(-a*dz1(i-1)-dK(i-1,1)*z1d(i-1)-K(i-1,1)*dz1d(i-1)+dz2(i-1))-ddK(i-1,1)*z1d(i-1)-dK(i-1,1)*dz1d(i-1)-dK(i-1,1)*(-a*z1d(i-1)+z2d(i-1))-K(i-1,1)*(-a*dz1d(i-1)+dz2d(i-1));
dx3d(i-1) = M*(-a*dz2(i-1)-dK(i-1,2)*z2d(i-1)-K(i-1,2)*dz2d(i-1)-N/M*dq(i-1)*cos(q(i-1))+(x(i-1,2)+dq(i-1))*cos(q(i-1)+x(i-1,1))+B/M*(-N/M*sin(x(i-1,1)+q(i-1))+N/M*sin(q(i-1))-B/M*x(i-1,2)+1/M*x(i-1,3))+ddx2d(i-1));
dz3(i-1) = -a/(2*(1-tau))*z3(i-1)-1/(2*(1-tau))*K(i-1,3)*abs(z3(i-1))^(2*tau-1)*sign(z3(i-1))*abs(z3d(i-1))^(2*(1-tau))+Vp(i-1)/L-0.1/L*sign(z3d(i-1));
z3(i) = z3(i-1)+(t(i)-t(i-1))*dz3(i-1);
u(i-1) = L*(-a/(2*(1-tau))*z3(i-1)+dx3d(i-1)+R/L*x3d(i-1)+Kb/L*x(i-1,2)-0.1/L*sign(z3(i-1))-K(i-1,3)/(2*(1-tau))*abs(z3(i-1))^(2*tau-1)*sign(z3(i-1))*abs(z3d(i-1))^(2*(1-tau)));
dx(i-1,1) = x(i-1,2);
dx(i-1,2) = N/M*sin(q(i-1))-N/M*sin(x(i-1,1)+q(i-1))-B/M*x(i-1,2)+1/M*x(i-1,3);
dx(i-1,3) = -R/L*x(i-1,3)-Kb/L*x(i-1,2)+1/L*u(i-1)+Vp(i-1)/L;
for j=1:length(x0)
x(i,j) = x(i-1,j)+(t(i)-t(i-1))*dx(i-1,j);
end
end
Unrecognized function or variable 'dRh'.
Sam Chak
on 2 Aug 2024
Hi @controlEE
I have attempted to run the simulation, but it has been quite challenging to troubleshoot the Simulink model at this stage. The primary reason for this difficulty is that I do not have access to the mathematical model of the Control Law, which would allow me to evaluate the code against a known standard.
In fact, the mathematical model of the Control Law itself should be cross-checked against the standard procedure of the Backstepping Control design method, as outlined by Professor Petar V. Kokotovic. This step is crucial to ensure the correctness of your control design.
Additionally, I am unfamiliar with the specific parts of your MATLAB code where the delayed states of the prescribed-time control scheme are implemented using the array indexing approach. Your way of implementing the delay differential equations (DDEs) appears to be quite different from the 1st example provided, and it requires further understanding and examination.
Sam Chak
on 5 Aug 2024
Hi @controlEE
Unlike the formulated PID controller, most sophisticated controllers must be designed from scratch in order to satisfy certain forms of stability criteria. If you were to directly use the control formula in Eq. (26), which the authors claimed was derived from the Backstepping procedure, then you would not be able to ascertain whether the control design is correct or not.
I am curious to know if, without restricting yourself to the use of the Strong Prescribed-time Stabilized Nonlinear Periodic-Delayed Feedback Controller (SPTSNPDFC), what other types of controllers you could potentially design from scratch?
controlEE
on 10 Aug 2024
Edited: controlEE
on 10 Aug 2024
Hi @Sam Chak , I need to design the SPTSNPDFC controller for the robot manipulator in the first place . I'll proceed to focus on drawbacks that posiibly can be modified and improved in the corresopnding controller . although PID controllers are quite appropriate and are widely used , however I'm seeking for the new control efforts designed theoritically . besides I'd like to share our ideas and prospectives with each other .
Sam Chak
on 10 Aug 2024
Yes @controlEE, you can design the SPTSNPDFC controller for the robot manipulator, thoroughly examine each term in the control equation to identify any potential issues regarding implementation, and ultimately propose hypothetical solutions to address specific challenges.
However, it is essential to understand that the SPTSNPDFC controller must be designed from scratch following Prof. Kokotovic's Backstepping procedure. The SPTSNPDFC controller cannot be developed simply by substituting values into the seemingly ready-to-implement Eq. (26).
Designing the controller from scratch requires constructing the SPTSNPDFC controller incrementally, ensuring that it satisfies the stability condition at every step. This involves demonstrating that each design step is valid and stable beyond reasonable doubt, in line with Prof. Kokotovic's Backstepping procedure.
A code snippet is provided here (note that the steps to verify the stability condition are not included in the code):
controlEE
on 15 Aug 2024
Edited: controlEE
on 15 Aug 2024
Hi @Sam Chak
I have successfully matched the states and control effort to those depicted in the article.
Moving forward, I plan to make improvements in the system's response and aim to generalize the method further. While the article mentions the control effort in the context of a SISO system, I am considering extending this approach to MIMO systems and other nonlinear systems. I appreciate your guidance as I explore these avenues.
Sam Chak
on 15 Aug 2024
Hi @controlEE
Congratulations! It is excellent to know that your persistence and efforts have paid off. Would you consider posting the full MATLAB code and the Simulink model in the ANSWER section below so that interested researchers can study how you successfully implemented the Strong Prescribed-time Stabilized Nonlinear Periodic-Delayed Feedback Controller (SPTSNPDFC)?
controlEE
on 31 Aug 2024
Edited: controlEE
on 31 Aug 2024
Hi @Sam Chak . Here's the model attached , I hope it helps all the interested researcher to acquire a good prospective in Control Theory.Besides, If you share with me suitable systems and in general opinions which I can apply my controller to .(Strict feedback systems) ,That would be great .
Answers (0)
See Also
Categories
Find more on Mechanical Engineering in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)