30 using namespace gtsam;
54 static Symbol body_P_cam1_key(
'P', 1);
55 static Symbol body_P_cam2_key(
'P', 2);
56 static Symbol body_P_cam3_key(
'P', 3);
59 static Key poseExtrinsicKey1(body_P_cam1_key);
60 static Key poseExtrinsicKey2(body_P_cam2_key);
68 static double missing_uR = std::numeric_limits<double>::quiet_NaN();
70 vector<StereoPoint2> stereo_projectToMultipleCameras(
const StereoCamera&
cam1,
74 vector<StereoPoint2> measurements_cam;
79 measurements_cam.push_back(cam1_uv1);
80 measurements_cam.push_back(cam2_uv1);
81 measurements_cam.push_back(cam3_uv1);
83 return measurements_cam;
97 EXPECT(
p.getVerboseCheirality() ==
false);
98 EXPECT(
p.getThrowCheirality() ==
false);
103 p.setRankTolerance(100);
104 p.setEnableEPI(
true);
105 p.setLandmarkDistanceThreshold(200);
106 p.setDynamicOutlierRejectionThreshold(3);
107 p.setRetriangulationThreshold(1
e-2);
112 EXPECT(
p.getTriangulationParameters().enableEPI ==
true);
190 double expectedError = 0.0;
234 double expectedError = 0.0;
260 StereoPoint2 cam2_uv_right_missing(cam2_uv.
uL(),missing_uR,cam2_uv.
v());
278 factor1.add(cam2_uv_right_missing,
x2, body_P_cam2_key,
K2);
281 double expectedError = 0.0;
297 StereoPoint2 cam1_uv_right_missing(cam1_uv.
uL(),missing_uR,cam1_uv.
v());
298 factor2.add(cam1_uv_right_missing,
x1, body_P_cam1_key,
K2);
299 factor2.add(cam2_uv_right_missing,
x2, body_P_cam2_key,
K2);
341 factor1->add(cam1_uv,
x1, body_P_cam1_key,
K);
342 factor1->add(cam2_uv,
x2, body_P_cam2_key,
K);
351 vector<std::shared_ptr<Cal3_S2Stereo> > Ks;
356 poseKeys.push_back(
x1);
357 poseKeys.push_back(
x2);
360 extrinsicKeys.push_back(body_P_cam1_key);
361 extrinsicKeys.push_back(body_P_cam2_key);
389 Point3 landmark3(3, 0, 3.0);
392 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
394 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
396 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
400 poseKeys.push_back(
x1);
401 poseKeys.push_back(
x2);
402 poseKeys.push_back(
x3);
405 extrinsicKeys.push_back(body_P_cam1_key);
406 extrinsicKeys.push_back(body_P_cam2_key);
407 extrinsicKeys.push_back(body_P_cam3_key);
412 smartFactor1->add(measurements_l1, poseKeys, extrinsicKeys,
K2);
415 smartFactor2->add(measurements_l2, poseKeys, extrinsicKeys,
K2);
418 smartFactor3->add(measurements_l3, poseKeys, extrinsicKeys,
K2);
420 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
425 Pose3 body_Pose_cam3 = Pose3::Identity();
438 values.
insert(body_P_cam3_key, body_Pose_cam3 * noise_pose);
455 Rot3(0, -0.0314107591, 0.99950656, -0.99950656, -0.0313952598,
456 -0.000986635786, 0.0314107591, -0.999013364, -0.0313952598),
463 Point3 landmark1_smart = *smartFactor1->point();
464 Point3 landmark2_smart = *smartFactor2->point();
465 Point3 landmark3_smart = *smartFactor3->point();
497 values2.
insert(
x3, w_Pose_cam3 * noise_pose);
498 values2.
insert(
L(1), landmark1_smart);
499 values2.
insert(
L(2), landmark2_smart);
500 values2.
insert(
L(3), landmark3_smart);
505 graph2.addPrior(
x1, w_Pose_cam1, noisePrior);
506 graph2.addPrior(
x2, w_Pose_cam2, noisePrior);
510 bool verboseCheirality =
true;
552 Point3 landmark3(3, 0, 3.0);
555 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
557 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
559 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
563 poseKeys.push_back(
x1);
564 poseKeys.push_back(
x2);
565 poseKeys.push_back(
x3);
567 Symbol body_P_cam_key(
'P', 0);
569 extrinsicKeys.push_back(body_P_cam_key);
570 extrinsicKeys.push_back(body_P_cam_key);
571 extrinsicKeys.push_back(body_P_cam_key);
576 smartFactor1->add(measurements_l1, poseKeys, extrinsicKeys,
K2);
579 smartFactor2->add(measurements_l2, poseKeys, extrinsicKeys,
K2);
582 smartFactor3->add(measurements_l3, poseKeys, extrinsicKeys,
K2);
584 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
631 Point3 landmark3(3, 0, 3.0);
634 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
636 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
638 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
641 double initialError_expected, initialError_actual;
644 poseKeys.push_back(
x1);
645 poseKeys.push_back(
x2);
646 poseKeys.push_back(
x3);
649 extrinsicKeys.push_back(body_P_cam1_key);
650 extrinsicKeys.push_back(body_P_cam2_key);
651 extrinsicKeys.push_back(body_P_cam3_key);
656 smartFactor1->add(measurements_l1, poseKeys, extrinsicKeys,
K2);
659 smartFactor2->add(measurements_l2, poseKeys, extrinsicKeys,
K2);
662 smartFactor3->add(measurements_l3, poseKeys, extrinsicKeys,
K2);
664 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
668 Pose3 body_Pose_cam2 = body_Pose_cam1;
669 Pose3 body_Pose_cam3 = body_Pose_cam1;
679 values.
insert(body_P_cam1_key, body_Pose_cam1 * noise_pose);
680 values.
insert(body_P_cam2_key, body_Pose_cam2 * noise_pose);
682 values.
insert(body_P_cam3_key, body_Pose_cam3 * noise_pose);
698 poseKeys.push_back(
x1);
699 poseKeys.push_back(
x2);
700 poseKeys.push_back(
x3);
703 extrinsicKeys.push_back(body_P_cam1_key);
704 extrinsicKeys.push_back(body_P_cam1_key);
705 extrinsicKeys.push_back(body_P_cam1_key);
710 smartFactor1->add(measurements_l1, poseKeys, extrinsicKeys,
K2);
713 smartFactor2->add(measurements_l2, poseKeys, extrinsicKeys,
K2);
716 smartFactor3->add(measurements_l3, poseKeys, extrinsicKeys,
K2);
718 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
731 values.
insert(body_P_cam1_key, body_Pose_cam1 * noise_pose);
767 Point3 landmark3(3, 0, 3.0);
770 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
772 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
774 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
778 poseKeys.push_back(
x1);
779 poseKeys.push_back(
x2);
780 poseKeys.push_back(
x3);
782 Symbol body_P_cam_key(
'P', 0);
784 extrinsicKeys.push_back(body_P_cam_key);
785 extrinsicKeys.push_back(body_P_cam_key);
786 extrinsicKeys.push_back(body_P_cam_key);
791 smartFactor1->add(measurements_l1, poseKeys, extrinsicKeys,
K2);
794 smartFactor2->add(measurements_l2, poseKeys, extrinsicKeys,
K2);
797 smartFactor3->add(measurements_l3, poseKeys, extrinsicKeys,
K2);
806 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
823 values.
insert(body_P_cam_key, body_Pose_cam*noise_pose);
889 Point3 landmark3(3, 0, 3.0);
892 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
894 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
896 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
900 poseKeys.push_back(
x1);
901 poseKeys.push_back(
x2);
902 poseKeys.push_back(
x3);
905 extrinsicKeys.push_back(body_P_cam1_key);
906 extrinsicKeys.push_back(body_P_cam1_key);
907 extrinsicKeys.push_back(body_P_cam3_key);
912 smartFactor1->add(measurements_l1, poseKeys, extrinsicKeys,
K2);
915 smartFactor2->add(measurements_l2, poseKeys, extrinsicKeys,
K2);
918 smartFactor3->add(measurements_l3, poseKeys, extrinsicKeys,
K2);
927 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
945 values.
insert(body_P_cam1_key, body_Pose_cam*noise_pose);
946 values.
insert(body_P_cam3_key, body_Pose_cam*noise_pose);
996 Point3 landmark3(5, 0, 3.0);
998 Point2Vector measurements_cam1, measurements_cam2, measurements_cam3;
1006 vector<StereoPoint2> measurements_cam1_stereo, measurements_cam2_stereo, measurements_cam3_stereo;
1007 for(
size_t k=0; k<measurements_cam1.size();k++)
1008 measurements_cam1_stereo.push_back(
StereoPoint2(measurements_cam1[k].
x() , missing_uR , measurements_cam1[k].
y()));
1010 for(
size_t k=0; k<measurements_cam2.size();k++)
1011 measurements_cam2_stereo.push_back(
StereoPoint2(measurements_cam2[k].
x() , missing_uR , measurements_cam2[k].
y()));
1013 for(
size_t k=0; k<measurements_cam3.size();k++)
1014 measurements_cam3_stereo.push_back(
StereoPoint2(measurements_cam3[k].
x() , missing_uR , measurements_cam3[k].
y()));
1017 poseKeys.push_back(
x1);
1018 poseKeys.push_back(
x2);
1019 poseKeys.push_back(
x3);
1021 Symbol body_P_cam_key(
'P', 0);
1023 extrinsicKeys.push_back(body_P_cam_key);
1024 extrinsicKeys.push_back(body_P_cam_key);
1025 extrinsicKeys.push_back(body_P_cam_key);
1035 smartFactor1.
add(measurements_cam1_stereo, poseKeys, extrinsicKeys, Kmono);
1038 smartFactor2.
add(measurements_cam2_stereo, poseKeys, extrinsicKeys, Kmono);
1041 smartFactor3.
add(measurements_cam3_stereo, poseKeys, extrinsicKeys, Kmono);
1044 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
1060 gtValues.
insert(body_P_cam_key, sensor_to_body);
1062 double expectedError = 0.0;
1071 values.
insert(body_P_cam_key, sensor_to_body*noise_pose);
1102 views.push_back(
x1);
1103 views.push_back(
x2);
1104 views.push_back(
x3);
1106 Symbol body_P_cam_key(
'P', 0);
1108 extrinsicKeys.push_back(body_P_cam_key);
1109 extrinsicKeys.push_back(body_P_cam_key);
1110 extrinsicKeys.push_back(body_P_cam_key);
1115 Point3 landmark3(3, 0, 3.0);
1118 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
1120 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
1122 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
1130 smartFactor1->add(measurements_cam1, views, extrinsicKeys,
K);
1133 smartFactor2->add(measurements_cam2, views, extrinsicKeys,
K);
1136 smartFactor3->add(measurements_cam3, views, extrinsicKeys,
K);
1139 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
1146 graph.
addPrior(body_P_cam_key, Pose3::Identity(), noisePrior);
1169 views.push_back(
x1);
1170 views.push_back(
x2);
1171 views.push_back(
x3);
1173 Symbol body_P_cam_key(
'P', 0);
1175 extrinsicKeys.push_back(body_P_cam_key);
1176 extrinsicKeys.push_back(body_P_cam_key);
1177 extrinsicKeys.push_back(body_P_cam_key);
1192 Point3 landmark3(3, 0, 3.0);
1193 Point3 landmark4(5, -0.5, 1);
1196 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
1198 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
1200 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
1202 vector<StereoPoint2> measurements_cam4 = stereo_projectToMultipleCameras(
cam1,
1205 measurements_cam4.at(0) = measurements_cam4.at(0) +
StereoPoint2(10, 10, 1);
1212 smartFactor1->add(measurements_cam1, views, extrinsicKeys,
K);
1215 smartFactor2->add(measurements_cam2, views, extrinsicKeys,
K);
1218 smartFactor3->add(measurements_cam3, views, extrinsicKeys,
K);
1221 smartFactor4->add(measurements_cam4, views, extrinsicKeys,
K);
1225 smartFactor4b->add(measurements_cam4, views, extrinsicKeys,
K);
1227 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
1256 EXPECT(smartFactor1->point());
1257 EXPECT(smartFactor2->point());
1258 EXPECT(smartFactor3->point());
1259 EXPECT(smartFactor4->point().outlier());
1260 EXPECT(smartFactor4b->point());