AUV-Coop-Assembly
Master Thesis for Robotics Engineering. Cooperative peg-in-hole assembly with two underwater vehicles guided by vision
plotCoopVel.m
1 function plotCoopVel(rootPath, coordName)
2 
3 legFontSize = 19;
4 titleFontSize = 18;
5 ylabFontSize = 17;
6 xlabFontSize = 17;
7 
8 fileName = strcat('coopVel.txt');
9 xDot = importMatrices(strcat(rootPath, coordName, fileName));
10 xDotSqueez = squeeze(xDot);
11 nStep = size(xDot, 3);
12 
13 %millisecond indicated in missionManager
14 global sControlLoop
15 totSecondPassed = sControlLoop*(nStep-1);
16 seconds = 0:sControlLoop:totSecondPassed;
17 
18 global secInsertion
19 
20 
21 figure('Renderer', 'painters', 'Position', [0 0 710 550])
22 subplot(2,1,1)
23 hold on;
24 plot(seconds, xDotSqueez(1:3,:));
25 %vertical line to show where insertion begin
26 plot([secInsertion; secInsertion], [-0.1 0.02]', '--m');
27 text([secInsertion+2], [0.011], {'\rightarrow Inside the hole'}, 'Color','magenta', 'FontSize',14);
28 hold off;
29 
30 xlab = xlabel('time [s]');
31 ylab = ylabel('Velocities [m/s]');
32 tq = title('Cooperative Tool Linear Velocities');
33 leg = legend('$\dot{x}$','$\dot{y}$', '$\dot{z}$');
34 
35 subplot(2,1,2)
36 hold on;
37 plot(seconds, xDotSqueez(4:6,:));
38 %vertical line to show where insertion begin
39 plot([secInsertion; secInsertion], [ylim]', '--m');
40 text([secInsertion+2], [0.0027], {'\rightarrow Inside the hole'}, 'Color','magenta', 'FontSize',14);
41 hold off;
42 xlab2 = xlabel('time [s]');
43 ylab2 = ylabel('Velocities [rad/s]');
44 tq2 = title('Cooperative Tool Angular Velocities');
45 leg2 = legend('$w_x$', '$w_y$', '$w_z$');
46 
47 set(leg, 'Interpreter', 'latex', 'FontSize' , legFontSize);
48 set (tq, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
49 set (ylab, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
50 set (xlab, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
51 set(leg2, 'Interpreter', 'latex', 'FontSize' , legFontSize);
52 set (tq2, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
53 set (ylab2, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
54 set (xlab2, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
55 
56 
57 
58 
59 
60 %% plot vel OLD
61 % figure
62 % hold on;
63 % for i = 1:nRow
64 % a(:) = xDot(i,1,:);
65 % plot(seconds, a);
66 % end
67 % xlabel('time [s]');
68 % ylab = ylabel(strcat('Cooperative vel [m/s], [rad/s]'));
69 % tq = title('Cooperative velocity of tool');
70 %
71 % if nRow == 6
72 % leg = legend('$\dot{x}$','$\dot{y}$', '$\dot{z}$', '$w_x$', '$w_y$', '$w_z$');
73 % elseif nRow == 5
74 % leg = legend('$\dot{x}$','$\dot{y}$', '$\dot{z}$', '$w_y$', '$w_z$');
75 %
76 % end
77 % set(leg, 'Interpreter', 'latex', 'FontSize' , legFontSize);
78 % set (tq, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
79 % set (ylab, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
80 % hold off