31 using namespace gtsam;
62 static double missing_uR = std::numeric_limits<double>::quiet_NaN();
64 vector<StereoPoint2> stereo_projectToMultipleCameras(
const StereoCamera&
cam1,
68 vector<StereoPoint2> measurements_cam;
73 measurements_cam.push_back(cam1_uv1);
74 measurements_cam.push_back(cam2_uv1);
75 measurements_cam.push_back(cam3_uv1);
77 return measurements_cam;
91 EXPECT(
p.getVerboseCheirality() ==
false);
92 EXPECT(
p.getThrowCheirality() ==
false);
97 p.setRankTolerance(100);
99 p.setLandmarkDistanceThreshold(200);
100 p.setDynamicOutlierRejectionThreshold(3);
101 p.setRetriangulationThreshold(1
e-2);
106 EXPECT(
p.getTriangulationParameters().enableEPI ==
true);
172 double expectedError = 0.0;
213 double expectedError = 0.0;
272 vector<std::shared_ptr<Cal3_S2Stereo> > Ks;
305 Point3 landmark3(3, 0, 3.0);
308 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
310 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
312 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
323 smartFactor1->add(measurements_l1, views,
K2);
326 smartFactor2->add(measurements_l2, views,
K2);
329 smartFactor3->add(measurements_l3, views,
K2);
331 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
351 Rot3(0, -0.0314107591, 0.99950656, -0.99950656, -0.0313952598,
352 -0.000986635786, 0.0314107591, -0.999013364, -0.0313952598),
359 Point3 landmark1_smart = *smartFactor1->point();
360 Point3 landmark2_smart = *smartFactor2->point();
361 Point3 landmark3_smart = *smartFactor3->point();
403 bool verboseCheirality =
true;
447 Point3 landmark3(3, 0, 3.0);
450 vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(
cam1,
452 vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(
cam1,
454 vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(
cam1,
465 smartFactor1->add(measurements_l1, views,
K2);
468 smartFactor2->add(measurements_l2, views,
K2);
471 smartFactor3->add(measurements_l3, views,
K2);
473 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
493 Rot3(0, -0.0314107591, 0.99950656, -0.99950656, -0.0313952598,
494 -0.000986635786, 0.0314107591, -0.999013364, -0.0313952598),
540 Point3 landmark3(5, 0, 3.0);
542 Point2Vector measurements_cam1, measurements_cam2, measurements_cam3;
556 vector<StereoPoint2> measurements_cam1_stereo, measurements_cam2_stereo, measurements_cam3_stereo;
557 for(
size_t k=0; k<measurements_cam1.size();k++)
558 measurements_cam1_stereo.push_back(
StereoPoint2(measurements_cam1[k].
x() , missing_uR , measurements_cam1[k].
y()));
560 for(
size_t k=0; k<measurements_cam2.size();k++)
561 measurements_cam2_stereo.push_back(
StereoPoint2(measurements_cam2[k].
x() , missing_uR , measurements_cam2[k].
y()));
563 for(
size_t k=0; k<measurements_cam3.size();k++)
564 measurements_cam3_stereo.push_back(
StereoPoint2(measurements_cam3[k].
x() , missing_uR , measurements_cam3[k].
y()));
573 smartFactor1.
add(measurements_cam1_stereo, views, Kmono);
576 smartFactor2.
add(measurements_cam2_stereo, views, Kmono);
579 smartFactor3.
add(measurements_cam3_stereo, views, Kmono);
581 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
597 double expectedError = 0.0;
634 Point3 landmark3(3, 0, 3.0);
637 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
639 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
641 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
648 smartFactor1->add(measurements_cam1, views,
K);
651 smartFactor2->add(measurements_cam2, views,
K);
654 smartFactor3->add(measurements_cam3, views,
K);
656 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
700 Point3 landmark3(3, 0, 3.0);
703 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
705 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
707 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
713 sp = measurements_cam2[2];
720 smartFactor1->add(measurements_cam1, views,
K);
723 smartFactor2->add(measurements_cam2, views,
K);
726 smartFactor3->add(measurements_cam3, views,
K);
728 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
774 Point3 landmark3(3, 0, 3.0);
777 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
779 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
781 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
789 smartFactor1->add(measurements_cam1, views,
K);
792 smartFactor2->add(measurements_cam2, views,
K);
795 smartFactor3->add(measurements_cam3, views,
K);
797 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
842 Point3 landmark3(3, 0, 3.0);
843 Point3 landmark4(5, -0.5, 1);
846 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
848 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
850 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
852 vector<StereoPoint2> measurements_cam4 = stereo_projectToMultipleCameras(
cam1,
855 measurements_cam4.at(0) = measurements_cam4.at(0) +
StereoPoint2(10, 10, 1);
863 smartFactor1->add(measurements_cam1, views,
K);
866 smartFactor2->add(measurements_cam2, views,
K);
869 smartFactor3->add(measurements_cam3, views,
K);
872 smartFactor4->add(measurements_cam4, views,
K);
876 smartFactor4b->add(measurements_cam4, views,
K);
878 const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
905 EXPECT(smartFactor1->point());
906 EXPECT(smartFactor2->point());
907 EXPECT(smartFactor3->point());
908 EXPECT(smartFactor4->point().outlier());
909 EXPECT(smartFactor4b->point());
1043 views.push_back(
x1);
1044 views.push_back(
x2);
1045 views.push_back(
x3);
1062 Point3 landmark3(3, 0, 3.0);
1065 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
1067 vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(
cam1,
1069 vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(
cam1,
1076 smartFactor1->add(measurements_cam1, views,
K);
1079 smartFactor2->add(measurements_cam2, views,
K);
1082 smartFactor3->add(measurements_cam3, views,
K);
1099 std::shared_ptr<GaussianFactor> hessianFactor1 = smartFactor1->linearize(
1101 std::shared_ptr<GaussianFactor> hessianFactor2 = smartFactor2->linearize(
1103 std::shared_ptr<GaussianFactor> hessianFactor3 = smartFactor3->linearize(
1106 Matrix CumulativeInformation = hessianFactor1->information()
1107 + hessianFactor2->information() + hessianFactor3->information();
1109 std::shared_ptr<GaussianFactorGraph> GaussianGraph =
graph.
linearize(
1111 Matrix GraphInformation = GaussianGraph->hessian().first;
1116 Matrix AugInformationMatrix = hessianFactor1->augmentedInformation()
1117 + hessianFactor2->augmentedInformation()
1118 + hessianFactor3->augmentedInformation();
1121 Vector InfoVector = AugInformationMatrix.block(0, 18, 18, 1);
1312 views.push_back(
x1);
1313 views.push_back(
x2);
1314 views.push_back(
x3);
1330 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
1334 smartFactorInstance->add(measurements_cam1, views,
K);
1341 std::shared_ptr<GaussianFactor> hessianFactor =
1342 smartFactorInstance->linearize(
values);
1352 std::shared_ptr<GaussianFactor> hessianFactorRot =
1353 smartFactorInstance->linearize(rotValues);
1359 hessianFactorRot->information(), 1
e-7));
1369 std::shared_ptr<GaussianFactor> hessianFactorRotTran =
1370 smartFactorInstance->linearize(tranValues);
1375 hessianFactorRotTran->information(), 1
e-6));
1382 views.push_back(
x1);
1383 views.push_back(
x2);
1384 views.push_back(
x3);
1398 vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(
cam1,
1402 smartFactor->add(measurements_cam1, views,
K2);
1409 std::shared_ptr<GaussianFactor> hessianFactor = smartFactor->linearize(
1413 EXPECT(smartFactor->isValid());
1422 std::shared_ptr<GaussianFactor> hessianFactorRot = smartFactor->linearize(
1426 EXPECT(smartFactor->isValid());
1431 hessianFactorRot->information(), 1
e-6));
1441 std::shared_ptr<GaussianFactor> hessianFactorRotTran =
1442 smartFactor->linearize(tranValues);
1445 #ifdef GTSAM_USE_EIGEN_MKL