![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1603651/image.png)
Looking for an state controller for NON-linear systems
3 次查看(过去 30 天)
显示 更早的评论
Hello, I have a non-linear state space model with some inputs and outputs and would now like to implement a state feedback (according to ACKERMANN) in SIMULINK. For this I have calculated my feedback coefficients K1, K2 and K3 with the "k=acker(A,b,p)" formula in Matlab.
Now I need a state controller. For this, there is the State Space Controller in the Matlab literature:
Can I use this for my non-linear model? I actually need a non-linear state controller. Which one can I use?
Thank you so much
-Martin
Attached my simulink project: matlab_mi.slx
Thats my model in simulink:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1599796/image.png)
0 个评论
采纳的回答
Sam Chak
2024-1-25
编辑:Sam Chak
2024-1-30
Update: Since the system is nonlinear, traditional methods like Ackermann's method won't be suitable. However, you can still experiment with the suggested fundamental nonlinear state feedback control law in your Simulink model. To ensure the simulation stops when the spacecraft has safely touched down, an 'Events' function has been added.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1603651/image.png)
It's important to note that this controller is conceptualized from a mathematical perspective. There are other practical engineering factors that need to be considered as well. For instance, increasing the value of the primary tuning parameter may initially cause an increase in mass, but it should gradually decrease due to fuel consumption. It wouldn't make sense for the mass to increase at the beginning.
%% Settings and Call ode45 solver
w = 0.037680; % Primary tuning parameter
tspan = [0 3000]; % simulation time
h0 = 15240; % initial descent altitude
hdot0 = -212.5; % initial descent velocity
m0 = 15264; % initial spacecraft mass
x0 = [h0, hdot0, m0];
options = odeset('RelTol', 1e-8, 'AbsTol', 1e-10, 'Events', @touchDownEventFcn);
[t, x] = ode45(@(t, x) LunarModuleEagle(t, x, w), tspan, x0, options);
%% Generate the Control Signal (mdot)
mdot = zeros(1, numel(t));
for j = 1:numel(t)
[~, mdot(j)] = LunarModuleEagle(t(j), x(j,:).', w);
end
init_u = mdot(1) % check if initial mdot ≤ 0 (cannot be > 0)
%% Plot results
figure(1)
subplot(2,1,1)
plot(t/60, x(:,1), 'linewidth', 1.5, 'color', '#528AFA'), grid on
ylabel('h (m)', 'fontsize', 12);
title('Descent Altitude')
subplot(2,1,2)
plot(t/60, x(:,2), 'linewidth', 1.5, 'color', '#FA477A'), grid on
xlabel('t (min)', 'fontsize', 12)
ylabel('h'' (m/s)', 'fontsize', 12);
title('Rate of descent')
figure(2)
subplot(2,1,1)
plot(t/60, x(:,3), 'linewidth', 1.5, 'color', '#E7B03E'), grid on
ylabel('m (kg)', 'fontsize', 12);
title('Total Mass')
% xlim([0 0.02]) % check if mass obeys physical law
subplot(2,1,2)
plot(t/60, mdot, 'linewidth', 1.5, 'color', '#78A19B'), grid on
xlabel('t (min)', 'fontsize', 12)
ylabel('m'' (kg/s)','fontsize', 12);
title('Rate of change of Mass')
%% Fuel consumption
m = x(:,3);
m_used = m0 - m(end)
%% Descending Equations of Motion for the Lunar Module Eagle
function [dxdt, mdot] = LunarModuleEagle(t, x, w)
% definitions
h = x(1); % state 1: descent altitude
hdot = x(2); % state 2: descent velocity
m = x(3); % state 3: spacecraft mass
% parameters
v = 3050; % not sure what to do with this?
Lg = 1.62; % lunar gravity
% state-feedback controller
wn = w;
kd = 2.5; % Secondary tuning parameter (if necessary)
Lg_Off_h = 0.21; % Off upon reaching 21 cm above surface
mdot = (m*(kd*wn*hdot + (wn^2)*h - Lg*(sign(x(1) - Lg_Off_h) + 1)/2))/v;
% mdot = -14.8018 % OP's fixed value
% ODEs
dxdt(1,1) = hdot;
dxdt(2,1) = (- v*mdot - m*Lg)/m; % m*h" = - v*m' - m*g;
dxdt(3,1) = mdot;
end
%% Stop simulation when the spacecraft has safely touched down on lunar surface
function [position,isterminal,direction] = touchDownEventFcn(t, x)
position = x(1); % The state variable that we want to be zero
isterminal = 1; % Halt integration
direction = -1; % The zero can be approached when x1 is decreasing
end
9 个评论
Sam Chak
2024-2-1
The lunar descent dynamics is given by
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606266/image.png)
If we design
as (this was actually my initial design)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606271/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606276/image.png)
and substitute it into the dynamics, we get
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606281/image.png)
Expanding it, we can cancel out the effect of lunar gravity
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606286/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606291/image.png)
which compensated system dynamics can be simplified as a simple harmonic motion:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606296/image.png)
However, due to the inaccuracies or oversimplifications in the descent dynamics of Eq. (1), if we implement the controller in Eq. (2), the descent altitude h (from Eq. 3) won't reach zero in finite time. The controller will keep firing the thrust, perfectly counteracting the effect of gravity until all the fuel is burned out.
One way to address this issue is by modifying Eq. (2) and disabling the "gravity canceller" term when the descent altitude
is reached, allowing lunar gravity to take over. In my simulation, I let the spacecraft "drop" from 21 cm above the surface.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606301/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1606306/image.png)
Jose Lorenzo
2024-4-25
Hello The variable "v" refers to the velocity of the exhaust gases with respect to the spacecraft. [m/sec]. The value of this variable must be applied while the ship has fuel, so that when has used up all the fuel, v must be worth 0 Therefore, it is necessary to have the net mass of the lunar module. After reviewing the website https://nssdc.gsfc.nasa.gov/nmc/spacecraft/display.action?id=1969-059C I have calculated that the net mass must be 4821 Kg. Below I show the code I am using:
function [dxdt, u] = LunarModuleEagle(t, x, w)
% Descending Equations of Motion for the Lunar Module Eagle
% definitions
h = x(1); % state 1: descent altitude
hdot = x(2); % state 2: descent velocity
m = x(3); % state 3: spacecraft mass
m_neta = 4821;
if (m > m_neta)
v = 3050; % velocity of the exhaust gases with respect to the spacecraft
else
v = 0;
end
Lg = 1.623; % lunar gravity [m/seg^2]
% state-feedback controller
wn = w;
kd = 2.5; % Secondary tuning parameter (if necessary)
Lg_Off_h = 0.21; % Off upon reaching 21 cm above surface
u = (m*(kd*wn*hdot + (wn^2)*h - Lg*(sign(x(1) - Lg_Off_h) + 1)/2))/v;
% u = -14.8018 % OP's fixed value
% ODEs
dxdt(1,1) = hdot;
dxdt(2,1) = (- v*u - m*Lg)/m; % m*h" = - v*m' - m*g;
dxdt(3,1) = u;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!