Commit 4af3153d authored by mmroma's avatar mmroma
Browse files

Done formatting admittance controller plots

parent c65f434f
function [] = plotHapticForceEstimate(data, location) function [f] = plotHapticForceEstimate(data, location,lw,fs)
%plotHapticForceEstimate %plotHapticForceEstimate
%% 4) Plot Results %% 4) Plot Results
figure(); f = figure();
dims = {'X','Y','Z'}; dims = {'X','Y','Z'};
for i=1:3 for i=1:3
subplot(3,1,i); subplot(3,1,i);
plot(data.tout,data.F_user_est(:,i)); plot(data.tout,data.F_user_est(:,i),'LineWidth',lw);
hold on; hold on;
plot(data.tout,data.F_user(:,i)); plot(data.tout,data.F_user(:,i),'LineWidth',lw);
% plot(data.tout,data.F_user_est_unfilt(:,i),'--'); % plot(data.tout,data.F_user_est_unfilt(:,i),'--');
hold off; hold off;
legend('Estimate','Actual'); legend('Estimate','Actual');
% legend('Estimate','Actual','Unfiltered Estimate'); % legend('Estimate','Actual','Unfiltered Estimate');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Force (N)'); ylabel([dims{i} '-dir (N)']);
title([dims{i} ' Direction - Haptic Force Input']); % title([dims{i} ' Direction - Haptic Force Input']);
ax = gca;
ax.FontSize = fs;
end end
movegui(location); movegui(location);
......
function [f] = plot_position(T,X,Xd,title_string,location) function [f] = plot_position(T,X,Xd,title_string,location,lw,fs)
f = figure(); f = figure();
subplot(3,1,1); subplot(3,1,1);
plot(T,X(:,1)); plot(T,X(:,1),'LineWidth',lw);
hold on; hold on;
plot(T,Xd(:,1),'r--'); plot(T,Xd(:,1),'r--','LineWidth',lw);
hold off; hold off;
ylabel('x (m)'); ylabel('x (m)');
title(title_string); title(title_string);
legend('Actual','Desired','Location','Best'); legend('Actual','Desired','Location','Best');
ax = gca;
ax.FontSize = fs;
subplot(3,1,2); subplot(3,1,2);
plot(T,X(:,2)); plot(T,X(:,2),'LineWidth',lw);
hold on; hold on;
plot(T,Xd(:,2),'r--'); plot(T,Xd(:,2),'r--','LineWidth',lw);
hold off; hold off;
ylabel('y (m)'); ylabel('y (m)');
legend('Actual','Desired','Location','Best'); legend('Actual','Desired','Location','Best');
ax = gca;
ax.FontSize = fs;
subplot(3,1,3); subplot(3,1,3);
plot(T,X(:,3)); plot(T,X(:,3),'LineWidth',lw);
hold on; hold on;
plot(T,Xd(:,3),'r--'); plot(T,Xd(:,3),'r--','LineWidth',lw);
hold off; hold off;
ylabel('z (m)'); ylabel('z (m)');
xlabel('Time (s)'); xlabel('Time (s)');
legend('Actual','Desired','Location','Best'); legend('Actual','Desired','Location','Best');
ax = gca;
ax.FontSize = fs;
movegui(location); movegui(location);
......
function [] = plot_velocity(T,X,Xd,title_string,location) function [f] = plot_velocity(T,X,Xd,title_string,location,lw,fs)
figure(); f = figure();
subplot(3,1,1); subplot(3,1,1);
plot(T,X(:,4)); plot(T,X(:,4),'LineWidth',lw);
hold on; hold on;
plot(T,Xd(:,4),'r--'); plot(T,Xd(:,4),'r--','LineWidth',lw);
hold off; hold off;
ylabel('x_{dot} (m/s)'); % ylabel('x_{dot} (m/s)');
ylabel('$\dot{x}$ (m/s)', 'Interpreter','latex');
title(title_string); title(title_string);
legend('Actual','Desired'); legend('Actual','Desired');
ax = gca;
ax.FontSize = fs;
subplot(3,1,2); subplot(3,1,2);
plot(T,X(:,5)); plot(T,X(:,5),'LineWidth',lw);
hold on; hold on;
plot(T,Xd(:,5),'r--'); plot(T,Xd(:,5),'r--','LineWidth',lw);
hold off; hold off;
ylabel('y_{dot} (m/s)'); % ylabel('y_{dot} (m/s)');
ylabel('$\dot{y}$ (m/s)', 'Interpreter','latex');
legend('Actual','Desired'); legend('Actual','Desired');
ax = gca;
ax.FontSize = fs;
subplot(3,1,3); subplot(3,1,3);
plot(T,X(:,6)); plot(T,X(:,6),'LineWidth',lw);
hold on; hold on;
plot(T,Xd(:,6),'r--'); plot(T,Xd(:,6),'r--','LineWidth',lw);
hold off; hold off;
ylabel('z_{dot} (m/s)'); % ylabel('z_{dot} (m/s)');
ylabel('$\dot{z}$ (m/s)', 'Interpreter','latex');
xlabel('Time (s)'); xlabel('Time (s)');
legend('Actual','Desired'); legend('Actual','Desired');
ax = gca;
ax.FontSize = fs;
movegui(location); movegui(location);
end end
......
function [] = paper_plot_admittance_control(d) function [] = paper_plot_admittance_control(d)
%PAPER_PLOT_ADMITTANCE_CONTROL %PAPER_PLOT_ADMITTANCE_CONTROL
lw = 2; %line width
fs = 12; %font size
%% 1) Payload Position %% 1) Payload Position
f = plot_position(d.tout, d.payload_X, d.Xd_load,'','northwest'); f = plot_position(d.tout, d.payload_X, d.Xd_load,'','northwest',lw,fs);
% Adjust ylims % Adjust ylims
extra_ylims = [-0.05, 0.05]; f.Children(6).YLim = [-0.1, 0.6]; %x
f.Children(6).YLim = f.Children(6).YLim + extra_ylims; %x f.Children(4).YLim = [-0.1, 0.1]; %y
f.Children(4).YLim = f.Children(4).YLim + extra_ylims; %y f.Children(2).YLim = [1.4, 1.6]; %z
f.Children(2).YLim = f.Children(2).YLim + extra_ylims; %z % extra_ylims = [-0.05, 0.05];
% f.Children(6).YLim = f.Children(6).YLim + extra_ylims; %x
% f.Children(4).YLim = f.Children(4).YLim + extra_ylims; %y
% f.Children(2).YLim = f.Children(2).YLim + extra_ylims; %z
% Adjust font size and boldness % Adjust font size and boldness
% Adjust line widths % Adjust line widths
% Save the plot % Save the plot
saveas(f,'Plotting/saved_plots/sim_payload_position.png')
saveas(f,'Plotting/saved_plots/sim_payload_position.eps')
%% 2) Payload Velocity %% 2) Payload Velocity
plot_velocity(d.tout, d.payload_X, d.Xd_load,'','northeast'); f = plot_velocity(d.tout, d.payload_X, d.Xd_load,'','northeast',lw,fs);
% Adjust ylims
f.Children(6).YLim = [-0.1, 0.2]; %x
f.Children(4).YLim = [-0.1, 0.1]; %y
f.Children(2).YLim = [-0.1, 0.1]; %z
% Adjust font size and boldness
% Adjust line widths
% Save the plot
saveas(f,'Plotting/saved_plots/sim_payload_velocity.png')
saveas(f,'Plotting/saved_plots/sim_payload_velocity.eps')
%% 3) Haptic Force Estimate %% 3) Haptic Force Estimate
plotHapticForceEstimate(d,'southwest'); f = plotHapticForceEstimate(d,'southwest',lw,fs);
% Adjust ylims
f.Children(6).YLim = [-0.1, 0.6]; %x
f.Children(4).YLim = [-0.1, 0.1]; %y
f.Children(2).YLim = [-0.1, 0.1]; %z
% Adjust font size and boldness
% Adjust line widths
% Save the plot
saveas(f,'Plotting/saved_plots/sim_haptic_force_estimate.png')
saveas(f,'Plotting/saved_plots/sim_haptic_force_estimate.eps')
end end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment