Looking for an state controller for NON-linear systems

8 views (last 30 days)
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
Attached my simulink project: matlab_mi.slx
Thats my model in simulink:

Accepted Answer

Sam Chak
Sam Chak on 25 Jan 2024
Edited: Sam Chak on 30 Jan 2024
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.
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);
init_u = mdot(1) % check if initial mdot ≤ 0 (cannot be > 0)
init_u = -8.1194e-05
%% Plot results
plot(t/60, x(:,1), 'linewidth', 1.5, 'color', '#528AFA'), grid on
ylabel('h (m)', 'fontsize', 12);
title('Descent Altitude')
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')
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
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)
m_used = 4.9042e+03
%% 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;
%% 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
Martin Mittrenga
Martin Mittrenga on 1 Feb 2024
Hello Sam, the repatriation finally worked. I inserted mdot as a function block. Now my question: How did you come across the mdot?
Sam Chak
Sam Chak on 1 Feb 2024
The lunar descent dynamics is given by
... Eq. (1)
If we design as (this was actually my initial design)
... Eq. (2)
and substitute it into the dynamics, we get
Expanding it, we can cancel out the effect of lunar gravity
which compensated system dynamics can be simplified as a simple harmonic motion:
. ... Eq. (3)
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.
... Eq. (4)

Sign in to comment.

More Answers (0)


Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!