AUV-Coop-Assembly
Master Thesis for Robotics Engineering. Cooperative peg-in-hole assembly with two underwater vehicles guided by vision
plotYDotDivided.m
1 function plotYDotDivided(rootPath, robotName, ydotName)
2 
3 legFontSize = 19;
4 titleFontSize = 18;
5 ylabFontSize = 17;
6 xlabFontSize = 17;
7 
8 yDotstr = strcat( '/', ydotName, '.txt');
9 yDot = importMatrices(strcat(rootPath, robotName, yDotstr));
10 if strcmp(ydotName, "yDotFinalWithCollision")
11  yDotNoCol = importMatrices(strcat(rootPath, robotName, "/yDotFinal.txt"));
12  yDot = yDot - yDotNoCol;
13 
14 end
15 nStep = size(yDot, 3);
16 
17 %millisecond indicated in missionManager
18 global sControlLoop
19 totSecondPassed = sControlLoop*(nStep-1);
20 seconds = 0:sControlLoop:totSecondPassed;
21 
22 global secInsertion
23 
24 
25 %% plot joint commands
26 figure('Renderer', 'painters', 'Position', [0 0 750 990])
27 subplot(3,1,1);
28 
29 hold on;
30 for i = 1:4
31  a(:) = yDot(i,1,:);
32  plot(seconds, a);
33 end
34 plot([secInsertion; secInsertion], [-0.06,0.03]', '--m');
35 text([secInsertion+2], [0.024], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
36 hold off;
37 xlab = xlabel('time [s]');
38 leg = legend('$\dot{q}_1$','$\dot{q}_2$', '$\dot{q}_3$', '$\dot{q}_4$');
39 ylab = ylabel('Joint velocities [rad/s]');
40 if strcmp(robotName, 'g500_A')
41  tq = title('Joint command for Robot A');
42 else
43  tq = title('Joint command for Robot B');
44 end
45 ylim([-0.06,0.03]);
46 set(leg, 'Interpreter', 'latex', 'FontSize' , legFontSize);
47 set (tq, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
48 set (ylab, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
49 set (xlab, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
50 
51 
52 %% plot vehicle command divided in angle e lin
53 
54 subplot(3,1,2);
55 hold on;
56 for i = 5:7
57  a(:) = yDot(i,1,:);
58  plot(seconds, a);
59 end
60 plot([secInsertion; secInsertion], [-0.02, 0.12]', '--m');
61 text([secInsertion+2], [0.11], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
62 hold off;
63 xlab1 = xlabel('time [s]');
64 ylab1 = ylabel('Linear velocity [m/s]');
65 if strcmp(robotName, 'g500_A')
66  tq1 = title('Vehicle linear velocity command for Robot A');
67 else
68  tq1 = title('Vehicle linear velocity command for Robot B');
69 end
70 leg1 = legend('$\dot{x}$','$\dot{y}$', '$\dot{z}$');
71 set(leg1, 'Interpreter', 'latex', 'FontSize' , legFontSize);
72 set (tq1, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
73 set (ylab1, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
74 set (xlab1, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
75 ylim([-0.02, 0.12]);
76 
77 
78 
79 subplot(3,1,3);
80 hold on;
81 for i = 8:10
82  a(:) = yDot(i,1,:);
83  plot(seconds, a);
84 end
85 plot([secInsertion; secInsertion], [-0.005, 0.045]', '--m');
86 text([secInsertion+2], [0.041], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
87 hold off;
88 xlab2 = xlabel('time [s]');
89 ylab2 = ylabel('Angular velocity [rad/s]');
90 if strcmp(robotName, 'g500_A')
91  tq2 = title('Vehicle angular velocity command for Robot A');
92 else
93  tq2 = title('Vehicle angular velocity command for Robot B');
94 end
95 leg2 = legend('$w_x$', '$w_y$', '$w_z$');
96 set(leg2, 'Interpreter', 'latex', 'FontSize' , legFontSize);
97 set (tq2, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
98 set (ylab2, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
99 set (xlab2, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
100 ylim([-0.005, 0.045])