29 #include <boost/bind.hpp> 32 using namespace gtsam;
49 const RangeFactor2D& factor) {
55 const RangeFactor3D& factor) {
61 const RangeFactorWithTransform2D& factor) {
67 const RangeFactorWithTransform3D& factor) {
100 Pose2 body_P_sensor_2D(0.25, -0.10, -M_PI_2);
101 Pose3 body_P_sensor_3D(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
102 Point3(0.25, -0.10, 1.0));
128 Pose2 body_P_sensor_2D(0.25, -0.10, -M_PI_2);
129 Pose3 body_P_sensor_3D(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
130 Point3(0.25, -0.10, 1.0));
147 Pose3 body_P_sensor_3D(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
148 Point3(0.25, -0.10, 1.0));
151 body_P_sensor_3D), factor3D_2;
157 const Pose3 pose(Rot3::RzRyRx(0.2, -0.3, 1.75),
Point3(1.0, 2.0, -3.0));
161 const Vector error_1 = factor3D_1.unwhitenedError(values);
176 Vector actualError(factor.
unwhitenedError({{poseKey, genericValue(pose)}, {pointKey, genericValue(point)}}));
179 Vector expectedError = (
Vector(1) << 0.295630141).finished();
188 Pose2 body_P_sensor(0.25, -0.10, -M_PI_2);
199 Vector actualError(factor.
unwhitenedError({{poseKey, genericValue(pose)}, {pointKey, genericValue(point)}}));
202 Vector expectedError = (
Vector(1) << 0.295630141).finished();
218 Vector actualError(factor.
unwhitenedError({{poseKey, genericValue(pose)}, {pointKey, genericValue(point)}}));
221 Vector expectedError = (
Vector(1) << 0.295630141).finished();
230 Pose3 body_P_sensor(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
231 Point3(0.25, -0.10, 1.0));
236 Rot3 R = Rot3::RzRyRx(0.2, -0.3, 1.75);
242 Vector actualError(factor.
unwhitenedError({{poseKey, genericValue(pose)}, {pointKey, genericValue(point)}}));
245 Vector expectedError = (
Vector(1) << 0.295630141).finished();
261 Matrix H1Actual, H2Actual;
265 Matrix H1Expected, H2Expected;
266 H1Expected = numericalDerivative11<Vector, Pose2>(
268 H2Expected = numericalDerivative11<Vector, Point2>(
279 Pose2 body_P_sensor(0.25, -0.10, -M_PI_2);
290 std::vector<Matrix> actualHs(2);
292 const Matrix& H1Actual = actualHs.at(0);
293 const Matrix& H2Actual = actualHs.at(1);
296 Matrix H1Expected, H2Expected;
297 H1Expected = numericalDerivative11<Vector, Pose2>(
299 H2Expected = numericalDerivative11<Vector, Point2>(
317 std::vector<Matrix> actualHs(2);
319 const Matrix& H1Actual = actualHs.at(0);
320 const Matrix& H2Actual = actualHs.at(1);
323 Matrix H1Expected, H2Expected;
324 H1Expected = numericalDerivative11<Vector, Pose3>(
326 H2Expected = numericalDerivative11<Vector, Point3>(
337 Pose3 body_P_sensor(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2),
338 Point3(0.25, -0.10, 1.0));
343 Rot3 R = Rot3::RzRyRx(0.2, -0.3, 1.75);
349 std::vector<Matrix> actualHs(2);
351 const Matrix& H1Actual = actualHs.at(0);
352 const Matrix& H2Actual = actualHs.at(1);
355 Matrix H1Expected, H2Expected;
356 H1Expected = numericalDerivative11<Vector, Pose3>(
358 H2Expected = numericalDerivative11<Vector, Point3>(
377 Vector expectedError = (
Vector(1) << 0.295630141).finished();
402 return (v2 - v1).norm();
416 Vector4
pose(1.0, 2.0, 00, 0);
417 Vector4
point(-4.0, 11.0, 0, 0);
420 Vector expectedError = (
Vector(1) << 0.295630141).finished();
Provides additional testing facilities for common data structures.
static int runAllTests(TestResult &result)
Point2 rotate(const Point2 &p, OptionalJacobian< 2, 1 > H1=boost::none, OptionalJacobian< 2, 2 > H2=boost::none) const
bool equalsObj(const T &input=T())
double operator()(const Vector4 &v1, const Vector4 &v2, OptionalJacobian< 1, 4 > H1, OptionalJacobian< 1, 4 > H2)
Rot2 R(Rot2::fromAngle(0.1))
RangeFactorWithTransform< Pose3, Point3 > RangeFactorWithTransform3D
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
Some functions to compute numerical derivatives.
const Point3 & translation(OptionalJacobian< 3, 6 > Hself=boost::none) const
get translation
RangeFactor< Pose3, Point3 > RangeFactor3D
const Point2 & translation() const
translation
Point3 rotate(const Point3 &p, OptionalJacobian< 3, 3 > H1=boost::none, OptionalJacobian< 3, 3 > H2=boost::none) const
Vector factorErrorWithTransform2D(const Pose2 &pose, const Point2 &point, const RangeFactorWithTransform2D &factor)
bool equalsXML(const T &input=T())
bool equalsBinary(const T &input=T())
BearingFactor3D factor3D(poseKey, pointKey, measurement3D, model3D)
void roundtripXML(const T &input, T &output)
JacobianFactor factor3(keyY, A32, keyZ, A33, b3, noiseModel::Isotropic::Sigma(2, sigma3))
Base class for all pinhole cameras.
Vector factorError3D(const Pose3 &pose, const Point3 &point, const RangeFactor3D &factor)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
TEST(RangeFactor, Constructor)
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
#define EXPECT(condition)
Vector factorError2D(const Pose2 &pose, const Point2 &point, const RangeFactor2D &factor)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
BearingFactor2D factor2D(poseKey, pointKey, measurement2D, model2D)
RangeFactor< Pose2, Point2 > RangeFactor2D
Vector evaluateError(const A1 &a1, const A2 &a2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
static SharedNoiseModel model(noiseModel::Unit::Create(1))
GenericValue< T > genericValue(const T &v)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
RangeFactorWithTransform< Pose2, Point2 > RangeFactorWithTransform2D
const KeyVector & keys() const
Access the factor's involved variable keys.
Vector factorErrorWithTransform3D(const Pose3 &pose, const Point3 &point, const RangeFactorWithTransform3D &factor)
JacobianFactor factor2(keyX, A21, keyY, A22, b2, noiseModel::Isotropic::Sigma(2, sigma2))
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
BOOST_CLASS_EXPORT(gtsam::noiseModel::Unit)
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))