removed tests that are not applicable - merging to develop now
							parent
							
								
									d8eeaf9cb3
								
							
						
					
					
						commit
						00eee7cd19
					
				| 
						 | 
				
			
			@ -699,91 +699,6 @@ TEST( SmartStereoProjectionFactorPP, 3poses_smart_projection_factor_optimization
 | 
			
		|||
  EXPECT_DOUBLES_EQUAL(0, graph.error(result), 1e-5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, body_P_sensor ) {
 | 
			
		||||
 | 
			
		||||
  // camera has some displacement
 | 
			
		||||
  Pose3 body_P_sensor = Pose3(Rot3::Ypr(-0.01, 0., -0.05), Point3(0.1, 0, 0.1));
 | 
			
		||||
  // create first camera. Looking along X-axis, 1 meter above ground plane (x-y)
 | 
			
		||||
  Pose3 pose1 = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 1));
 | 
			
		||||
  StereoCamera cam1(pose1.compose(body_P_sensor), K2);
 | 
			
		||||
 | 
			
		||||
  // create second camera 1 meter to the right of first camera
 | 
			
		||||
  Pose3 pose2 = pose1 * Pose3(Rot3(), Point3(1, 0, 0));
 | 
			
		||||
  StereoCamera cam2(pose2.compose(body_P_sensor), K2);
 | 
			
		||||
 | 
			
		||||
  // create third camera 1 meter above the first camera
 | 
			
		||||
  Pose3 pose3 = pose1 * Pose3(Rot3(), Point3(0, -1, 0));
 | 
			
		||||
  StereoCamera cam3(pose3.compose(body_P_sensor), K2);
 | 
			
		||||
 | 
			
		||||
  // three landmarks ~5 meters infront of camera
 | 
			
		||||
  Point3 landmark1(5, 0.5, 1.2);
 | 
			
		||||
  Point3 landmark2(5, -0.5, 1.2);
 | 
			
		||||
  Point3 landmark3(3, 0, 3.0);
 | 
			
		||||
 | 
			
		||||
  // 1. Project three landmarks into three cameras and triangulate
 | 
			
		||||
  vector<StereoPoint2> measurements_l1 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark1);
 | 
			
		||||
  vector<StereoPoint2> measurements_l2 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark2);
 | 
			
		||||
  vector<StereoPoint2> measurements_l3 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark3);
 | 
			
		||||
 | 
			
		||||
  KeyVector views;
 | 
			
		||||
  views.push_back(x1);
 | 
			
		||||
  views.push_back(x2);
 | 
			
		||||
  views.push_back(x3);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionParams smart_params;
 | 
			
		||||
  smart_params.triangulation.enableEPI = true;
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor1(new SmartStereoProjectionFactorPP(model, smart_params, body_P_sensor));
 | 
			
		||||
  smartFactor1->add(measurements_l1, views, K2);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor2(new SmartStereoProjectionFactorPP(model, smart_params, body_P_sensor));
 | 
			
		||||
  smartFactor2->add(measurements_l2, views, K2);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor3(new SmartStereoProjectionFactorPP(model, smart_params, body_P_sensor));
 | 
			
		||||
  smartFactor3->add(measurements_l3, views, K2);
 | 
			
		||||
 | 
			
		||||
  const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
 | 
			
		||||
 | 
			
		||||
  NonlinearFactorGraph graph;
 | 
			
		||||
  graph.push_back(smartFactor1);
 | 
			
		||||
  graph.push_back(smartFactor2);
 | 
			
		||||
  graph.push_back(smartFactor3);
 | 
			
		||||
  graph.addPrior(x1, pose1, noisePrior);
 | 
			
		||||
  graph.addPrior(x2, pose2, noisePrior);
 | 
			
		||||
 | 
			
		||||
  //  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI/10, 0., -M_PI/10), Point3(0.5,0.1,0.3)); // noise from regular projection factor test below
 | 
			
		||||
  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI / 100, 0., -M_PI / 100),
 | 
			
		||||
      Point3(0.1, 0.1, 0.1)); // smaller noise
 | 
			
		||||
  Values values;
 | 
			
		||||
  values.insert(x1, pose1);
 | 
			
		||||
  values.insert(x2, pose2);
 | 
			
		||||
  // initialize third pose with some noise, we expect it to move back to original pose3
 | 
			
		||||
  values.insert(x3, pose3 * noise_pose);
 | 
			
		||||
  EXPECT(
 | 
			
		||||
      assert_equal(
 | 
			
		||||
          Pose3(
 | 
			
		||||
              Rot3(0, -0.0314107591, 0.99950656, -0.99950656, -0.0313952598,
 | 
			
		||||
                  -0.000986635786, 0.0314107591, -0.999013364, -0.0313952598),
 | 
			
		||||
              Point3(0.1, -0.1, 1.9)), values.at<Pose3>(x3)));
 | 
			
		||||
 | 
			
		||||
  //  cout << std::setprecision(10) << "\n----SmartStereoFactor graph initial error: " << graph.error(values) << endl;
 | 
			
		||||
  EXPECT_DOUBLES_EQUAL(953392.32838422502, graph.error(values), 1e-7); // initial error
 | 
			
		||||
 | 
			
		||||
  Values result;
 | 
			
		||||
  gttic_(SmartStereoProjectionFactorPP);
 | 
			
		||||
  LevenbergMarquardtOptimizer optimizer(graph, values, lm_params);
 | 
			
		||||
  result = optimizer.optimize();
 | 
			
		||||
  gttoc_(SmartStereoProjectionFactorPP);
 | 
			
		||||
  tictoc_finishedIteration_();
 | 
			
		||||
 | 
			
		||||
  EXPECT_DOUBLES_EQUAL(0, graph.error(result), 1e-5);
 | 
			
		||||
 | 
			
		||||
  // result.print("results of 3 camera, 3 landmark optimization \n");
 | 
			
		||||
  EXPECT(assert_equal(pose3, result.at<Pose3>(x3)));
 | 
			
		||||
}
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, body_P_sensor_monocular ){
 | 
			
		||||
  // make a realistic calibration matrix
 | 
			
		||||
| 
						 | 
				
			
			@ -885,143 +800,6 @@ TEST( SmartStereoProjectionFactorPP, body_P_sensor_monocular ){
 | 
			
		|||
  result = optimizer.optimize();
 | 
			
		||||
  EXPECT(assert_equal(bodyPose3,result.at<Pose3>(x3)));
 | 
			
		||||
}
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, jacobianSVD ) {
 | 
			
		||||
 | 
			
		||||
  KeyVector views;
 | 
			
		||||
  views.push_back(x1);
 | 
			
		||||
  views.push_back(x2);
 | 
			
		||||
  views.push_back(x3);
 | 
			
		||||
 | 
			
		||||
  // create first camera. Looking along X-axis, 1 meter above ground plane (x-y)
 | 
			
		||||
  Pose3 pose1 = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 1));
 | 
			
		||||
  StereoCamera cam1(pose1, K);
 | 
			
		||||
  // create second camera 1 meter to the right of first camera
 | 
			
		||||
  Pose3 pose2 = pose1 * Pose3(Rot3(), Point3(1, 0, 0));
 | 
			
		||||
  StereoCamera cam2(pose2, K);
 | 
			
		||||
  // create third camera 1 meter above the first camera
 | 
			
		||||
  Pose3 pose3 = pose1 * Pose3(Rot3(), Point3(0, -1, 0));
 | 
			
		||||
  StereoCamera cam3(pose3, K);
 | 
			
		||||
 | 
			
		||||
  // three landmarks ~5 meters infront of camera
 | 
			
		||||
  Point3 landmark1(5, 0.5, 1.2);
 | 
			
		||||
  Point3 landmark2(5, -0.5, 1.2);
 | 
			
		||||
  Point3 landmark3(3, 0, 3.0);
 | 
			
		||||
 | 
			
		||||
  // 1. Project three landmarks into three cameras and triangulate
 | 
			
		||||
  vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark1);
 | 
			
		||||
  vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark2);
 | 
			
		||||
  vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark3);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionParams params;
 | 
			
		||||
  params.setLinearizationMode(JACOBIAN_SVD);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor1( new SmartStereoProjectionFactorPP(model, params));
 | 
			
		||||
  smartFactor1->add(measurements_cam1, views, K);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor2(new SmartStereoProjectionFactorPP(model, params));
 | 
			
		||||
  smartFactor2->add(measurements_cam2, views, K);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor3(new SmartStereoProjectionFactorPP(model, params));
 | 
			
		||||
  smartFactor3->add(measurements_cam3, views, K);
 | 
			
		||||
 | 
			
		||||
  const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
 | 
			
		||||
 | 
			
		||||
  NonlinearFactorGraph graph;
 | 
			
		||||
  graph.push_back(smartFactor1);
 | 
			
		||||
  graph.push_back(smartFactor2);
 | 
			
		||||
  graph.push_back(smartFactor3);
 | 
			
		||||
  graph.addPrior(x1, pose1, noisePrior);
 | 
			
		||||
  graph.addPrior(x2, pose2, noisePrior);
 | 
			
		||||
 | 
			
		||||
  //  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI/10, 0., -M_PI/10), Point3(0.5,0.1,0.3)); // noise from regular projection factor test below
 | 
			
		||||
  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI / 100, 0., -M_PI / 100),
 | 
			
		||||
      Point3(0.1, 0.1, 0.1)); // smaller noise
 | 
			
		||||
  Values values;
 | 
			
		||||
  values.insert(x1, pose1);
 | 
			
		||||
  values.insert(x2, pose2);
 | 
			
		||||
  values.insert(x3, pose3 * noise_pose);
 | 
			
		||||
 | 
			
		||||
  Values result;
 | 
			
		||||
  LevenbergMarquardtOptimizer optimizer(graph, values, lm_params);
 | 
			
		||||
  result = optimizer.optimize();
 | 
			
		||||
  EXPECT(assert_equal(pose3, result.at<Pose3>(x3)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, jacobianSVDwithMissingValues ) {
 | 
			
		||||
 | 
			
		||||
  KeyVector views;
 | 
			
		||||
  views.push_back(x1);
 | 
			
		||||
  views.push_back(x2);
 | 
			
		||||
  views.push_back(x3);
 | 
			
		||||
 | 
			
		||||
  // create first camera. Looking along X-axis, 1 meter above ground plane (x-y)
 | 
			
		||||
  Pose3 pose1 = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 1));
 | 
			
		||||
  StereoCamera cam1(pose1, K);
 | 
			
		||||
  // create second camera 1 meter to the right of first camera
 | 
			
		||||
  Pose3 pose2 = pose1 * Pose3(Rot3(), Point3(1, 0, 0));
 | 
			
		||||
  StereoCamera cam2(pose2, K);
 | 
			
		||||
  // create third camera 1 meter above the first camera
 | 
			
		||||
  Pose3 pose3 = pose1 * Pose3(Rot3(), Point3(0, -1, 0));
 | 
			
		||||
  StereoCamera cam3(pose3, K);
 | 
			
		||||
 | 
			
		||||
  // three landmarks ~5 meters infront of camera
 | 
			
		||||
  Point3 landmark1(5, 0.5, 1.2);
 | 
			
		||||
  Point3 landmark2(5, -0.5, 1.2);
 | 
			
		||||
  Point3 landmark3(3, 0, 3.0);
 | 
			
		||||
 | 
			
		||||
  // 1. Project three landmarks into three cameras and triangulate
 | 
			
		||||
  vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark1);
 | 
			
		||||
  vector<StereoPoint2> measurements_cam2 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark2);
 | 
			
		||||
  vector<StereoPoint2> measurements_cam3 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark3);
 | 
			
		||||
 | 
			
		||||
  // DELETE SOME MEASUREMENTS
 | 
			
		||||
  StereoPoint2 sp = measurements_cam1[1];
 | 
			
		||||
  measurements_cam1[1] = StereoPoint2(sp.uL(), missing_uR, sp.v());
 | 
			
		||||
  sp = measurements_cam2[2];
 | 
			
		||||
  measurements_cam2[2] = StereoPoint2(sp.uL(), missing_uR, sp.v());
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionParams params;
 | 
			
		||||
  params.setLinearizationMode(JACOBIAN_SVD);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor1( new SmartStereoProjectionFactorPP(model, params));
 | 
			
		||||
  smartFactor1->add(measurements_cam1, views, K);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor2(new SmartStereoProjectionFactorPP(model, params));
 | 
			
		||||
  smartFactor2->add(measurements_cam2, views, K);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor3(new SmartStereoProjectionFactorPP(model, params));
 | 
			
		||||
  smartFactor3->add(measurements_cam3, views, K);
 | 
			
		||||
 | 
			
		||||
  const SharedDiagonal noisePrior = noiseModel::Isotropic::Sigma(6, 0.10);
 | 
			
		||||
 | 
			
		||||
  NonlinearFactorGraph graph;
 | 
			
		||||
  graph.push_back(smartFactor1);
 | 
			
		||||
  graph.push_back(smartFactor2);
 | 
			
		||||
  graph.push_back(smartFactor3);
 | 
			
		||||
  graph.addPrior(x1, pose1, noisePrior);
 | 
			
		||||
  graph.addPrior(x2, pose2, noisePrior);
 | 
			
		||||
 | 
			
		||||
  //  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI/10, 0., -M_PI/10), Point3(0.5,0.1,0.3)); // noise from regular projection factor test below
 | 
			
		||||
  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI / 100, 0., -M_PI / 100),
 | 
			
		||||
      Point3(0.1, 0.1, 0.1)); // smaller noise
 | 
			
		||||
  Values values;
 | 
			
		||||
  values.insert(x1, pose1);
 | 
			
		||||
  values.insert(x2, pose2);
 | 
			
		||||
  values.insert(x3, pose3 * noise_pose);
 | 
			
		||||
 | 
			
		||||
  Values result;
 | 
			
		||||
  LevenbergMarquardtOptimizer optimizer(graph, values, lm_params);
 | 
			
		||||
  result = optimizer.optimize();
 | 
			
		||||
  EXPECT(assert_equal(pose3, result.at<Pose3>(x3),1e-7));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, landmarkDistance ) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1278,151 +1056,6 @@ TEST( SmartStereoProjectionFactorPP, CheckHessian) {
 | 
			
		|||
  EXPECT(assert_equal(InfoVector, GaussianGraph->hessian().second, 1e-8));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, HessianWithRotation ) {
 | 
			
		||||
  KeyVector views;
 | 
			
		||||
  views.push_back(x1);
 | 
			
		||||
  views.push_back(x2);
 | 
			
		||||
  views.push_back(x3);
 | 
			
		||||
 | 
			
		||||
  // create first camera. Looking along X-axis, 1 meter above ground plane (x-y)
 | 
			
		||||
  Pose3 pose1 = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 1));
 | 
			
		||||
  StereoCamera cam1(pose1, K);
 | 
			
		||||
 | 
			
		||||
  // create second camera 1 meter to the right of first camera
 | 
			
		||||
  Pose3 pose2 = pose1 * Pose3(Rot3(), Point3(1, 0, 0));
 | 
			
		||||
  StereoCamera cam2(pose2, K);
 | 
			
		||||
 | 
			
		||||
  // create third camera 1 meter above the first camera
 | 
			
		||||
  Pose3 pose3 = pose1 * Pose3(Rot3(), Point3(0, -1, 0));
 | 
			
		||||
  StereoCamera cam3(pose3, K);
 | 
			
		||||
 | 
			
		||||
  Point3 landmark1(5, 0.5, 1.2);
 | 
			
		||||
 | 
			
		||||
  vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark1);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactorInstance(new SmartStereoProjectionFactorPP(model));
 | 
			
		||||
  smartFactorInstance->add(measurements_cam1, views, K);
 | 
			
		||||
 | 
			
		||||
  Values values;
 | 
			
		||||
  values.insert(x1, pose1);
 | 
			
		||||
  values.insert(x2, pose2);
 | 
			
		||||
  values.insert(x3, pose3);
 | 
			
		||||
 | 
			
		||||
  boost::shared_ptr<GaussianFactor> hessianFactor =
 | 
			
		||||
      smartFactorInstance->linearize(values);
 | 
			
		||||
  // hessianFactor->print("Hessian factor \n");
 | 
			
		||||
 | 
			
		||||
  Pose3 poseDrift = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 0));
 | 
			
		||||
 | 
			
		||||
  Values rotValues;
 | 
			
		||||
  rotValues.insert(x1, poseDrift.compose(pose1));
 | 
			
		||||
  rotValues.insert(x2, poseDrift.compose(pose2));
 | 
			
		||||
  rotValues.insert(x3, poseDrift.compose(pose3));
 | 
			
		||||
 | 
			
		||||
  boost::shared_ptr<GaussianFactor> hessianFactorRot =
 | 
			
		||||
      smartFactorInstance->linearize(rotValues);
 | 
			
		||||
  // hessianFactorRot->print("Hessian factor \n");
 | 
			
		||||
 | 
			
		||||
  // Hessian is invariant to rotations in the nondegenerate case
 | 
			
		||||
  EXPECT(
 | 
			
		||||
      assert_equal(hessianFactor->information(),
 | 
			
		||||
          hessianFactorRot->information(), 1e-7));
 | 
			
		||||
 | 
			
		||||
  Pose3 poseDrift2 = Pose3(Rot3::Ypr(-M_PI / 2, -M_PI / 3, -M_PI / 2),
 | 
			
		||||
      Point3(10, -4, 5));
 | 
			
		||||
 | 
			
		||||
  Values tranValues;
 | 
			
		||||
  tranValues.insert(x1, poseDrift2.compose(pose1));
 | 
			
		||||
  tranValues.insert(x2, poseDrift2.compose(pose2));
 | 
			
		||||
  tranValues.insert(x3, poseDrift2.compose(pose3));
 | 
			
		||||
 | 
			
		||||
  boost::shared_ptr<GaussianFactor> hessianFactorRotTran =
 | 
			
		||||
      smartFactorInstance->linearize(tranValues);
 | 
			
		||||
 | 
			
		||||
  // Hessian is invariant to rotations and translations in the nondegenerate case
 | 
			
		||||
  EXPECT(
 | 
			
		||||
      assert_equal(hessianFactor->information(),
 | 
			
		||||
          hessianFactorRotTran->information(), 1e-6));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* *************************************************************************
 | 
			
		||||
