Skip to content

Commit

Permalink
Updated visualization in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
rustlluk committed Mar 18, 2022
1 parent 08bd148 commit 5f45c01
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 24 deletions.
2 changes: 2 additions & 0 deletions @Robot/getResultKinematics.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
end
mResults = results.(fnames{field});
% corrections = results - default

corrs.(fnames{field}) = zeros(size(mResults));

corrs.(fnames{field})(:,1:3,:,:) = mResults(:,1:3,:,:)/optim.unitsCoef-robot.structure.kinematics.(fnames{field})(:,1:3,1);
corrs.(fnames{field})(:,4:6,:,:) = mResults(:,4:6,:,:)-robot.structure.kinematics.(fnames{field})(:,4:6,1);
% wrap to [-pi,pi]
Expand Down
3 changes: 2 additions & 1 deletion @Robot/prepareDataset.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@
camFrames = [camFrames{:}];
uniqueFrames = [uniqueFrames; {camFrames.name}'];
end
if isstruct(datasets.(part){dataset}.rtMat)
if isfield(datasets.(part){dataset}, 'rtMat') && isstruct(datasets.(part){dataset}.rtMat)
rtFields = fieldnames(datasets.(part){dataset}.rtMat)';
else
rtFields = {};
datasets.(part){dataset}.rtMat = [];
end
% Preallocate arrays
links(length(datasets.(part){dataset}.frame), 1) = Link();
Expand Down
6 changes: 3 additions & 3 deletions Calib/errors_fcn.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
end
end
% concat all results into output variable, with right scalling
error_vec = [(distances - refDist)*approach.selftouch, ...
plane_distances*approach.planes, dist_from_ext*approach.external, ...
proj_dist*approach.projection];
error_vec = [reshape((distances - refDist)*approach.selftouch, 1, []), ...
reshape(plane_distances*approach.planes, 1, []), reshape(dist_from_ext*approach.external, 1, []), ...
reshape(proj_dist*approach.projection, 1, [])];
end

Binary file modified MRC.mlappinstall
Binary file not shown.
5 changes: 4 additions & 1 deletion UserData/Robots/iCub/loadDatasetICub.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
nmbPoses = length(idxs);
else
nmbPoses = varargin{1};
if ischar(nmbPoses)
nmbPoses = str2double(nmbPoses);
end
end
data2(nmbPoses+1:end,:) = [];
eyeAngle = data2(:,29)/2;
Expand Down Expand Up @@ -111,7 +114,7 @@
dataset2.cameras(:,2) = 1;
end
cam_frames = robot.findLinkByType('eye');
dh_pars = robot.structure.defaultKinematics;
dh_pars = robot.structure.kinematics;
right_finger = robot.findLink('rightHandFinger');
left_finger = robot.findLink('leftHandFinger');
parents = struct('rightArm', robot.links{3}, 'leftArm', robot.links{3}, 'torso', robot.links{1}, ...
Expand Down
15 changes: 8 additions & 7 deletions Visualisation/plotErrorBars.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ function plotErrorBars(folders,varargin)
errors=errors.errors;
optim = info.optim;
if strcmp(units,'m') && strcmp(optim.units,'mm')
const = 0.001;
const = repmat(0.001, 1, 8);
elseif strcmp(units,'mm') && strcmp(optim.units,'m')
const = 1000;
const = repmat(1000, 1, 8);
else
const = 1;
const = ones(1, 8);
end
const(end-1:end) = 1;
for l = 1:numLines
mins(l, fi) = min(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const;
maxs(l, fi) = max(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const;
means(l, fi) = mean(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const;
stds(l, fi) = std(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const;
mins(l, fi) = min(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const(l);
maxs(l, fi) = max(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const(l);
means(l, fi) = mean(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const(l);
stds(l, fi) = std(errors(lines(l), optim.repetitions*(pert-1)+(1:optim.repetitions)))*const(l);
end
end

Expand Down
9 changes: 5 additions & 4 deletions Visualisation/plotErrorsBoxplots.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ function plotErrorsBoxplots(folders,varargin)
robot=info.rob;
if strcmp(errorsType,'errors')
% get cellArray from arrays
distsTs = num2cell(errors(13:16,(pert-1)*optim.repetitions+(1:optim.repetitions)).*const,2);
distsTs = num2cell([errors(13:15,(pert-1)*optim.repetitions+(1:optim.repetitions)).*const; errors(16,(pert-1)*optim.repetitions+(1:optim.repetitions))],2);

if p.Results.train
distsTr = num2cell(errors(5:8,(pert-1)*optim.repetitions+(1:optim.repetitions)).*const,2);
distsTr = num2cell([errors(5:7,(pert-1)*optim.repetitions+(1:optim.repetitions)).*const;errors(8,(pert-1)*optim.repetitions+(1:optim.repetitions))],2);
else
distsTr = num2cell(errors(9:12,(pert-1)*optim.repetitions+(1:optim.repetitions)).*const,2);
distsTr = num2cell([errors(9:11,(pert-1)*optim.repetitions+(1:optim.repetitions)).*const; errors(12,(pert-1)*optim.repetitions+(1:optim.repetitions))],2);
end
else
distsTs=cell(4,1);
Expand Down Expand Up @@ -203,7 +204,7 @@ function plotErrorsBoxplots(folders,varargin)
ax.XAxis.TickLabelInterpreter = 'latex';
ax.YAxis.TickLabelInterpreter = 'latex';
xlabel('Dataset');
ylabel(['Error [',units,']']);
ylabel(['Error [',units,'/px]']);
title('Comparison of RMS errors')
%get y limits for lines
yl=ylim;
Expand Down
16 changes: 8 additions & 8 deletions Visualisation/plotErrorsHistogram.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ function plotErrorsHistogram(folder,varargin)
errors=errors.errorsAll;
optim = info.optim;
if strcmp(units,'m') && strcmp(optim.units,'mm')
const = 0.001;
const = repmat(0.001, 1, 4);
elseif strcmp(units,'mm') && strcmp(optim.units,'m')
const = 1000;
const = repmat(1000, 1, 4);
else
const = 1;
const = ones(1, 4);
end
const(end) = 1;
robot=info.rob;
distsTs=cell(4,1);
distsTr=cell(4,1);
Expand All @@ -74,14 +75,14 @@ function plotErrorsHistogram(folder,varargin)
distsTr{i,:}=[distsTr{i,:};nan];
else
dist=[errors{12+i}{(pert-1)*optim.repetitions+(1:optim.repetitions)}];
distsTs{i,:}=[distsTs{i,:};(dist(:)').*const];
distsTs{i,:}=[distsTs{i,:};(dist(:)').*const(i)];
dist=[errors{4+i}{(pert-1)*optim.repetitions+(1:optim.repetitions)}];
distsTs{i,:}=[distsTs{i,:},(dist(:)').*const];
distsTs{i,:}=[distsTs{i,:},(dist(:)').*const(i)];

dist=[errors{0+i}{(pert-1)*optim.repetitions+(1:optim.repetitions)}];
distsTr{i,:}=[distsTr{i,:};(dist(:)').*const];
distsTr{i,:}=[distsTr{i,:};(dist(:)').*const(i)];
dist=[errors{8+i}{(pert-1)*optim.repetitions+(1:optim.repetitions)}];
distsTr{i,:}=[distsTr{i,:},(dist(:)').*const];
distsTr{i,:}=[distsTr{i,:},(dist(:)').*const(i)];
end
end

Expand All @@ -95,7 +96,6 @@ function plotErrorsHistogram(folder,varargin)
optTypes2={'Selftouch Before', 'Planes Before', 'External Before', 'Projection Before'};
colorTypes=[[233,114,77]; [214,215,39]; [149,196,243]; [121,204,179]]./255;
colorTypes2=[[33,114,177]; [14,215,39]; [0,0,0]; [255,0,255]]./255;

for i=1:4
% if values for given calibration type
if any(~isnan(distsTr{i,:}))
Expand Down
Binary file modified gui.mlapp
Binary file not shown.

0 comments on commit 5f45c01

Please sign in to comment.