-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathposerRepresentationConformability.m
83 lines (63 loc) · 3.02 KB
/
poserRepresentationConformability.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function [tcpPoseInBaseCoords,gridPoseInCameraCoords,cameraPoseInGridCoords]=poserRepresentationConformability(RobotPoses,cameraPoses,validcalibposes,varargin)
% set the input pose nature e-g rpy,quaternion etc so that representation could be read and converted
% to homogenous tranformations
% Removes all poses based on reject images by intrinsic calibration
% RobotPoses: Cartesian calibration poses
% correctedPoeses: Corrected cartesian calibration poses
% validcalibposes: Mask (vector) with rejected and accepted images
%DataFormat: can be one of these where input can be 'rpy','quat','HT', where format should be 'xyz|rpy', 'xyz|quaternion','HT'
%%initialize
persistent p;
if isempty(p)
% Set input parser
defaults = struct('DataFormat', 'rpy');
p = inputParser;
p.CaseSensitive = false;
p.addParameter('DataFormat', defaults.DataFormat);
parser = p;
else
parser = p;
end
parser.parse(varargin{:});
DataFormat = validatestring(parser.Results.DataFormat, {'rpy', 'quat','HTvector'}, mfilename, 'DataFormat');
%% robot poses
% Set counter
j = 1;
for i = 1:size(RobotPoses, 1)
if validcalibposes(i)
% Convert to hom matrix
if strcmp(DataFormat,'rpy')
pose = RobotPoses(j,:);
rotationMatrix = rpyToRotationMatrix(pose(4), pose(5), pose(6));%roll,pitch,yaw
translationVec=[pose(1) pose(2) pose(3)];
tform = createHT(rotationMatrix,translationVec);
tcpPoseInBaseCoords(:,:,j) = tform; %normally
% tcpPoseInBaseCoords(:,:,j) = invertHT(tform);
elseif strcmp(DataFormat,'quat')
error('crete the conversion function for quaterinion based o nthe input data, havent done this atm')
elseif strcmp(DataFormat,'HTvector')
pose = RobotPoses(j,:);
tform= reshape(pose,4,[])';
tcpPoseInBaseCoords(:,:,j) = tform;
end
j = j + 1;
end
end
%%
% Set camera poses
j = 1;
for i = 1:size(validcalibposes)
if validcalibposes(i)
% Convert to hom matrix
gridPoseInCameraCoords_invR = inv(cameraPoses.correctedOrientationMatrix(:,:,j));%inverse of the just the orientation
gridPoseInCameraCoords(:,:,j)=createHT(gridPoseInCameraCoords_invR,cameraPoses.correctedTranslationVector(:,:,j));
%deletehis
% [orientation,location] = extrinsicsToCameraPose(cameraPoses.correctedOrientationMatrix(:,:,j),cameraPoses.correctedTranslationVector(:,:,j)) % output is cam2 grid
% gridPoseInCameraCoords(:,:,j)=(createHT(orientation,location));
% or - this should be the correct form, but not sure
% gridPoseInCameraCoords(:,:,j)=inv(createHT(cameraPoses.correctedOrientationMatrix(:,:,j),cameraPoses.correctedTranslationVector(:,:,j)));
cameraPoseInGridCoords(:,:,j) = inv(gridPoseInCameraCoords(:,:,j));%inverse of the orientation and translation
j = j + 1;
end
end
end