bug: factorGraph does not work for relative measurement angles
显示 更早的评论
I tried to add relative pose measurements of 2 adjacent nodes using factorGraph's object function factorTwoPoseSE3, but no matter how much I should modify the relative angle “relZ”,“relY”,“relX” any variables(i.e. the number of quaternions), the optimized result graph remains the same, which is apparently a big problem?
If this is not the case, how do I modify the code to achieve the correct optimisation result that I want?
Design a plane rectangle, its observed 4 absolute coordinate points (0,0), (1,0), (1,1), (0,1), (0,1), node (node) number 1,2,3,4, respectively, in the last node 4 observed node 1 relative coordinates for (0.8,0), that is, closed loop , you can see that the last node error is 0.2. that is, this pose graph contains 4 edges, The first 3 of these are odometers and the last one is a closed loop edge.
% Since factorTwoPoseSE2 cannot specify a starting point for the time being, se3 is used for this purpose.
abspos = [0,0,0,eul2quat([0,0,0],"ZYX"); % rotate 0 about Z axis
1,0,0,eul2quat([pi/2,0,0],"ZYX"); % rotate 90*pi/180 about Z axis
1,1,0,eul2quat([pi,0,0],"ZYX"); % rotate 180*pi/180 about Z axis
0,1,0,eul2quat([3*pi/2,0,0],"ZYX")]; % rotate 270*pi/180 about Z axis
% no matter how much I should modify these relZ,relY,relX any values, the result newNodes does't change???
relZ = pi/2;
relY = 0;
relX = 0;
relPose = [1,0,0,eul2quat([relZ,relY,relX]);
1,0,0,eul2quat([relZ,relY,relX]);
1,0,0,eul2quat([relZ,relY,relX]);
0.8,0,0,eul2quat([relZ,relY,relX])];
fg = factorGraph();
pf = factorPoseSE3Prior(1,Measurement=[0,0,0, 1,0,0,0]);
addFactor(fg,pf);
nodeID = [1 2];
f = factorTwoPoseSE3(nodeID,Measurement=relPose(1,:));% odometry
addFactor(fg,f);
nodeID = [2 3];
f = factorTwoPoseSE3(nodeID,Measurement=relPose(2,:));% odometry
addFactor(fg,f);
nodeID = [3 4];
f = factorTwoPoseSE3(nodeID,Measurement=relPose(3,:));% odometry
addFactor(fg,f);
nodeID = [4 1];
f = factorTwoPoseSE3(nodeID,Measurement=relPose(end,:));% loop closure
addFactor(fg,f);
% optimize
optns = factorGraphSolverOptions();
optimize(fg,optns);
newNodes = [fg.nodeState(1);
fg.nodeState(2);
fg.nodeState(3);
fg.nodeState(4)]
figure;
plot(newNodes(:,1),newNodes(:,2),'b-',Marker='.')
hold on;grid on;
plot(newNodes([4,1],1),newNodes([4,1],2),'r-',Marker='.')
text(newNodes(:,1),newNodes(:,2),string(1:4))
title('after factorGraph(3D) optimize')
----------------------------------
Additionly, according to the factorTwoPoseSE3 official documentation "Measured relative pose, specified as a seven-element row vector of the form [dx dy dz dqw dqx dqy dqz]. dx, dy, and dz are the change in position in x, y, and z respectively. dqw, dqx, dqy, and dqz are the change in quaternion rotation in w, x, y, and z respectively."
So, I have made the following changes to the relpos and it seems that the optimisation graphs are not correct, which is very confusing!
relPose = diff(abspos);
relPose = [relPose;
abspos(1,:)-abspos(end,:)];

3 个评论
Zheng Dong
2023-1-9
Hi Cui,
The measurement is relative to the ego frame not the world frame, which is the same as the relPose input in poseGraph. As for the result you got for the SE3 case, we are investigating on it now. We will add answers below if we get any updates.
Thanks,
Zheng
xingxingcui
2023-1-11
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Localization Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

