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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
close all;
|
| 2 |
+
clear;
|
| 3 |
+
|
| 4 |
+
dataset = 'robot_logger_device_2024_10_16_13_07_30.mat';
|
| 5 |
+
|
| 6 |
+
load(dataset);
|
| 7 |
+
|
| 8 |
+
jnt_list = robot_logger_device.tsid_fixed_cartesian.joints_state.torques.tsid.elements_names;
|
| 9 |
+
|
| 10 |
+
time_cmd = squeeze(robot_logger_device.tsid_fixed_cartesian.joints_state.torques.tsid.timestamps)';
|
| 11 |
+
time_meas = squeeze(robot_logger_device.joints_state. ...
|
| 12 |
+
torques.timestamps)';
|
| 13 |
+
trq_meas = squeeze(robot_logger_device.joints_state.torques.data)';
|
| 14 |
+
[~, start_idx] = min(abs(time_meas - time_cmd(1)));
|
| 15 |
+
time_meas = time_meas(start_idx:end);
|
| 16 |
+
trq_meas = trq_meas(start_idx:end, :);
|
| 17 |
+
time_cmd = squeeze(robot_logger_device.tsid_fixed_cartesian.joints_state.torques.tsid.timestamps)';
|
| 18 |
+
time_end = min(time_meas(end), time_cmd(end));
|
| 19 |
+
time_meas = time_meas(time_meas <= time_end);
|
| 20 |
+
time_cmd = time_cmd(time_cmd <= time_end);
|
| 21 |
+
trq_meas = trq_meas(1:length(time_meas), :);
|
| 22 |
+
time_start = time_meas(1);
|
| 23 |
+
time_meas = time_meas - time_start;
|
| 24 |
+
time_cmd = time_cmd - time_start;
|
| 25 |
+
time_cmd = time_cmd - time_cmd(1);
|
| 26 |
+
|
| 27 |
+
trq_cmd = squeeze(robot_logger_device.tsid_fixed_cartesian.joints_state.torques.tsid.data)';
|
| 28 |
+
trq_cmd = trq_cmd(:, end-11:end);
|
| 29 |
+
trq_meas = trq_meas(:, end-11:end);
|
| 30 |
+
|
| 31 |
+
right_foot_pos_des = squeeze(robot_logger_device.tsid_fixed_cartesian.right_foot.position.desired.data)';
|
| 32 |
+
right_foot_pos_meas = squeeze(robot_logger_device.tsid_fixed_cartesian.right_foot.position.measured.data)';
|
| 33 |
+
|
| 34 |
+
right_foot_ori_des = squeeze(robot_logger_device.tsid_fixed_cartesian.right_foot.orientation.desired.data)';
|
| 35 |
+
right_foot_ori_meas = squeeze(robot_logger_device.tsid_fixed_cartesian.right_foot.orientation.measured.data)';
|
| 36 |
+
|
| 37 |
+
left_foot_pos_des = squeeze(robot_logger_device.tsid_fixed_cartesian.left_foot.position.desired.data)';
|
| 38 |
+
left_foot_pos_meas = squeeze(robot_logger_device.tsid_fixed_cartesian.left_foot.position.measured.data)';
|
| 39 |
+
|
| 40 |
+
left_foot_ori_des = squeeze(robot_logger_device.tsid_fixed_cartesian.left_foot.orientation.desired.data)';
|
| 41 |
+
left_foot_ori_meas = squeeze(robot_logger_device.tsid_fixed_cartesian.left_foot.orientation.measured.data)';
|
| 42 |
+
|
| 43 |
+
% Plot trq_meas vs trq_cmd in 6 subplots in 1 figure and the other 6 in a new figure
|
| 44 |
+
figure;
|
| 45 |
+
for i=1:6
|
| 46 |
+
subplot(3,2,i);
|
| 47 |
+
plot(time_meas, trq_meas(:, i), 'LineWidth', 2);
|
| 48 |
+
hold on;
|
| 49 |
+
plot(time_cmd, trq_cmd(:, i), 'LineWidth', 2);
|
| 50 |
+
title(['Joint ', jnt_list(i)], 'FontSize', 14);
|
| 51 |
+
legend('Measured', 'Commanded');
|
| 52 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 53 |
+
ylabel('Torque [Nm]', 'FontSize', 12);
|
| 54 |
+
% Disable latex interpreter for titles
|
| 55 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 56 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 57 |
+
end
|
| 58 |
+
|
| 59 |
+
figure;
|
| 60 |
+
for i=7:12
|
| 61 |
+
subplot(3,2,i-6);
|
| 62 |
+
plot(time_meas, trq_meas(:, i), 'LineWidth', 2);
|
| 63 |
+
hold on;
|
| 64 |
+
plot(time_cmd, trq_cmd(:, i), 'LineWidth', 2);
|
| 65 |
+
title(['Joint ', jnt_list(i)], 'FontSize', 14);
|
| 66 |
+
legend('Measured', 'Commanded');
|
| 67 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 68 |
+
ylabel('Torque [Nm]', 'FontSize', 12);
|
| 69 |
+
% Disable latex interpreter for titles
|
| 70 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 71 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 72 |
+
end
|
| 73 |
+
|
| 74 |
+
% Plot tracking of right foot position and orientation
|
| 75 |
+
figure;
|
| 76 |
+
subplot(2,1,1);
|
| 77 |
+
plot(time_cmd, right_foot_pos_des, 'LineWidth', 2);
|
| 78 |
+
hold on;
|
| 79 |
+
plot(time_cmd, right_foot_pos_meas, 'LineWidth', 2);
|
| 80 |
+
title('Right foot position', 'FontSize', 14);
|
| 81 |
+
legend('Desired', 'Measured');
|
| 82 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 83 |
+
ylabel('Position [m]', 'FontSize', 12);
|
| 84 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 85 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 86 |
+
|
| 87 |
+
subplot(2,1,2);
|
| 88 |
+
plot(time_cmd, right_foot_ori_des, 'LineWidth', 2);
|
| 89 |
+
hold on;
|
| 90 |
+
plot(time_cmd, right_foot_ori_meas, 'LineWidth', 2);
|
| 91 |
+
title('Right foot orientation', 'FontSize', 14);
|
| 92 |
+
legend('Desired', 'Measured');
|
| 93 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 94 |
+
ylabel('Orientation [deg]', 'FontSize', 12);
|
| 95 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 96 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 97 |
+
|
| 98 |
+
% Plot tracking of left foot position and orientation
|
| 99 |
+
figure;
|
| 100 |
+
subplot(2,1,1);
|
| 101 |
+
plot(time_cmd, left_foot_pos_des, 'LineWidth', 2);
|
| 102 |
+
hold on;
|
| 103 |
+
plot(time_cmd, left_foot_pos_meas, 'LineWidth', 2);
|
| 104 |
+
title('Left foot position', 'FontSize', 14);
|
| 105 |
+
legend('Desired', 'Measured');
|
| 106 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 107 |
+
ylabel('Position [m]', 'FontSize', 12);
|
| 108 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 109 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 110 |
+
|
| 111 |
+
subplot(2,1,2);
|
| 112 |
+
plot(time_cmd, left_foot_ori_des, 'LineWidth', 2);
|
| 113 |
+
hold on;
|
| 114 |
+
plot(time_cmd, left_foot_ori_meas, 'LineWidth', 2);
|
| 115 |
+
title('Left foot orientation', 'FontSize', 14);
|
| 116 |
+
legend('Desired', 'Measured');
|
| 117 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 118 |
+
ylabel('Orientation [deg]', 'FontSize', 12);
|
| 119 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 120 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 121 |
+
|
| 122 |
+
% Plot tracking error of torques
|
| 123 |
+
% Align data to the same time vector time_cmd
|
| 124 |
+
trq_meas = interp1(time_meas, trq_meas, time_cmd);
|
| 125 |
+
|
| 126 |
+
trq_err = trq_meas - trq_cmd;
|
| 127 |
+
figure;
|
| 128 |
+
for i=1:6
|
| 129 |
+
subplot(3,2,i);
|
| 130 |
+
plot(time_cmd, trq_err(:, i), 'LineWidth', 2);
|
| 131 |
+
title(['Joint ', jnt_list(i)], 'FontSize', 14);
|
| 132 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 133 |
+
ylabel('Error [Nm]', 'FontSize', 12);
|
| 134 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 135 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 136 |
+
end
|
| 137 |
+
|
| 138 |
+
figure;
|
| 139 |
+
for i=7:12
|
| 140 |
+
subplot(3,2,i-6);
|
| 141 |
+
plot(time_cmd, trq_err(:, i), 'LineWidth', 2);
|
| 142 |
+
title(['Joint ', jnt_list(i)], 'FontSize', 14);
|
| 143 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 144 |
+
ylabel('Error [Nm]', 'FontSize', 12);
|
| 145 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 146 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 147 |
+
end
|
| 148 |
+
|
| 149 |
+
% Plot tracking error of right foot position and orientation
|
| 150 |
+
right_foot_pos_err = right_foot_pos_meas - right_foot_pos_des;
|
| 151 |
+
right_foot_ori_err = right_foot_ori_meas - right_foot_ori_des;
|
| 152 |
+
figure;
|
| 153 |
+
subplot(2,1,1);
|
| 154 |
+
plot(time_cmd, right_foot_pos_err, 'LineWidth', 2);
|
| 155 |
+
title('Right foot position error', 'FontSize', 14);
|
| 156 |
+
legend('x', 'y', 'z');
|
| 157 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 158 |
+
ylabel('Error [m]', 'FontSize', 12);
|
| 159 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 160 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 161 |
+
|
| 162 |
+
subplot(2,1,2);
|
| 163 |
+
plot(time_cmd, right_foot_ori_err, 'LineWidth', 2);
|
| 164 |
+
title('Right foot orientation error', 'FontSize', 14);
|
| 165 |
+
legend('x', 'y', 'z', 'w');
|
| 166 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 167 |
+
ylabel('Error [deg]', 'FontSize', 12);
|
| 168 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 169 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 170 |
+
|
| 171 |
+
% Plot tracking error of left foot position and orientation
|
| 172 |
+
left_foot_pos_err = left_foot_pos_meas - left_foot_pos_des;
|
| 173 |
+
left_foot_ori_err = left_foot_ori_meas - left_foot_ori_des;
|
| 174 |
+
figure;
|
| 175 |
+
subplot(2,1,1);
|
| 176 |
+
plot(time_cmd, left_foot_pos_err, 'LineWidth', 2);
|
| 177 |
+
title('Left foot position error', 'FontSize', 14);
|
| 178 |
+
legend('x', 'y', 'z');
|
| 179 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 180 |
+
ylabel('Error [m]', 'FontSize', 12);
|
| 181 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 182 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|
| 183 |
+
|
| 184 |
+
subplot(2,1,2);
|
| 185 |
+
plot(time_cmd, left_foot_ori_err, 'LineWidth', 2);
|
| 186 |
+
title('Left foot orientation error', 'FontSize', 14);
|
| 187 |
+
legend('x', 'y', 'z', 'w');
|
| 188 |
+
xlabel('Time [s]', 'FontSize', 12);
|
| 189 |
+
ylabel('Error [deg]', 'FontSize', 12);
|
| 190 |
+
set(get(gca, 'title'), 'interpreter', 'none');
|
| 191 |
+
set(gca, 'LineWidth', 1.5, 'FontSize', 12);
|