TEST( SmartStereoProjectionFactorPP, HessianWithRotationNonDegenerate ) {
 | 
			
		||||
 | 
			
		||||
  KeyVector views;
 | 
			
		||||
  views.push_back(x1);
 | 
			
		||||
  views.push_back(x2);
 | 
			
		||||
  views.push_back(x3);
 | 
			
		||||
 | 
			
		||||
  // create first camera. Looking along X-axis, 1 meter above ground plane (x-y)
 | 
			
		||||
  Pose3 pose1 = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 1));
 | 
			
		||||
  StereoCamera cam1(pose1, K2);
 | 
			
		||||
 | 
			
		||||
  // Second and third cameras in same place, which is a degenerate configuration
 | 
			
		||||
  Pose3 pose2 = pose1;
 | 
			
		||||
  Pose3 pose3 = pose1;
 | 
			
		||||
  StereoCamera cam2(pose2, K2);
 | 
			
		||||
  StereoCamera cam3(pose3, K2);
 | 
			
		||||
 | 
			
		||||
  Point3 landmark1(5, 0.5, 1.2);
 | 
			
		||||
 | 
			
		||||
  vector<StereoPoint2> measurements_cam1 = stereo_projectToMultipleCameras(cam1,
 | 
			
		||||
      cam2, cam3, landmark1);
 | 
			
		||||
 | 
			
		||||
  SmartStereoProjectionFactorPP::shared_ptr smartFactor(new SmartStereoProjectionFactorPP(model));
 | 
			
		||||
  smartFactor->add(measurements_cam1, views, K2);
 | 
			
		||||
 | 
			
		||||
  Values values;
 | 
			
		||||
  values.insert(x1, pose1);
 | 
			
		||||
  values.insert(x2, pose2);
 | 
			
		||||
  values.insert(x3, pose3);
 | 
			
		||||
 | 
			
		||||
  boost::shared_ptr<GaussianFactor> hessianFactor = smartFactor->linearize(
 | 
			
		||||
      values);
 | 
			
		||||
 | 
			
		||||
  // check that it is non degenerate
 | 
			
		||||
  EXPECT(smartFactor->isValid());
 | 
			
		||||
 | 
			
		||||
  Pose3 poseDrift = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 0));
 | 
			
		||||
 | 
			
		||||
  Values rotValues;
 | 
			
		||||
  rotValues.insert(x1, poseDrift.compose(pose1));
 | 
			
		||||
  rotValues.insert(x2, poseDrift.compose(pose2));
 | 
			
		||||
  rotValues.insert(x3, poseDrift.compose(pose3));
 | 
			
		||||
 | 
			
		||||
  boost::shared_ptr<GaussianFactor> hessianFactorRot = smartFactor->linearize(
 | 
			
		||||
      rotValues);
 | 
			
		||||
 | 
			
		||||
  // check that it is non degenerate
 | 
			
		||||
  EXPECT(smartFactor->isValid());
 | 
			
		||||
 | 
			
		||||
  // Hessian is invariant to rotations in the nondegenerate case
 | 
			
		||||
  EXPECT(
 | 
			
		||||
      assert_equal(hessianFactor->information(),
 | 
			
		||||
          hessianFactorRot->information(), 1e-6));
 | 
			
		||||
 | 
			
		||||
  Pose3 poseDrift2 = Pose3(Rot3::Ypr(-M_PI / 2, -M_PI / 3, -M_PI / 2),
 | 
			
		||||
      Point3(10, -4, 5));
 | 
			
		||||
 | 
			
		||||
  Values tranValues;
 | 
			
		||||
  tranValues.insert(x1, poseDrift2.compose(pose1));
 | 
			
		||||
  tranValues.insert(x2, poseDrift2.compose(pose2));
 | 
			
		||||
  tranValues.insert(x3, poseDrift2.compose(pose3));
 | 
			
		||||
 | 
			
		||||
  boost::shared_ptr<GaussianFactor> hessianFactorRotTran =
 | 
			
		||||
      smartFactor->linearize(tranValues);
 | 
			
		||||
 | 
			
		||||
  // Hessian is invariant to rotations and translations in the degenerate case
 | 
			
		||||
  EXPECT(
 | 
			
		||||
      assert_equal(hessianFactor->information(),
 | 
			
		||||
#ifdef GTSAM_USE_EIGEN_MKL
 | 
			
		||||
          hessianFactorRotTran->information(), 1e-5));
 | 
			
		||||
#else
 | 
			
		||||
          hessianFactorRotTran->information(), 1e-6));
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
int main() {
 | 
			
		||||
  TestResult tr;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue