Code covered by the BSD License  

Highlights from
Simultaneous Plant and Control Design of an Active Automotive Suspension Using Direct Transcription

image thumbnail

Simultaneous Plant and Control Design of an Active Automotive Suspension Using Direct Transcription

by

 

A toolbox for using Direct Transcription to perform combined plant and control design.

myplot_results(platform)
function myplot_results(platform)
% Generate plots from saved results
% Example myplot_results('pcwin64')

platform = upper(platform);

% Plot results for dt
dt = load(['dt_results_' platform]);
[~,~,~,~,stateCon,objComp] = qcar_new_objective_open();
myplot_dt(dt.out1, dt.t01, dt.t02, objComp, stateCon);

% Plot results for seq
seq = load(['seq_results_' platform]);
myplot_seq(seq.out2, seq.t01, seq.t02, objComp, stateCon);

end

function myplot_dt(out, t01, t02, objComp, stateCon)
% Generate plots for dt
ramp_in = 25/100 * 10;
load IRI_737b
zdot = calc_zdot(road_x, road_z, 10); % Vehicle speed assumed to be 10


% Plot the z_s - z0
myplot_signal(t01, ...
    out.xu{1}(1,:) + out.xu{1}(3,:));
myplot_ylabel('z_s - z_0 (m)');
set(gca, 'YLim', [-0.25 0.05]);

% Plot control input
myplot_signal(t01, ...
    out.xu{1}(5,:));
myplot_ylabel('Control Input (N)');
set(gca, 'YLim', [-2500 1500]);
% Plot the three different criteria
wt = objComp(out.param, out.xu{1}, t01, @(t)ramp_in);
% Plot control input
myplot_signal(t01(2:end), wt(1,:), 'k--', ...
    t01(2:end), wt(2,:), '-', ...
    t01(2:end), wt(3,:), '-.');
myplot_ylabel('Objective');
set(gca, 'YLim', [0 0.06]); 
legend({'Handling', 'Control', 'Comfort'});
set(gca, 'YLim', [0 5]);


% Plot the z_s - z0
myplot_signal(t02, ...
    out.xu{2}(1,:) + out.xu{2}(3,:));
myplot_ylabel('z_s - z_0 (m)');
set(gca, 'YLim', [-0.015 0.01]);

% Plot control input
myplot_signal(t02, ...
    out.xu{2}(5,:));
myplot_ylabel('Control Input (N)');
set(gca, 'YLim', [-500 500]);

% Plot the three different criteria
wt = objComp(out.param, out.xu{2}, t02, @(t)lookup_u(zdot,t));
% Plot control input
myplot_signal(t02(2:end), wt(1,:), 'k--', ...
    t02(2:end), wt(2,:), '-', ...
    t02(2:end), wt(3,:), '-.');
myplot_ylabel('Objective');
set(gca, 'YLim', [0 5]); 
legend({'Handling', 'Control', 'Comfort'});
y1 = evaluateStateConstraints(t01, out.param, out.xu{1}, stateCon(1));
myplot_signal(t01, y1);
myplot_ylabel('State constraints');
y2 = evaluateStateConstraints(t02, out.param, out.xu{2}, stateCon(2));
myplot_signal(t02, y2);
myplot_ylabel('State constraints');

end

function myplot_seq(out, t01, t02, objComp, stateCon)

ramp_in = 25/100 * 10;
load IRI_737b
zdot = calc_zdot(road_x, road_z, 10); % Vehicle speed assumed to be 10


% Plot the z_s - z0
myplot_signal(t01, ...
    out.xu_frames{1}(1,:) + out.xu_frames{1}(3,:));
myplot_ylabel('z_s - z_0 (m)');
set(gca, 'YLim', [-0.25 0.05]);

% Plot control input
myplot_signal(t01, ...
    out.xu_frames{1}(5,:));
myplot_ylabel('Control Input (N)');
set(gca, 'YLim', [-2500 1500]);

% Plot the three different criteria
wt = objComp(out.xd, out.xu_frames{1}, t01, @(t)ramp_in);
% Plot control input
myplot_signal(t01(2:end), wt(1,:), 'k--', ...
    t01(2:end), wt(2,:), '-', ...
    t01(2:end), wt(3,:), '-.');
myplot_ylabel('Objective');
legend({'Handling', 'Control', 'Comfort'});
set(gca, 'YLim', [0 5]);

% Plot the z_s - z0
myplot_signal(t02, ...
    out.xu_frames{2}(1,:) + out.xu_frames{2}(3,:));
myplot_ylabel('z_s - z_0 (m)');
set(gca, 'YLim', [-0.015 0.01]);

% Plot control input
myplot_signal(t02, ...
    out.xu_frames{2}(5,:));
myplot_ylabel('Control Input (N)');
set(gca, 'YLim', [-500 500]);

% Plot the three different criteria
wt = objComp(out.xd, out.xu_frames{2}, t02, @(t)lookup_u(zdot,t));
% Plot control input
myplot_signal(t02(2:end), wt(1,:), 'k--', ...
    t02(2:end), wt(2,:), '-', ...
    t02(2:end), wt(3,:), '-.');
myplot_ylabel('Objective');
set(gca, 'YLim', [0 5]); 
legend({'Handling', 'Control', 'Comfort'});

y1 = evaluateStateConstraints(t01, out.xd, out.xu_frames{1}, stateCon(1));
myplot_signal(t01, y1);
myplot_ylabel('State constraints');
y2 = evaluateStateConstraints(t02, out.xd, out.xu_frames{2}, stateCon(2));
myplot_signal(t02, y2);
myplot_ylabel('State constraints');
end

Contact us