-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_kin.m
47 lines (37 loc) · 1010 Bytes
/
test_kin.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
function test_kin(kin)
% clc
N = length(kin.joint_type);
% Make sure kin.P and kin.H are the right sizes
assert(width(kin.P) == N + 1);
assert(width(kin.H) == N);
% Test for 2R and 3R joints
prev_intersection = NaN(3,1);
for i = 1:N-1
j = i+1;
p_ij = kin.P(:,j);
h_i = kin.H(:,i);
h_j = kin.H(:,j);
ab = pinv([h_i h_j]) * p_ij;
dist_ij = norm(p_ij - [h_i h_j] * ab);
if dist_ij < 1e-3
fprintf("Joints %d and %d intersect\n", i, j);
intersection = sum(kin.P(:,1:j),2) + h_j*ab(2);
if norm(intersection - prev_intersection) < 1e-3
fprintf("Joints %d %d %d spherical\n", i-1, i, j);
end
prev_intersection = intersection;
else
prev_intersection = NaN(3,1);
end
end
fprintf("\n");
% Test for 2R|| (and implicitly 3R||) joints
for i = 1:N-1
j = i+1;
h_i = kin.H(:,i);
h_j = kin.H(:,j);
if abs(dot(h_i, h_j)) > 1-1e-3
fprintf("Joints %d and %d parallel\n", i, j);
end
end
end