-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfix_the_path.m
49 lines (29 loc) · 1006 Bytes
/
fix_the_path.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
poseGraph = robotics.PoseGraph;
data = load('output_path.mat');
path = data.output_path;
N = size(path, 1);
addRelativePose(poseGraph, path{506}.');
for idx = 3 : (1135 - 504)
past = nodes(poseGraph, idx-1);
vec = path{idx+504}.';
tx = past(1);
ty = past(2);
theta = - past(3);
ct = cos(theta);
st = sin(theta);
R = [ct, -st; st, ct];
xy = [(vec(1) - tx), (vec(2) - ty)];
xy = xy * (R');
newTheta = -angdiff(vec(3), past(3));
%newTheta = - angdiff(vec(3), past(3));
addRelativePose(poseGraph, [xy(1) xy(2) newTheta]);
end
%addRelativePose(poseGraph, [1 1 0]);
%addRelativePose(poseGraph,[0,0,0],[1 0 0 1 0 1],100,1300) ;
% addRelativePose(poseGraph,[0,0,0],[1 0 0 1 0 1],500,1100) ;
% addRelativePose(poseGraph,[0,0,0],[1 0 0 1 0 1],700,900) ;
addRelativePose(poseGraph,[0,0,0],[1 0 0 1 0 1],2,631) ;
poseGraph = optimizePoseGraph(poseGraph);
show(poseGraph);
disp(poseGraph);
node = nodes(poseGraph);