1 function plotTask(rootPath, robotName, taskName)
3 filename = strcat(rootPath, robotName, "/", taskName);
11 refs = importMatrices(strcat(filename, '/reference.txt'));
12 act = importMatrices(strcat(filename, '/activation.txt'));
15 nStep = size(refs, 3);
17 %millisecond indicated in missionManager
19 totSecondPassed = sControlLoop*(nStep-1);
20 seconds = 0:sControlLoop:totSecondPassed;
24 %% plot refs (vector n*1)
25 % figure('Renderer', 'painters', 'Position', [0 0 650 500])
30 % xlim([secInsertion;180]);
32 % xlab = xlabel('time [s]');
34 % if strcmp(taskName, 'PIPE_REACHING_GOAL')
35 % leg = legend('$\dot{x}$
','$\dot{y}$
', '$\dot{z}$
', '$w_x$
', '$w_y$
', '$w_z$
'); 36 % ylab = ylabel('references [m/s], [rad/s]
'); 37 % elseif strcmp(taskName, 'JOINT_LIMIT
') 38 % leg = legend('$\dot{q}_1$
','$\dot{q}_2$
', '$\dot{q}_3$
', '$\dot{q}_4$
'); 39 % ylab = ylabel('references [rad/s]
'); 40 % elseif strcmp(taskName, 'HORIZONTAL_ATTITUDE
') 41 % leg = legend('$\dot{\bar{x}}$
'); 42 % ylab = ylabel('references
'); 43 % elseif strcmp(taskName, 'ARM_SHAPE
') 44 % if nRow == 1 % scalar type (norm) 45 % leg = legend('$\dot{\bar{x}}$
'); 46 % ylab = ylabel('reference (norm)
'); 48 % leg = legend('$\dot{q}_1$
','$\dot{q}_2$
', '$\dot{q}_3$
', '$\dot{q}_4$
'); 49 % ylab = ylabel('references [rad/s]
'); 51 % elseif strcmp(taskName, 'FORCE_INSERTION
') 52 % if nRow == 1 %only force norm 53 % leg = legend('$\dot{\bar{x}}$
'); 54 % ylab = ylabel('reference (norm)
'); 56 % elseif nRow == 2 %norm of force and torque. BEST METHOD 57 % leg = legend('$\dot{\bar{x}}_f$
', '$\dot{\bar{x}}_m$
'); 58 % ylab = ylabel('reference
'); 59 % if strcmp(robotName, 'g500_A
') 60 % tr = title('Robot A: Force-Torque
Task Reference');
62 % tr = title(
'Robot B: Force-Torque Task Reference');
65 % elseif nRow == 3 % only force
66 % leg = legend(
'$\dot{x}$',
'$\dot{y}$',
'$\dot{z}$');
67 % ylab = ylabel(
'reference []');
72 %
if ~strcmp(taskName,
'FORCE_INSERTION')
73 % tr = title(strcat(robotName,
" ", taskName));
75 %
set(leg,
'Interpreter',
'latex',
'FontSize' , legFontSize );
76 %
set (tr,
'Interpreter',
'latex',
'FontSize', titleFontSize);
77 %
set (ylab,
'Interpreter',
'latex',
'FontSize', ylabFontSize);
78 %
set (xlab,
'Interpreter',
'latex',
'FontSize', xlabFontSize);
82 % % error = importMatrices(strcat(filename,
'/error.txt'));
83 % % nRow = size(refs, 1);
84 % % nStep = size(refs, 3);
86 % % %millisecond indicated in missionManager
87 % % totSecondPassed = sControlLoop*(nStep-1);
88 % % seconds = 0:sControlLoop:totSecondPassed;
93 % % a(:) = error(i,1,:);
96 % % xlab = xlabel(
'time [s]');
98 % %
if strcmp(taskName,
'PIPE_REACHING_GOAL')
99 % % leg = legend(
'$x_{err}$',
'$y_{err}$',
'$z_{err}$',
'$pitch_{err}$',
'$yaw_{err}$');
100 % % ylab = ylabel(
'error [m],[rad]');
101 % % elseif strcmp(taskName,
'JOINT_LIMIT')
102 % % leg = legend(
'$q1_{err}$',
'$q2_{err}$',
'$q3_{err}$',
'$q4_{err}$');
103 % % ylab = ylabel(
'error [rad]');
104 % % elseif strcmp(taskName,
'ARM_SHAPE')
105 % %
if nRow == 1 % scalar type (norm)
106 % % leg = legend(
'$norm_{err}$');
107 % % ylab = ylabel(
'error (norm)');
109 % % leg = legend(
'$q1_{err}$',
'$q2_{err}$',
'$q3_{err}$',
'$q4_{err}$');
110 % % ylab = ylabel(
'errors [rad]');
112 % % elseif strcmp(taskName,
'FORCE_INSERTION')
113 % %
if nRow == 1 %only force norm
114 % % leg = legend(
'$norm_{err}$');
115 % % ylab = ylabel(
'error (norm)');
117 % % elseif nRow == 2 %norm of force and torque. BEST METHOD
118 % % leg = legend(
'$err_f$',
'$err_m$');
119 % % ylab = ylabel(
'error (norm)');
121 % % elseif nRow == 3 % only force
122 % % leg = legend(
'$x_{err}$',
'$y_{err}$',
'$z_{err}$');
123 % % ylab = ylabel(
'error [m]');
127 % % te = title(strcat(robotName,
" ", taskName));
128 % %
set(leg,
'Interpreter',
'latex',
'FontSize' , legFontSize);
129 % %
set (te,
'Interpreter',
'latex',
'FontSize', titleFontSize);
130 % %
set (ylab,
'Interpreter',
'latex',
'FontSize', ylabFontSize);
135 % %% plot activations
136 % act = importMatrices(strcat(filename,
'/activation.txt'));
137 % nRow = size(refs, 1);
138 % nStep = size(refs, 3);
140 % %millisecond indicated in missionManager
141 % totSecondPassed = sControlLoop*(nStep-1);
142 % seconds = 0:sControlLoop:totSecondPassed;
144 % figure(
'Renderer',
'painters',
'Position', [0 0 650 500])
149 % xlim([secInsertion;180]);
152 % xlab = xlabel(
'time [s]');
154 %
if strcmp(taskName,
'JOINT_LIMIT')
155 % leg = legend(
'$A_{11}$',
'$A_{22}$',
'$A_{33}$',
'$A_{44}$');
156 % ylab = ylabel(
'activations');
157 % elseif strcmp(taskName,
'HORIZONTAL_ATTITUDE')
158 % leg = legend(
'$A$');
159 % ylab = ylabel(
'activation');
160 % elseif strcmp(taskName,
'ARM_SHAPE')
161 %
if nRow == 1 % scalar type (norm)
162 % leg = legend(
'$A$');
163 % ylab = ylabel(
'activation');
165 % leg = legend(
'$A_{11}$',
'$A_{22}$',
'$A_{33}$',
'$A_{44}$');
166 % ylab = ylabel(
'activations');
168 % elseif strcmp(taskName,
'FORCE_INSERTION')
169 %
if nRow == 1 % only norm force
170 % leg = legend(
'$A$');
171 % ylab = ylabel(
'activation');
174 % elseif nRow == 2 %norm of force and torque. BEST METHOD
175 % leg = legend(
'$a_f$',
'$a_m$');
176 % ylab = ylabel(
'activations');
177 %
if strcmp(robotName,
'g500_A')
178 % ta = title(
'Robot A: Force-Torque Task Activation');
180 % ta = title(
'Robot B: Force-Torque Task Activation');
183 % elseif nRow == 3 % only force
184 % leg = legend(
'$A_{11}$',
'$A_{22}$',
'$A_{33}$');
185 % ylab = ylabel(
'activations');
189 %
if ~strcmp(taskName,
'FORCE_INSERTION')
190 % ta = title(strcat(robotName,
" " ,taskName));
192 %
set(leg,
'Interpreter',
'latex',
'FontSize' , legFontSize);
193 %
set (ta,
'Interpreter',
'latex',
'FontSize' , titleFontSize);
194 %
set (ylab,
'Interpreter',
'latex',
'FontSize', ylabFontSize);
195 %
set (xlab,
'Interpreter',
'latex',
'FontSize', xlabFontSize);
198 %% plot activation and ref
for force torque divided
199 if strcmp(taskName,
'FORCE_INSERTION')
200 actSqueez = squeeze(act);
202 figure('Renderer', 'painters', 'Position', [0 0 710 550])
205 plot(seconds, actSqueez(1,:));
206 xlaba = xlabel('time [s]');
207 ylaba= ylabel('Activation');
208 if strcmp(robotName, 'g500_A')
209 ta = title('Robot A: Force-Torque
Task Activation - Force part');
211 ta = title('Robot B: Force-Torque
Task Activation - Force part');
213 xlim([secInsertion;180]);
215 set (ta, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
216 set (ylaba, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
217 set (xlaba, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
220 plot(seconds, actSqueez(2,:));
221 xlaba = xlabel('time [s]');
222 ylaba= ylabel('Activation');
223 if strcmp(robotName, 'g500_A')
224 ta = title('Robot A: Force-Torque
Task Activation - Torque part');
226 ta = title('Robot B: Force-Torque
Task Activation - Torque part');
228 xlim([secInsertion;180]);
230 set (ta, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
231 set (ylaba, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
232 set (xlaba, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
234 refSqueez = squeeze(refs);
235 figure('Renderer', 'painters', 'Position', [0 0 710 550])
238 plot(seconds, refSqueez(1,:));
239 xlaba = xlabel('time [s]');
240 ylaba= ylabel('Reference');
241 if strcmp(robotName, 'g500_A')
242 ta = title('Robot A: Force-Torque
Task Reference - Force part');
244 ta = title('Robot B: Force-Torque
Task Reference - Force part');
246 xlim([secInsertion;180]);
248 set (ta, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
249 set (ylaba, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
250 set (xlaba, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
253 plot(seconds, refSqueez(2,:));
254 xlaba = xlabel('time [s]');
255 ylaba= ylabel('Reference');
256 if strcmp(robotName, 'g500_A')
257 ta = title('Robot A: Force-Torque
Task Reference - Torque part');
259 ta = title('Robot B: Force-Torque
Task Reference - Torque part');
261 xlim([secInsertion;180]);
263 set (ta, 'Interpreter', 'latex', 'FontSize' , titleFontSize);
264 set (ylaba, 'Interpreter', 'latex', 'FontSize', ylabFontSize);
265 set (xlaba, 'Interpreter', 'latex', 'FontSize', xlabFontSize);
270 %% plot jacob-1*ref (for ydot generated by the single task) only for force insertion for now
276 if strcmp(taskName, 'FORCE_INSERTION')
277 jacobs = importMatrices(strcat(rootPath, robotName, '/forceJacob.txt'));
278 yDotSingle = zeros(10,nStep);
281 yDotSingle(:,i) = pinv(jacobs(:,:,i)) * refs(:,:,i);
284 figure('Renderer', 'painters', 'Position', [0 0 750 990])
286 plot (seconds, yDotSingle(1:4,:))
287 xlab1 = xlabel('time [s]');
288 leg1 = legend('$\dot{q}_1$
','$\dot{q}_2$
', '$\dot{q}_3$
', '$\dot{q}_4$
'); 289 ylab1 = ylabel('Joint velocities [rad/s]
'); 290 if strcmp(robotName, 'g500_A
') 291 tq1 = title('Joint command
for Robot A
'); 293 tq1 = title('Joint command
for Robot B
'); 295 xlim([secInsertion;180]); 297 set(leg1, 'Interpreter
', 'latex
', 'FontSize
' , legFontSize); 298 set (tq1, 'Interpreter
', 'latex
', 'FontSize
' , titleFontSize); 299 set (ylab1, 'Interpreter
', 'latex
', 'FontSize
', ylabFontSize); 300 set (xlab1, 'Interpreter
', 'latex
', 'FontSize
', xlabFontSize); 303 plot (seconds, yDotSingle(5:7,:)) 304 xlab2 = xlabel('time [s]
'); 305 leg2 = legend('$\dot{x}$
','$\dot{y}$
', '$\dot{z}$
'); 306 ylab2 = ylabel('Linear velocity [m/s]
'); 307 if strcmp(robotName, 'g500_A
') 308 tq2 = title('Vehicle linear velocity command
for Robot A
'); 310 tq2 = title('Vehicle linear velocity command
for Robot B
'); 312 xlim([secInsertion;180]); 315 set(leg2, 'Interpreter
', 'latex
', 'FontSize
' , legFontSize); 316 set (tq2, 'Interpreter
', 'latex
', 'FontSize
' , titleFontSize); 317 set (ylab2, 'Interpreter
', 'latex
', 'FontSize
', ylabFontSize); 318 set (xlab2, 'Interpreter
', 'latex
', 'FontSize
', xlabFontSize); 322 plot (seconds, yDotSingle(8:10,:)) 323 xlab3 = xlabel('time [s]
'); 324 leg3 = legend('$w_x$
', '$w_y$
', '$w_z$
'); 325 ylab3 = ylabel('Angular velocity [rad/s]
'); 326 if strcmp(robotName, 'g500_A
') 327 tq3 = title('Vehicle angular velocity command
for Robot A
'); 329 tq3 = title('Vehicle angular velocity command
for Robot B
'); 331 xlim([secInsertion;180]); 334 set(leg3, 'Interpreter
', 'latex
', 'FontSize
' , legFontSize); 335 set (tq3, 'Interpreter
', 'latex
', 'FontSize
' , titleFontSize); 336 set (ylab3, 'Interpreter
', 'latex
', 'FontSize
', ylabFontSize); 337 set (xlab3, 'Interpreter
', 'latex
', 'FontSize
', xlabFontSize); ABSTRACT class task. Each task is a derived class of this class. It contains all the variable that th...