AUV-Coop-Assembly
Master Thesis for Robotics Engineering. Cooperative peg-in-hole assembly with two underwater vehicles guided by vision
plotYDotDivided3.m
1 function plotYDotDivided3(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 subplot(1,2,1)
30 hold on;
31 for i = 1:4
32  a(:) = yDot(i,1,:);
33  plot(seconds, a);
34 end
35 plot([secInsertion; secInsertion], [-0.06,0.03]', '--m');
36 text([secInsertion+2], [0.024], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
37 hold off;
38 xlab = xlabel('time [s]');
39 leg = legend('$\dot{q}_1$','$\dot{q}_2$', '$\dot{q}_3$', '$\dot{q}_4$');
40 ylab = ylabel('Joint velocities [rad/s]');
41 if strcmp(robotName, 'g500_A')
42  tq = title('Joint command for Robot A');
43 else
44  tq = title('Joint command for Robot B');
45 end
46 ylim([-0.06,0.03]);
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 
52 subplot(1,2,2)
53 hold on;
54 for i = 1:4
55  a(:) = yDot(i,1,:);
56  plot(seconds, a);
57 end
58 plot([secInsertion; secInsertion], [-0.06,0.03]', '--m');
59 text([secInsertion+2], [0.024], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
60 hold off;
61 xlab = xlabel('time [s]');
62 leg = legend('$\dot{q}_1$','$\dot{q}_2$', '$\dot{q}_3$', '$\dot{q}_4$');
63 ylab = ylabel('Joint velocities [rad/s]');
64 if strcmp(robotName, 'g500_A')
65  tq = title('Joint command for Robot A');
66 else
67  tq = title('Joint command for Robot B');
68 end
69 ylim([-0.06,0.03]);
70 set(leg, 'Interpreter', 'latex', 'FontSize' , legFontSize);
71 set (tq, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
72 set (ylab, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
73 set (xlab, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
74 
75 
76 %% plot vehicle command divided in angle e lin
77 
78 subplot(3,1,2);
79 hold on;
80 for i = 5:7
81  a(:) = yDot(i,1,:);
82  plot(seconds, a);
83 end
84 plot([secInsertion; secInsertion], [-0.02, 0.12]', '--m');
85 text([secInsertion+2], [0.11], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
86 hold off;
87 xlab1 = xlabel('time [s]');
88 ylab1 = ylabel('Linear velocity [m/s]');
89 if strcmp(robotName, 'g500_A')
90  tq1 = title('Vehicle linear velocity command for Robot A');
91 else
92  tq1 = title('Vehicle linear velocity command for Robot B');
93 end
94 leg1 = legend('$\dot{x}$','$\dot{y}$', '$\dot{z}$');
95 set(leg1, 'Interpreter', 'latex', 'FontSize' , legFontSize);
96 set (tq1, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
97 set (ylab1, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
98 set (xlab1, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
99 ylim([-0.02, 0.12]);
100 
101 
102 
103 subplot(3,1,3);
104 hold on;
105 for i = 8:10
106  a(:) = yDot(i,1,:);
107  plot(seconds, a);
108 end
109 plot([secInsertion; secInsertion], [-0.005, 0.045]', '--m');
110 text([secInsertion+2], [0.041], {'\rightarrow Inside the hole'}, 'Color', 'magenta', 'FontSize',14);
111 hold off;
112 xlab2 = xlabel('time [s]');
113 ylab2 = ylabel('Angular velocity [rad/s]');
114 if strcmp(robotName, 'g500_A')
115  tq2 = title('Vehicle angular velocity command for Robot A');
116 else
117  tq2 = title('Vehicle angular velocity command for Robot B');
118 end
119 leg2 = legend('$w_x$', '$w_y$', '$w_z$');
120 set(leg2, 'Interpreter', 'latex', 'FontSize' , legFontSize);
121 set (tq2, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
122 set (ylab2, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
123 set (xlab2, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
124 ylim([-0.005, 0.045])