31 #include <boost/bind.hpp> 34 using namespace gtsam;
37 static double fov = 60;
38 static size_t w=640,
h=480;
54 struct traits<TestProjectionFactor> :
public Testable<TestProjectionFactor> {
66 Key transformKey(
T(1));
71 TestProjectionFactor factor(measurement,
model, poseKey, transformKey, pointKey,
K);
77 Key transformKey(
T(1));
81 TestProjectionFactor factor(measurement,
model, poseKey, transformKey, pointKey,
K);
99 Pose3 body_P_sensor(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
Point3(0.25, -0.10, 1.0));
111 Key transformKey(
T(1));
114 TestProjectionFactor factor(measurement,
model, poseKey, transformKey, pointKey,
K);
134 Key transformKey(
T(1));
138 TestProjectionFactor factor(measurement,
model, poseKey,transformKey, pointKey,
K);
158 Key transformKey(
T(1));
161 TestProjectionFactor factor(measurement,
model, poseKey, transformKey, pointKey,
K);
168 Matrix H1Actual, H2Actual, H3Actual;
172 Matrix H1Expected = (
Matrix(2, 6) << 0., -554.256, 0., -92.376, 0., 0., 554.256, 0., 0., 0., -92.376, 0.).finished();
173 Matrix H3Expected = (
Matrix(2, 3) << 92.376, 0., 0., 0., 92.376, 0.).finished();
180 Matrix H2Expected = numericalDerivative32<Vector,Pose3, Pose3, Point3>(
181 boost::function<Vector(const Pose3&, const Pose3&, const Point3&)>(
183 boost::none, boost::none, boost::none)), pose,
Pose3(),
point);
192 Key transformKey(
T(1));
195 Pose3 body_P_sensor(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
Point3(0.25, -0.10, 1.0));
196 TestProjectionFactor factor(measurement,
model, poseKey, transformKey, pointKey,
K);
203 Matrix H1Actual, H2Actual, H3Actual;
204 factor.
evaluateError(pose, body_P_sensor, point, H1Actual, H2Actual, H3Actual);
207 Matrix H1Expected = (
Matrix(2, 6) << -92.376, 0., 577.350, 0., 92.376, 0., -9.2376, -577.350, 0., 0., 0., 92.376).finished();
208 Matrix H3Expected = (
Matrix(2, 3) << 0., -92.376, 0., 0., 0., -92.376).finished();
215 Matrix H2Expected = numericalDerivative32<Vector, Pose3, Pose3, Point3>(
216 boost::function<Vector(const Pose3&, const Pose3&, const Point3&)>(
218 boost::none, boost::none, boost::none)), pose, body_P_sensor, point);
Provides additional testing facilities for common data structures.
static SharedNoiseModel model(noiseModel::Unit::Create(2))
static int runAllTests(TestResult &result)
Calibration of a camera with radial distortion, calculations in base class Cal3DS2_Base.
Some functions to compute numerical derivatives.
const gtsam::Key pointKey
static Cal3_S2::shared_ptr K(new Cal3_S2(fov, w, h))
ProjectionFactorPPP< Pose3, Point3 > TestProjectionFactor
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
Eigen::Triplet< double > T
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
TEST(ProjectionFactorPPP, nonStandard)
Derived from ProjectionFactor, but estimates body-camera transform in addition to body pose and 3D la...
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
Vector evaluateError(const Pose3 &pose, const Point3 &point, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const override
Evaluate error h(x)-z and optionally derivatives.
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
JacobianFactor factor2(keyX, A21, keyY, A22, b2, noiseModel::Isotropic::Sigma(2, sigma2))
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
boost::shared_ptr< Cal3_S2 > shared_ptr
std::uint64_t Key
Integer nonlinear key type.
noiseModel::Base::shared_ptr SharedNoiseModel
The most common 5DOF 3D->2D calibration.
JacobianFactor factor1(keyX, A11, b1, noiseModel::Isotropic::Sigma(2, sigma1))