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
%% 4) Plot Results
figure();
f = figure();
dims = {'X','Y','Z'};
for i=1:3
subplot(3,1,i);
plot(data.tout,data.F_user_est(:,i));
plot(data.tout,data.F_user_est(:,i),'LineWidth',lw);
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),'--');
hold off;
legend('Estimate','Actual');
% legend('Estimate','Actual','Unfiltered Estimate');
xlabel('Time (s)');
ylabel('Force (N)');
title([dims{i} ' Direction - Haptic Force Input']);
ylabel([dims{i} '-dir (N)']);
% title([dims{i} ' Direction - Haptic Force Input']);
ax = gca;
ax.FontSize = fs;
end
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();
subplot(3,1,1);
plot(T,X(:,1));
plot(T,X(:,1),'LineWidth',lw);
hold on;
plot(T,Xd(:,1),'r--');
plot(T,Xd(:,1),'r--','LineWidth',lw);
hold off;
ylabel('x (m)');
title(title_string);
legend('Actual','Desired','Location','Best');
ax = gca;
ax.FontSize = fs;
subplot(3,1,2);
plot(T,X(:,2));
plot(T,X(:,2),'LineWidth',lw);
hold on;
plot(T,Xd(:,2),'r--');
plot(T,Xd(:,2),'r--','LineWidth',lw);
hold off;
ylabel('y (m)');
legend('Actual','Desired','Location','Best');
ax = gca;
ax.FontSize = fs;
subplot(3,1,3);
plot(T,X(:,3));
plot(T,X(:,3),'LineWidth',lw);
hold on;
plot(T,Xd(:,3),'r--');
plot(T,Xd(:,3),'r--','LineWidth',lw);
hold off;
ylabel('z (m)');
xlabel('Time (s)');
legend('Actual','Desired','Location','Best');
ax = gca;
ax.FontSize = fs;
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);
plot(T,X(:,4));
plot(T,X(:,4),'LineWidth',lw);
hold on;
plot(T,Xd(:,4),'r--');
plot(T,Xd(:,4),'r--','LineWidth',lw);
hold off;
ylabel('x_{dot} (m/s)');
% ylabel('x_{dot} (m/s)');
ylabel('$\dot{x}$ (m/s)', 'Interpreter','latex');
title(title_string);
legend('Actual','Desired');
ax = gca;
ax.FontSize = fs;
subplot(3,1,2);
plot(T,X(:,5));
plot(T,X(:,5),'LineWidth',lw);
hold on;
plot(T,Xd(:,5),'r--');
plot(T,Xd(:,5),'r--','LineWidth',lw);
hold off;
ylabel('y_{dot} (m/s)');
% ylabel('y_{dot} (m/s)');
ylabel('$\dot{y}$ (m/s)', 'Interpreter','latex');
legend('Actual','Desired');
ax = gca;
ax.FontSize = fs;
subplot(3,1,3);
plot(T,X(:,6));
plot(T,X(:,6),'LineWidth',lw);
hold on;
plot(T,Xd(:,6),'r--');
plot(T,Xd(:,6),'r--','LineWidth',lw);
hold off;
ylabel('z_{dot} (m/s)');
% ylabel('z_{dot} (m/s)');
ylabel('$\dot{z}$ (m/s)', 'Interpreter','latex');
xlabel('Time (s)');
legend('Actual','Desired');
ax = gca;
ax.FontSize = fs;
movegui(location);
end
......
function [] = paper_plot_admittance_control(d)
%PAPER_PLOT_ADMITTANCE_CONTROL
lw = 2; %line width
fs = 12; %font size
%% 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
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
f.Children(6).YLim = [-0.1, 0.6]; %x
f.Children(4).YLim = [-0.1, 0.1]; %y
f.Children(2).YLim = [1.4, 1.6]; %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 line widths
% Save the plot
saveas(f,'Plotting/saved_plots/sim_payload_position.png')
saveas(f,'Plotting/saved_plots/sim_payload_position.eps')
%% 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
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
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