diff --git a/.cproject b/.cproject
index a596e90bf..4ab3bd70b 100644
--- a/.cproject
+++ b/.cproject
@@ -736,14 +736,6 @@
true
true
-
- make
- -j5
- testImuFactor.run
- true
- true
- true
-
make
-j5
@@ -2265,6 +2257,14 @@
true
true
+
+ make
+ -j5
+ testVelocityConstraint3.run
+ true
+ true
+ true
+
make
-j1
@@ -2766,10 +2766,10 @@
true
true
-
+
make
-j5
- testBetweenFactor.run
+ testPriorFactor.run
true
true
true
diff --git a/gtsam/geometry/tests/testPoint3.cpp b/gtsam/geometry/tests/testPoint3.cpp
index a791fd8db..4a07fe815 100644
--- a/gtsam/geometry/tests/testPoint3.cpp
+++ b/gtsam/geometry/tests/testPoint3.cpp
@@ -16,7 +16,6 @@
#include
#include
-#include
#include
#include
@@ -90,8 +89,8 @@ TEST (Point3, normalize) {
}
//*************************************************************************
-LieScalar norm_proxy(const Point3& point) {
- return LieScalar(point.norm());
+double norm_proxy(const Point3& point) {
+ return double(point.norm());
}
TEST (Point3, norm) {
@@ -99,7 +98,7 @@ TEST (Point3, norm) {
Point3 point(3,4,5); // arbitrary point
double expected = sqrt(50);
EXPECT_DOUBLES_EQUAL(expected, point.norm(actualH), 1e-8);
- Matrix expectedH = numericalDerivative11(norm_proxy, point);
+ Matrix expectedH = numericalDerivative11(norm_proxy, point);
EXPECT(assert_equal(expectedH, actualH, 1e-8));
}
diff --git a/gtsam/linear/tests/testHessianFactor.cpp b/gtsam/linear/tests/testHessianFactor.cpp
index 17ad0bf42..90a9cceda 100644
--- a/gtsam/linear/tests/testHessianFactor.cpp
+++ b/gtsam/linear/tests/testHessianFactor.cpp
@@ -276,8 +276,8 @@ TEST(HessianFactor, CombineAndEliminate)
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0);
- Vector b0 = (Vector(3) << 1.5, 1.5, 1.5);
- Vector s0 = (Vector(3) << 1.6, 1.6, 1.6);
+ Vector3 b0(1.5, 1.5, 1.5);
+ Vector3 s0(1.6, 1.6, 1.6);
Matrix A10 = (Matrix(3,3) <<
2.0, 0.0, 0.0,
@@ -287,15 +287,15 @@ TEST(HessianFactor, CombineAndEliminate)
-2.0, 0.0, 0.0,
0.0, -2.0, 0.0,
0.0, 0.0, -2.0);
- Vector b1 = (Vector(3) << 2.5, 2.5, 2.5);
- Vector s1 = (Vector(3) << 2.6, 2.6, 2.6);
+ Vector3 b1(2.5, 2.5, 2.5);
+ Vector3 s1(2.6, 2.6, 2.6);
Matrix A21 = (Matrix(3,3) <<
3.0, 0.0, 0.0,
0.0, 3.0, 0.0,
0.0, 0.0, 3.0);
- Vector b2 = (Vector(3) << 3.5, 3.5, 3.5);
- Vector s2 = (Vector(3) << 3.6, 3.6, 3.6);
+ Vector3 b2(3.5, 3.5, 3.5);
+ Vector3 s2(3.6, 3.6, 3.6);
GaussianFactorGraph gfg;
gfg.add(1, A01, b0, noiseModel::Diagonal::Sigmas(s0, true));
@@ -305,8 +305,8 @@ TEST(HessianFactor, CombineAndEliminate)
Matrix zero3x3 = zeros(3,3);
Matrix A0 = gtsam::stack(3, &A10, &zero3x3, &zero3x3);
Matrix A1 = gtsam::stack(3, &A11, &A01, &A21);
- Vector b = gtsam::concatVectors(3, &b1, &b0, &b2);
- Vector sigmas = gtsam::concatVectors(3, &s1, &s0, &s2);
+ Vector9 b; b << b1, b0, b2;
+ Vector9 sigmas; sigmas << s1, s0, s2;
// create a full, uneliminated version of the factor
JacobianFactor expectedFactor(0, A0, 1, A1, b, noiseModel::Diagonal::Sigmas(sigmas, true));
diff --git a/gtsam/linear/tests/testJacobianFactor.cpp b/gtsam/linear/tests/testJacobianFactor.cpp
index f70c3496a..1650df0ec 100644
--- a/gtsam/linear/tests/testJacobianFactor.cpp
+++ b/gtsam/linear/tests/testJacobianFactor.cpp
@@ -369,8 +369,8 @@ TEST(JacobianFactor, eliminate)
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0);
- Vector b0 = (Vector(3) << 1.5, 1.5, 1.5);
- Vector s0 = (Vector(3) << 1.6, 1.6, 1.6);
+ Vector3 b0(1.5, 1.5, 1.5);
+ Vector3 s0(1.6, 1.6, 1.6);
Matrix A10 = (Matrix(3, 3) <<
2.0, 0.0, 0.0,
@@ -380,15 +380,15 @@ TEST(JacobianFactor, eliminate)
-2.0, 0.0, 0.0,
0.0, -2.0, 0.0,
0.0, 0.0, -2.0);
- Vector b1 = (Vector(3) << 2.5, 2.5, 2.5);
- Vector s1 = (Vector(3) << 2.6, 2.6, 2.6);
+ Vector3 b1(2.5, 2.5, 2.5);
+ Vector3 s1(2.6, 2.6, 2.6);
Matrix A21 = (Matrix(3, 3) <<
3.0, 0.0, 0.0,
0.0, 3.0, 0.0,
0.0, 0.0, 3.0);
- Vector b2 = (Vector(3) << 3.5, 3.5, 3.5);
- Vector s2 = (Vector(3) << 3.6, 3.6, 3.6);
+ Vector3 b2(3.5, 3.5, 3.5);
+ Vector3 s2(3.6, 3.6, 3.6);
GaussianFactorGraph gfg;
gfg.add(1, A01, b0, noiseModel::Diagonal::Sigmas(s0, true));
@@ -398,8 +398,8 @@ TEST(JacobianFactor, eliminate)
Matrix zero3x3 = zeros(3,3);
Matrix A0 = gtsam::stack(3, &A10, &zero3x3, &zero3x3);
Matrix A1 = gtsam::stack(3, &A11, &A01, &A21);
- Vector b = gtsam::concatVectors(3, &b1, &b0, &b2);
- Vector sigmas = gtsam::concatVectors(3, &s1, &s0, &s2);
+ Vector9 b; b << b1, b0, b2;
+ Vector9 sigmas; sigmas << s1, s0, s2;
JacobianFactor combinedFactor(0, A0, 1, A1, b, noiseModel::Diagonal::Sigmas(sigmas, true));
GaussianFactorGraph::EliminationResult expected = combinedFactor.eliminate(list_of(0));
diff --git a/gtsam/navigation/CombinedImuFactor.h b/gtsam/navigation/CombinedImuFactor.h
index 725274acc..e82bea423 100644
--- a/gtsam/navigation/CombinedImuFactor.h
+++ b/gtsam/navigation/CombinedImuFactor.h
@@ -17,11 +17,10 @@
#pragma once
/* GTSAM includes */
-#include
-#include
#include
#include
-#include
+#include
+#include
#include
/* External or standard includes */
@@ -46,7 +45,7 @@ namespace gtsam {
* [3] L. Carlone, S. Williams, R. Roberts, "Preintegrated IMU factor: Computation of the Jacobian Matrices", Tech. Report, 2013.
*/
- class CombinedImuFactor: public NoiseModelFactor6 {
+ class CombinedImuFactor: public NoiseModelFactor6 {
public:
@@ -214,7 +213,7 @@ namespace gtsam {
Matrix3 H_vel_vel = I_3x3;
Matrix3 H_vel_angles = - deltaRij.matrix() * skewSymmetric(correctedAcc) * Jr_theta_i * deltaT;
// analytic expression corresponding to the following numerical derivative
- // Matrix H_vel_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_vel, correctedOmega, correctedAcc, deltaT, _1, deltaVij), theta_i);
+ // Matrix H_vel_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_vel, correctedOmega, correctedAcc, deltaT, _1, deltaVij), theta_i);
Matrix3 H_vel_biasacc = - deltaRij.matrix() * deltaT;
Matrix3 H_angles_pos = Z_3x3;
@@ -222,7 +221,7 @@ namespace gtsam {
Matrix3 H_angles_angles = Jrinv_theta_j * Rincr.inverse().matrix() * Jr_theta_i;
Matrix3 H_angles_biasomega =- Jrinv_theta_j * Jr_theta_incr * deltaT;
// analytic expression corresponding to the following numerical derivative
- // Matrix H_angles_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_angles, correctedOmega, deltaT, _1), thetaij);
+ // Matrix H_angles_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_angles, correctedOmega, deltaT, _1), thetaij);
// overall Jacobian wrt preintegrated measurements (df/dx)
Matrix F(15,15);
@@ -322,7 +321,7 @@ namespace gtsam {
private:
typedef CombinedImuFactor This;
- typedef NoiseModelFactor6 Base;
+ typedef NoiseModelFactor6 Base;
CombinedPreintegratedMeasurements preintegratedMeasurements_;
Vector3 gravity_;
@@ -412,7 +411,7 @@ namespace gtsam {
/** implement functions needed to derive from Factor */
/** vector of errors */
- Vector evaluateError(const Pose3& pose_i, const LieVector& vel_i, const Pose3& pose_j, const LieVector& vel_j,
+ Vector evaluateError(const Pose3& pose_i, const Vector3& vel_i, const Pose3& pose_j, const Vector3& vel_j,
const imuBias::ConstantBias& bias_i, const imuBias::ConstantBias& bias_j,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
@@ -626,7 +625,7 @@ namespace gtsam {
/** predicted states from IMU */
- static void Predict(const Pose3& pose_i, const LieVector& vel_i, Pose3& pose_j, LieVector& vel_j,
+ static void Predict(const Pose3& pose_i, const Vector3& vel_i, Pose3& pose_j, Vector3& vel_j,
const imuBias::ConstantBias& bias_i, imuBias::ConstantBias& bias_j,
const CombinedPreintegratedMeasurements& preintegratedMeasurements,
const Vector3& gravity, const Vector3& omegaCoriolis, boost::optional body_P_sensor = boost::none,
@@ -649,7 +648,7 @@ namespace gtsam {
- skewSymmetric(omegaCoriolis) * vel_i * deltaTij*deltaTij // Coriolis term - we got rid of the 2 wrt ins paper
+ 0.5 * gravity * deltaTij*deltaTij;
- vel_j = LieVector(vel_i + Rot_i.matrix() * (preintegratedMeasurements.deltaVij
+ vel_j = Vector3(vel_i + Rot_i.matrix() * (preintegratedMeasurements.deltaVij
+ preintegratedMeasurements.delVdelBiasAcc * biasAccIncr
+ preintegratedMeasurements.delVdelBiasOmega * biasOmegaIncr)
- 2 * skewSymmetric(omegaCoriolis) * vel_i * deltaTij // Coriolis term
diff --git a/gtsam/navigation/ImuBias.h b/gtsam/navigation/ImuBias.h
index 9bc24c152..18713505e 100644
--- a/gtsam/navigation/ImuBias.h
+++ b/gtsam/navigation/ImuBias.h
@@ -144,7 +144,7 @@ namespace imuBias {
/// return dimensionality of tangent space
inline size_t dim() const { return dimension; }
- /** Update the LieVector with a tangent space update */
+ /** Update the bias with a tangent space update */
inline ConstantBias retract(const Vector& v) const { return ConstantBias(biasAcc_ + v.head(3), biasGyro_ + v.tail(3)); }
/** @return the local coordinates of another object */
diff --git a/gtsam/navigation/ImuFactor.h b/gtsam/navigation/ImuFactor.h
index d68af4f8b..ea8a2cb8c 100644
--- a/gtsam/navigation/ImuFactor.h
+++ b/gtsam/navigation/ImuFactor.h
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include
/* External or standard includes */
@@ -46,7 +45,7 @@ namespace gtsam {
* [3] L. Carlone, S. Williams, R. Roberts, "Preintegrated IMU factor: Computation of the Jacobian Matrices", Tech. Report, 2013.
*/
- class ImuFactor: public NoiseModelFactor5 {
+ class ImuFactor: public NoiseModelFactor5 {
public:
@@ -203,13 +202,13 @@ namespace gtsam {
Matrix H_vel_vel = I_3x3;
Matrix H_vel_angles = - deltaRij.matrix() * skewSymmetric(correctedAcc) * Jr_theta_i * deltaT;
// analytic expression corresponding to the following numerical derivative
- // Matrix H_vel_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_vel, correctedOmega, correctedAcc, deltaT, _1, deltaVij), theta_i);
+ // Matrix H_vel_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_vel, correctedOmega, correctedAcc, deltaT, _1, deltaVij), theta_i);
Matrix H_angles_pos = Z_3x3;
Matrix H_angles_vel = Z_3x3;
Matrix H_angles_angles = Jrinv_theta_j * Rincr.inverse().matrix() * Jr_theta_i;
// analytic expression corresponding to the following numerical derivative
- // Matrix H_angles_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_angles, correctedOmega, deltaT, _1), thetaij);
+ // Matrix H_angles_angles = numericalDerivative11(boost::bind(&PreIntegrateIMUObservations_delta_angles, correctedOmega, deltaT, _1), thetaij);
// overall Jacobian wrt preintegrated measurements (df/dx)
Matrix F(9,9);
@@ -285,7 +284,7 @@ namespace gtsam {
private:
typedef ImuFactor This;
- typedef NoiseModelFactor5 Base;
+ typedef NoiseModelFactor5 Base;
PreintegratedMeasurements preintegratedMeasurements_;
Vector3 gravity_;
@@ -373,7 +372,7 @@ namespace gtsam {
/** implement functions needed to derive from Factor */
/** vector of errors */
- Vector evaluateError(const Pose3& pose_i, const LieVector& vel_i, const Pose3& pose_j, const LieVector& vel_j,
+ Vector evaluateError(const Pose3& pose_i, const Vector3& vel_i, const Pose3& pose_j, const Vector3& vel_j,
const imuBias::ConstantBias& bias,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
@@ -525,7 +524,7 @@ namespace gtsam {
/** predicted states from IMU */
- static void Predict(const Pose3& pose_i, const LieVector& vel_i, Pose3& pose_j, LieVector& vel_j,
+ static void Predict(const Pose3& pose_i, const Vector3& vel_i, Pose3& pose_j, Vector3& vel_j,
const imuBias::ConstantBias& bias, const PreintegratedMeasurements preintegratedMeasurements,
const Vector3& gravity, const Vector3& omegaCoriolis, boost::optional body_P_sensor = boost::none,
const bool use2ndOrderCoriolis = false)
@@ -547,7 +546,7 @@ namespace gtsam {
- skewSymmetric(omegaCoriolis) * vel_i * deltaTij*deltaTij // Coriolis term - we got rid of the 2 wrt ins paper
+ 0.5 * gravity * deltaTij*deltaTij;
- vel_j = LieVector(vel_i + Rot_i.matrix() * (preintegratedMeasurements.deltaVij
+ vel_j = Vector3(vel_i + Rot_i.matrix() * (preintegratedMeasurements.deltaVij
+ preintegratedMeasurements.delVdelBiasAcc * biasAccIncr
+ preintegratedMeasurements.delVdelBiasOmega * biasOmegaIncr)
- 2 * skewSymmetric(omegaCoriolis) * vel_i * deltaTij // Coriolis term
diff --git a/gtsam/navigation/MagFactor.h b/gtsam/navigation/MagFactor.h
index fc9d4f62b..96a0971c5 100644
--- a/gtsam/navigation/MagFactor.h
+++ b/gtsam/navigation/MagFactor.h
@@ -19,7 +19,6 @@
#include
#include
#include
-#include
namespace gtsam {
@@ -165,7 +164,7 @@ public:
* This version uses model measured bM = scale * bRn * direction + bias
* and optimizes for both scale, direction, and the bias.
*/
-class MagFactor3: public NoiseModelFactor3 {
+class MagFactor3: public NoiseModelFactor3 {
const Point3 measured_; ///< The measured magnetometer values
const Rot3 bRn_; ///< The assumed known rotation from nav to body
@@ -175,7 +174,7 @@ public:
/** Constructor */
MagFactor3(Key key1, Key key2, Key key3, const Point3& measured,
const Rot3& nRb, const SharedNoiseModel& model) :
- NoiseModelFactor3(model, key1, key2, key3), //
+ NoiseModelFactor3(model, key1, key2, key3), //
measured_(measured), bRn_(nRb.inverse()) {
}
@@ -190,7 +189,7 @@ public:
* @param nM (unknown) local earth magnetic field vector, in nav frame
* @param bias (unknown) 3D bias
*/
- Vector evaluateError(const LieScalar& scale, const Unit3& direction,
+ Vector evaluateError(double scale, const Unit3& direction,
const Point3& bias, boost::optional H1 = boost::none,
boost::optional H2 = boost::none, boost::optional H3 =
boost::none) const {
diff --git a/gtsam/navigation/tests/testCombinedImuFactor.cpp b/gtsam/navigation/tests/testCombinedImuFactor.cpp
index 279c20e69..5fca3343e 100644
--- a/gtsam/navigation/tests/testCombinedImuFactor.cpp
+++ b/gtsam/navigation/tests/testCombinedImuFactor.cpp
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -143,9 +142,9 @@ TEST( CombinedImuFactor, ErrorWithBiases )
imuBias::ConstantBias bias(Vector3(0.2, 0, 0), Vector3(0, 0, 0.3)); // Biases (acc, rot)
imuBias::ConstantBias bias2(Vector3(0.2, 0.2, 0), Vector3(1, 0, 0.3)); // Biases (acc, rot)
Pose3 x1(Rot3::Expmap(Vector3(0, 0, M_PI/4.0)), Point3(5.0, 1.0, -50.0));
- LieVector v1((Vector(3) << 0.5, 0.0, 0.0));
+ Vector3 v1(0.5, 0.0, 0.0);
Pose3 x2(Rot3::Expmap(Vector3(0, 0, M_PI/4.0 + M_PI/10.0)), Point3(5.5, 1.0, -50.0));
- LieVector v2((Vector(3) << 0.5, 0.0, 0.0));
+ Vector3 v2(0.5, 0.0, 0.0);
// Measurements
Vector3 gravity; gravity << 0, 0, 9.81;
diff --git a/gtsam/nonlinear/NonlinearFactor.cpp b/gtsam/nonlinear/NonlinearFactor.cpp
index f6f43b062..e9b97d644 100644
--- a/gtsam/nonlinear/NonlinearFactor.cpp
+++ b/gtsam/nonlinear/NonlinearFactor.cpp
@@ -18,6 +18,7 @@
#include
#include
+#include
namespace gtsam {
@@ -62,7 +63,8 @@ NonlinearFactor::shared_ptr NonlinearFactor::rekey(
void NoiseModelFactor::print(const std::string& s,
const KeyFormatter& keyFormatter) const {
Base::print(s, keyFormatter);
- noiseModel_->print(" noise model: ");
+ if (noiseModel_)
+ noiseModel_->print(" noise model: ");
}
/* ************************************************************************* */
@@ -76,18 +78,19 @@ bool NoiseModelFactor::equals(const NonlinearFactor& f, double tol) const {
/* ************************************************************************* */
static void check(const SharedNoiseModel& noiseModel, size_t m) {
- if (!noiseModel)
- throw std::invalid_argument("NoiseModelFactor: no NoiseModel.");
- if (m != noiseModel->dim())
+ if (noiseModel && m != noiseModel->dim())
throw std::invalid_argument(
- "NoiseModelFactor was created with a NoiseModel of incorrect dimension.");
+ boost::str(
+ boost::format(
+ "NoiseModelFactor: NoiseModel has dimension %1% instead of %2%.")
+ % noiseModel->dim() % m));
}
/* ************************************************************************* */
Vector NoiseModelFactor::whitenedError(const Values& c) const {
const Vector b = unwhitenedError(c);
check(noiseModel_, b.size());
- return noiseModel_->whiten(b);
+ return noiseModel_ ? noiseModel_->whiten(b) : b;
}
/* ************************************************************************* */
@@ -95,7 +98,10 @@ double NoiseModelFactor::error(const Values& c) const {
if (active(c)) {
const Vector b = unwhitenedError(c);
check(noiseModel_, b.size());
- return 0.5 * noiseModel_->distance(b);
+ if (noiseModel_)
+ return 0.5 * noiseModel_->distance(b);
+ else
+ return 0.5 * b.squaredNorm();
} else {
return 0.0;
}
@@ -115,7 +121,8 @@ boost::shared_ptr NoiseModelFactor::linearize(
check(noiseModel_, b.size());
// Whiten the corresponding system now
- noiseModel_->WhitenSystem(A, b);
+ if (noiseModel_)
+ noiseModel_->WhitenSystem(A, b);
// Fill in terms, needed to create JacobianFactor below
std::vector > terms(size());
@@ -125,7 +132,7 @@ boost::shared_ptr NoiseModelFactor::linearize(
}
// TODO pass unwhitened + noise model to Gaussian factor
- if (noiseModel_->is_constrained())
+ if (noiseModel_ && noiseModel_->is_constrained())
return GaussianFactor::shared_ptr(
new JacobianFactor(terms, b,
boost::static_pointer_cast(noiseModel_)->unit()));
diff --git a/gtsam/nonlinear/WhiteNoiseFactor.h b/gtsam/nonlinear/WhiteNoiseFactor.h
index 852ad147c..a7987d73b 100644
--- a/gtsam/nonlinear/WhiteNoiseFactor.h
+++ b/gtsam/nonlinear/WhiteNoiseFactor.h
@@ -19,7 +19,6 @@
#include
#include
-#include
#include
namespace gtsam {
@@ -126,7 +125,7 @@ namespace gtsam {
/// Calculate the error of the factor, typically equal to log-likelihood
inline double error(const Values& x) const {
- return f(z_, x.at(meanKey_), x.at(precisionKey_));
+ return f(z_, x.at(meanKey_), x.at(precisionKey_));
}
/**
@@ -155,8 +154,8 @@ namespace gtsam {
/// linearize returns a Hessianfactor that is an approximation of error(p)
virtual boost::shared_ptr linearize(const Values& x) const {
- double u = x.at(meanKey_);
- double p = x.at(precisionKey_);
+ double u = x.at(meanKey_);
+ double p = x.at(precisionKey_);
Key j1 = meanKey_;
Key j2 = precisionKey_;
return linearize(z_, u, p, j1, j2);
diff --git a/gtsam/nonlinear/tests/testValues.cpp b/gtsam/nonlinear/tests/testValues.cpp
index 9b9e8d0e0..60639e8b7 100644
--- a/gtsam/nonlinear/tests/testValues.cpp
+++ b/gtsam/nonlinear/tests/testValues.cpp
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include
#include // for operator +=
@@ -74,7 +73,7 @@ struct dimension : public boost::integral_constant {};
TEST( Values, equals1 )
{
Values expected;
- LieVector v((Vector(3) << 5.0, 6.0, 7.0));
+ Vector3 v(5.0, 6.0, 7.0);
expected.insert(key1, v);
Values actual;
@@ -86,8 +85,8 @@ TEST( Values, equals1 )
TEST( Values, equals2 )
{
Values cfg1, cfg2;
- LieVector v1((Vector(3) << 5.0, 6.0, 7.0));
- LieVector v2((Vector(3) << 5.0, 6.0, 8.0));
+ Vector3 v1(5.0, 6.0, 7.0);
+ Vector3 v2(5.0, 6.0, 8.0);
cfg1.insert(key1, v1);
cfg2.insert(key1, v2);
@@ -99,8 +98,8 @@ TEST( Values, equals2 )
TEST( Values, equals_nan )
{
Values cfg1, cfg2;
- LieVector v1((Vector(3) << 5.0, 6.0, 7.0));
- LieVector v2((Vector(3) << inf, inf, inf));
+ Vector3 v1(5.0, 6.0, 7.0);
+ Vector3 v2(inf, inf, inf);
cfg1.insert(key1, v1);
cfg2.insert(key1, v2);
@@ -112,10 +111,10 @@ TEST( Values, equals_nan )
TEST( Values, insert_good )
{
Values cfg1, cfg2, expected;
- LieVector v1((Vector(3) << 5.0, 6.0, 7.0));
- LieVector v2((Vector(3) << 8.0, 9.0, 1.0));
- LieVector v3((Vector(3) << 2.0, 4.0, 3.0));
- LieVector v4((Vector(3) << 8.0, 3.0, 7.0));
+ Vector3 v1(5.0, 6.0, 7.0);
+ Vector3 v2(8.0, 9.0, 1.0);
+ Vector3 v3(2.0, 4.0, 3.0);
+ Vector3 v4(8.0, 3.0, 7.0);
cfg1.insert(key1, v1);
cfg1.insert(key2, v2);
@@ -134,10 +133,10 @@ TEST( Values, insert_good )
TEST( Values, insert_bad )
{
Values cfg1, cfg2;
- LieVector v1((Vector(3) << 5.0, 6.0, 7.0));
- LieVector v2((Vector(3) << 8.0, 9.0, 1.0));
- LieVector v3((Vector(3) << 2.0, 4.0, 3.0));
- LieVector v4((Vector(3) << 8.0, 3.0, 7.0));
+ Vector3 v1(5.0, 6.0, 7.0);
+ Vector3 v2(8.0, 9.0, 1.0);
+ Vector3 v3(2.0, 4.0, 3.0);
+ Vector3 v4(8.0, 3.0, 7.0);
cfg1.insert(key1, v1);
cfg1.insert(key2, v2);
@@ -151,16 +150,16 @@ TEST( Values, insert_bad )
TEST( Values, update_element )
{
Values cfg;
- LieVector v1((Vector(3) << 5.0, 6.0, 7.0));
- LieVector v2((Vector(3) << 8.0, 9.0, 1.0));
+ Vector3 v1(5.0, 6.0, 7.0);
+ Vector3 v2(8.0, 9.0, 1.0);
cfg.insert(key1, v1);
CHECK(cfg.size() == 1);
- CHECK(assert_equal(v1, cfg.at(key1)));
+ CHECK(assert_equal((Vector)v1, cfg.at(key1)));
cfg.update(key1, v2);
CHECK(cfg.size() == 1);
- CHECK(assert_equal(v2, cfg.at(key1)));
+ CHECK(assert_equal((Vector)v2, cfg.at(key1)));
}
/* ************************************************************************* */
@@ -168,10 +167,10 @@ TEST(Values, basic_functions)
{
Values values;
const Values& values_c = values;
- values.insert(2, LieVector());
- values.insert(4, LieVector());
- values.insert(6, LieVector());
- values.insert(8, LieVector());
+ values.insert(2, Vector3());
+ values.insert(4, Vector3());
+ values.insert(6, Vector3());
+ values.insert(8, Vector3());
// find
EXPECT_LONGS_EQUAL(4, values.find(4)->key);
@@ -195,8 +194,8 @@ TEST(Values, basic_functions)
//TEST(Values, dim_zero)
//{
// Values config0;
-// config0.insert(key1, LieVector((Vector(2) << 2.0, 3.0));
-// config0.insert(key2, LieVector((Vector(3) << 5.0, 6.0, 7.0));
+// config0.insert(key1, Vector2((Vector(2) << 2.0, 3.0));
+// config0.insert(key2, Vector3(5.0, 6.0, 7.0));
// LONGS_EQUAL(5, config0.dim());
//
// VectorValues expected;
@@ -209,16 +208,16 @@ TEST(Values, basic_functions)
TEST(Values, expmap_a)
{
Values config0;
- config0.insert(key1, LieVector((Vector(3) << 1.0, 2.0, 3.0)));
- config0.insert(key2, LieVector((Vector(3) << 5.0, 6.0, 7.0)));
+ config0.insert(key1, Vector3(1.0, 2.0, 3.0));
+ config0.insert(key2, Vector3(5.0, 6.0, 7.0));
VectorValues increment = pair_list_of
(key1, (Vector(3) << 1.0, 1.1, 1.2))
(key2, (Vector(3) << 1.3, 1.4, 1.5));
Values expected;
- expected.insert(key1, LieVector((Vector(3) << 2.0, 3.1, 4.2)));
- expected.insert(key2, LieVector((Vector(3) << 6.3, 7.4, 8.5)));
+ expected.insert(key1, Vector3(2.0, 3.1, 4.2));
+ expected.insert(key2, Vector3(6.3, 7.4, 8.5));
CHECK(assert_equal(expected, config0.retract(increment)));
}
@@ -227,15 +226,15 @@ TEST(Values, expmap_a)
TEST(Values, expmap_b)
{
Values config0;
- config0.insert(key1, LieVector((Vector(3) << 1.0, 2.0, 3.0)));
- config0.insert(key2, LieVector((Vector(3) << 5.0, 6.0, 7.0)));
+ config0.insert(key1, Vector3(1.0, 2.0, 3.0));
+ config0.insert(key2, Vector3(5.0, 6.0, 7.0));
VectorValues increment = pair_list_of
(key2, (Vector(3) << 1.3, 1.4, 1.5));
Values expected;
- expected.insert(key1, LieVector((Vector(3) << 1.0, 2.0, 3.0)));
- expected.insert(key2, LieVector((Vector(3) << 6.3, 7.4, 8.5)));
+ expected.insert(key1, Vector3(1.0, 2.0, 3.0));
+ expected.insert(key2, Vector3(6.3, 7.4, 8.5));
CHECK(assert_equal(expected, config0.retract(increment)));
}
@@ -244,16 +243,16 @@ TEST(Values, expmap_b)
//TEST(Values, expmap_c)
//{
// Values config0;
-// config0.insert(key1, LieVector((Vector(3) << 1.0, 2.0, 3.0)));
-// config0.insert(key2, LieVector((Vector(3) << 5.0, 6.0, 7.0)));
+// config0.insert(key1, Vector3(1.0, 2.0, 3.0));
+// config0.insert(key2, Vector3(5.0, 6.0, 7.0));
//
-// Vector increment = LieVector(6,
+// Vector increment = Vector6(
// 1.0, 1.1, 1.2,
// 1.3, 1.4, 1.5);
//
// Values expected;
-// expected.insert(key1, LieVector((Vector(3) << 2.0, 3.1, 4.2)));
-// expected.insert(key2, LieVector((Vector(3) << 6.3, 7.4, 8.5)));
+// expected.insert(key1, Vector3(2.0, 3.1, 4.2));
+// expected.insert(key2, Vector3(6.3, 7.4, 8.5));
//
// CHECK(assert_equal(expected, config0.retract(increment)));
//}
@@ -262,8 +261,8 @@ TEST(Values, expmap_b)
TEST(Values, expmap_d)
{
Values config0;
- config0.insert(key1, LieVector((Vector(3) << 1.0, 2.0, 3.0)));
- config0.insert(key2, LieVector((Vector(3) << 5.0, 6.0, 7.0)));
+ config0.insert(key1, Vector3(1.0, 2.0, 3.0));
+ config0.insert(key2, Vector3(5.0, 6.0, 7.0));
//config0.print("config0");
CHECK(equal(config0, config0));
CHECK(config0.equals(config0));
@@ -280,8 +279,8 @@ TEST(Values, expmap_d)
TEST(Values, localCoordinates)
{
Values valuesA;
- valuesA.insert(key1, LieVector((Vector(3) << 1.0, 2.0, 3.0)));
- valuesA.insert(key2, LieVector((Vector(3) << 5.0, 6.0, 7.0)));
+ valuesA.insert(key1, Vector3(1.0, 2.0, 3.0));
+ valuesA.insert(key2, Vector3(5.0, 6.0, 7.0));
VectorValues expDelta = pair_list_of
(key1, (Vector(3) << 0.1, 0.2, 0.3))
@@ -317,28 +316,28 @@ TEST(Values, extract_keys)
TEST(Values, exists_)
{
Values config0;
- config0.insert(key1, LieVector((Vector(1) << 1.)));
- config0.insert(key2, LieVector((Vector(1) << 2.)));
+ config0.insert(key1, 1.0);
+ config0.insert(key2, 2.0);
- boost::optional v = config0.exists(key1);
- CHECK(assert_equal((Vector(1) << 1.),*v));
+ boost::optional v = config0.exists(key1);
+ DOUBLES_EQUAL(1.0,*v,1e-9);
}
/* ************************************************************************* */
TEST(Values, update)
{
Values config0;
- config0.insert(key1, LieVector((Vector(1) << 1.)));
- config0.insert(key2, LieVector((Vector(1) << 2.)));
+ config0.insert(key1, 1.0);
+ config0.insert(key2, 2.0);
Values superset;
- superset.insert(key1, LieVector((Vector(1) << -1.)));
- superset.insert(key2, LieVector((Vector(1) << -2.)));
+ superset.insert(key1, -1.0);
+ superset.insert(key2, -2.0);
config0.update(superset);
Values expected;
- expected.insert(key1, LieVector((Vector(1) << -1.)));
- expected.insert(key2, LieVector((Vector(1) << -2.)));
+ expected.insert(key1, -1.0);
+ expected.insert(key2, -2.0);
CHECK(assert_equal(expected, config0));
}
diff --git a/gtsam/slam/EssentialMatrixFactor.h b/gtsam/slam/EssentialMatrixFactor.h
index 557565a6e..87d847af2 100644
--- a/gtsam/slam/EssentialMatrixFactor.h
+++ b/gtsam/slam/EssentialMatrixFactor.h
@@ -10,7 +10,6 @@
#include
#include
#include
-#include
#include
namespace gtsam {
@@ -85,14 +84,13 @@ public:
* Binary factor that optimizes for E and inverse depth d: assumes measurement
* in image 2 is perfect, and returns re-projection error in image 1
*/
-class EssentialMatrixFactor2: public NoiseModelFactor2 {
+class EssentialMatrixFactor2: public NoiseModelFactor2 {
Point3 dP1_; ///< 3D point corresponding to measurement in image 1
Point2 pn_; ///< Measurement in image 2, in ideal coordinates
double f_; ///< approximate conversion factor for error scaling
- typedef NoiseModelFactor2 Base;
+ typedef NoiseModelFactor2 Base;
typedef EssentialMatrixFactor2 This;
public:
@@ -149,7 +147,7 @@ public:
* @param E essential matrix
* @param d inverse depth d
*/
- Vector evaluateError(const EssentialMatrix& E, const LieScalar& d,
+ Vector evaluateError(const EssentialMatrix& E, const double& d,
boost::optional DE = boost::none, boost::optional Dd =
boost::none) const {
@@ -237,7 +235,8 @@ public:
*/
template
EssentialMatrixFactor3(Key key1, Key key2, const Point2& pA, const Point2& pB,
- const Rot3& cRb, const SharedNoiseModel& model, boost::shared_ptr K) :
+ const Rot3& cRb, const SharedNoiseModel& model,
+ boost::shared_ptr K) :
EssentialMatrixFactor2(key1, key2, pA, pB, model, K), cRb_(cRb) {
}
@@ -259,7 +258,7 @@ public:
* @param E essential matrix
* @param d inverse depth d
*/
- Vector evaluateError(const EssentialMatrix& E, const LieScalar& d,
+ Vector evaluateError(const EssentialMatrix& E, const double& d,
boost::optional DE = boost::none, boost::optional Dd =
boost::none) const {
if (!DE) {
diff --git a/gtsam/slam/tests/testEssentialMatrixFactor.cpp b/gtsam/slam/tests/testEssentialMatrixFactor.cpp
index c889fb1e9..46e283d34 100644
--- a/gtsam/slam/tests/testEssentialMatrixFactor.cpp
+++ b/gtsam/slam/tests/testEssentialMatrixFactor.cpp
@@ -36,7 +36,7 @@ SfM_data data;
bool readOK = readBAL(filename, data);
Rot3 c1Rc2 = data.cameras[1].pose().rotation();
Point3 c1Tc2 = data.cameras[1].pose().translation();
-PinholeCamera camera2(data.cameras[1].pose(),Cal3_S2());
+PinholeCamera camera2(data.cameras[1].pose(), Cal3_S2());
EssentialMatrix trueE(c1Rc2, Unit3(c1Tc2));
double baseline = 0.1; // actual baseline of the camera
@@ -96,7 +96,7 @@ TEST (EssentialMatrixFactor, factor) {
// Use numerical derivatives to calculate the expected Jacobian
Matrix Hexpected;
- Hexpected = numericalDerivative11(
+ Hexpected = numericalDerivative11(
boost::bind(&EssentialMatrixFactor::evaluateError, &factor, _1,
boost::none), trueE);
@@ -164,17 +164,17 @@ TEST (EssentialMatrixFactor2, factor) {
Vector expected = reprojectionError.vector();
Matrix Hactual1, Hactual2;
- LieScalar d(baseline / P1.z());
+ double d(baseline / P1.z());
Vector actual = factor.evaluateError(trueE, d, Hactual1, Hactual2);
EXPECT(assert_equal(expected, actual, 1e-7));
// Use numerical derivatives to calculate the expected Jacobian
Matrix Hexpected1, Hexpected2;
- boost::function f =
- boost::bind(&EssentialMatrixFactor2::evaluateError, &factor, _1, _2,
- boost::none, boost::none);
- Hexpected1 = numericalDerivative21(f, trueE, d);
- Hexpected2 = numericalDerivative22(f, trueE, d);
+ boost::function f = boost::bind(
+ &EssentialMatrixFactor2::evaluateError, &factor, _1, _2, boost::none,
+ boost::none);
+ Hexpected1 = numericalDerivative21(f, trueE, d);
+ Hexpected2 = numericalDerivative22(f, trueE, d);
// Verify the Jacobian is correct
EXPECT(assert_equal(Hexpected1, Hactual1, 1e-8));
@@ -197,7 +197,7 @@ TEST (EssentialMatrixFactor2, minimization) {
truth.insert(100, trueE);
for (size_t i = 0; i < 5; i++) {
Point3 P1 = data.tracks[i].p;
- truth.insert(i, LieScalar(baseline / P1.z()));
+ truth.insert(i, double(baseline / P1.z()));
}
EXPECT_DOUBLES_EQUAL(0, graph.error(truth), 1e-8);
@@ -211,7 +211,7 @@ TEST (EssentialMatrixFactor2, minimization) {
EssentialMatrix actual = result.at(100);
EXPECT(assert_equal(trueE, actual, 1e-1));
for (size_t i = 0; i < 5; i++)
- EXPECT(assert_equal(truth.at(i), result.at(i), 1e-1));
+ EXPECT_DOUBLES_EQUAL(truth.at(i), result.at(i), 1e-1);
// Check error at result
EXPECT_DOUBLES_EQUAL(0, graph.error(result), 1e-4);
@@ -238,17 +238,17 @@ TEST (EssentialMatrixFactor3, factor) {
Vector expected = reprojectionError.vector();
Matrix Hactual1, Hactual2;
- LieScalar d(baseline / P1.z());
+ double d(baseline / P1.z());
Vector actual = factor.evaluateError(bodyE, d, Hactual1, Hactual2);
EXPECT(assert_equal(expected, actual, 1e-7));
// Use numerical derivatives to calculate the expected Jacobian
Matrix Hexpected1, Hexpected2;
- boost::function f =
- boost::bind(&EssentialMatrixFactor3::evaluateError, &factor, _1, _2,
- boost::none, boost::none);
- Hexpected1 = numericalDerivative21(f, bodyE, d);
- Hexpected2 = numericalDerivative22(f, bodyE, d);
+ boost::function f = boost::bind(
+ &EssentialMatrixFactor3::evaluateError, &factor, _1, _2, boost::none,
+ boost::none);
+ Hexpected1 = numericalDerivative21(f, bodyE, d);
+ Hexpected2 = numericalDerivative22(f, bodyE, d);
// Verify the Jacobian is correct
EXPECT(assert_equal(Hexpected1, Hactual1, 1e-8));
@@ -270,7 +270,7 @@ TEST (EssentialMatrixFactor3, minimization) {
truth.insert(100, bodyE);
for (size_t i = 0; i < 5; i++) {
Point3 P1 = data.tracks[i].p;
- truth.insert(i, LieScalar(baseline / P1.z()));
+ truth.insert(i, double(baseline / P1.z()));
}
EXPECT_DOUBLES_EQUAL(0, graph.error(truth), 1e-8);
@@ -284,7 +284,7 @@ TEST (EssentialMatrixFactor3, minimization) {
EssentialMatrix actual = result.at(100);
EXPECT(assert_equal(bodyE, actual, 1e-1));
for (size_t i = 0; i < 5; i++)
- EXPECT(assert_equal(truth.at(i), result.at(i), 1e-1));
+ EXPECT_DOUBLES_EQUAL(truth.at(i), result.at(i), 1e-1);
// Check error at result
EXPECT_DOUBLES_EQUAL(0, graph.error(result), 1e-4);
@@ -314,7 +314,7 @@ Point2 pB(size_t i) {
boost::shared_ptr //
K = boost::make_shared(500, 0, 0);
-PinholeCamera camera2(data.cameras[1].pose(),*K);
+PinholeCamera camera2(data.cameras[1].pose(), *K);
Vector vA(size_t i) {
Point2 xy = K->calibrate(pA(i));
@@ -380,17 +380,17 @@ TEST (EssentialMatrixFactor2, extraTest) {
Vector expected = reprojectionError.vector();
Matrix Hactual1, Hactual2;
- LieScalar d(baseline / P1.z());
+ double d(baseline / P1.z());
Vector actual = factor.evaluateError(trueE, d, Hactual1, Hactual2);
EXPECT(assert_equal(expected, actual, 1e-7));
// Use numerical derivatives to calculate the expected Jacobian
Matrix Hexpected1, Hexpected2;
- boost::function f =
- boost::bind(&EssentialMatrixFactor2::evaluateError, &factor, _1, _2,
- boost::none, boost::none);
- Hexpected1 = numericalDerivative21(f, trueE, d);
- Hexpected2 = numericalDerivative22(f, trueE, d);
+ boost::function f = boost::bind(
+ &EssentialMatrixFactor2::evaluateError, &factor, _1, _2, boost::none,
+ boost::none);
+ Hexpected1 = numericalDerivative21(f, trueE, d);
+ Hexpected2 = numericalDerivative22(f, trueE, d);
// Verify the Jacobian is correct
EXPECT(assert_equal(Hexpected1, Hactual1, 1e-6));
@@ -413,7 +413,7 @@ TEST (EssentialMatrixFactor2, extraMinimization) {
truth.insert(100, trueE);
for (size_t i = 0; i < data.number_tracks(); i++) {
Point3 P1 = data.tracks[i].p;
- truth.insert(i, LieScalar(baseline / P1.z()));
+ truth.insert(i, double(baseline / P1.z()));
}
EXPECT_DOUBLES_EQUAL(0, graph.error(truth), 1e-8);
@@ -427,7 +427,7 @@ TEST (EssentialMatrixFactor2, extraMinimization) {
EssentialMatrix actual = result.at(100);
EXPECT(assert_equal(trueE, actual, 1e-1));
for (size_t i = 0; i < data.number_tracks(); i++)
- EXPECT(assert_equal(truth.at(i), result.at(i), 1e-1));
+ EXPECT_DOUBLES_EQUAL(truth.at(i), result.at(i), 1e-1);
// Check error at result
EXPECT_DOUBLES_EQUAL(0, graph.error(result), 1e-4);
@@ -449,17 +449,17 @@ TEST (EssentialMatrixFactor3, extraTest) {
Vector expected = reprojectionError.vector();
Matrix Hactual1, Hactual2;
- LieScalar d(baseline / P1.z());
+ double d(baseline / P1.z());
Vector actual = factor.evaluateError(bodyE, d, Hactual1, Hactual2);
EXPECT(assert_equal(expected, actual, 1e-7));
// Use numerical derivatives to calculate the expected Jacobian
Matrix Hexpected1, Hexpected2;
- boost::function f =
- boost::bind(&EssentialMatrixFactor3::evaluateError, &factor, _1, _2,
- boost::none, boost::none);
- Hexpected1 = numericalDerivative21(f, bodyE, d);
- Hexpected2 = numericalDerivative22(f, bodyE, d);
+ boost::function f = boost::bind(
+ &EssentialMatrixFactor3::evaluateError, &factor, _1, _2, boost::none,
+ boost::none);
+ Hexpected1 = numericalDerivative21(f, bodyE, d);
+ Hexpected2 = numericalDerivative22(f, bodyE, d);
// Verify the Jacobian is correct
EXPECT(assert_equal(Hexpected1, Hactual1, 1e-6));
diff --git a/gtsam/slam/tests/testPriorFactor.cpp b/gtsam/slam/tests/testPriorFactor.cpp
new file mode 100644
index 000000000..b3e54bedb
--- /dev/null
+++ b/gtsam/slam/tests/testPriorFactor.cpp
@@ -0,0 +1,28 @@
+/**
+ * @file testPriorFactor.cpp
+ * @brief Test PriorFactor
+ * @author Frank Dellaert
+ * @date Nov 4, 2014
+ */
+
+#include
+#include
+#include
+
+using namespace std;
+using namespace gtsam;
+
+/* ************************************************************************* */
+
+// Constructor
+TEST(PriorFactor, Constructor) {
+ SharedNoiseModel model;
+ PriorFactor factor(1, LieScalar(1.0), model);
+}
+
+/* ************************************************************************* */
+int main() {
+ TestResult tr;
+ return TestRegistry::runAllTests(tr);
+}
+/* ************************************************************************* */
diff --git a/gtsam_unstable/dynamics/FullIMUFactor.h b/gtsam_unstable/dynamics/FullIMUFactor.h
index b8dba6b61..1c35fc9b8 100644
--- a/gtsam_unstable/dynamics/FullIMUFactor.h
+++ b/gtsam_unstable/dynamics/FullIMUFactor.h
@@ -7,7 +7,6 @@
#pragma once
#include
-#include
#include
#include
@@ -29,20 +28,20 @@ public:
protected:
/** measurements from the IMU */
- Vector accel_, gyro_;
+ Vector3 accel_, gyro_;
double dt_; /// time between measurements
public:
/** Standard constructor */
- FullIMUFactor(const Vector& accel, const Vector& gyro,
+ FullIMUFactor(const Vector3& accel, const Vector3& gyro,
double dt, const Key& key1, const Key& key2, const SharedNoiseModel& model)
: Base(model, key1, key2), accel_(accel), gyro_(gyro), dt_(dt) {
assert(model->dim() == 9);
}
/** Single IMU vector - imu = [accel, gyro] */
- FullIMUFactor(const Vector& imu,
+ FullIMUFactor(const Vector6& imu,
double dt, const Key& key1, const Key& key2, const SharedNoiseModel& model)
: Base(model, key1, key2), accel_(imu.head(3)), gyro_(imu.tail(3)), dt_(dt) {
assert(imu.size() == 6);
@@ -68,15 +67,15 @@ public:
void print(const std::string& s="", const gtsam::KeyFormatter& formatter = gtsam::DefaultKeyFormatter) const {
std::string a = "FullIMUFactor: " + s;
Base::print(a, formatter);
- gtsam::print(accel_, "accel");
- gtsam::print(gyro_, "gyro");
+ gtsam::print((Vector)accel_, "accel");
+ gtsam::print((Vector)gyro_, "gyro");
std::cout << "dt: " << dt_ << std::endl;
}
// access
- const Vector& gyro() const { return gyro_; }
- const Vector& accel() const { return accel_; }
- Vector z() const { return concatVectors(2, &accel_, &gyro_); }
+ const Vector3& gyro() const { return gyro_; }
+ const Vector3& accel() const { return accel_; }
+ Vector6 z() const { return (Vector6() << accel_, gyro_); }
/**
* Error evaluation with optional derivatives - calculates
@@ -85,13 +84,13 @@ public:
virtual Vector evaluateError(const PoseRTV& x1, const PoseRTV& x2,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none) const {
- Vector z(9);
+ Vector9 z;
z.head(3).operator=(accel_); // Strange syntax to work around ambiguous operator error with clang
z.segment(3, 3).operator=(gyro_); // Strange syntax to work around ambiguous operator error with clang
z.tail(3).operator=(x2.t().vector()); // Strange syntax to work around ambiguous operator error with clang
- if (H1) *H1 = numericalDerivative21(
+ if (H1) *H1 = numericalDerivative21(
boost::bind(This::predict_proxy, _1, _2, dt_), x1, x2, 1e-5);
- if (H2) *H2 = numericalDerivative22(
+ if (H2) *H2 = numericalDerivative22(
boost::bind(This::predict_proxy, _1, _2, dt_), x1, x2, 1e-5);
return z - predict_proxy(x1, x2, dt_);
}
@@ -107,11 +106,11 @@ public:
private:
/** copy of the measurement function formulated for numerical derivatives */
- static LieVector predict_proxy(const PoseRTV& x1, const PoseRTV& x2, double dt) {
- Vector hx(9);
+ static Vector9 predict_proxy(const PoseRTV& x1, const PoseRTV& x2, double dt) {
+ Vector9 hx;
hx.head(6).operator=(x1.imuPrediction(x2, dt)); // Strange syntax to work around ambiguous operator error with clang
hx.tail(3).operator=(x1.translationIntegration(x2, dt).vector()); // Strange syntax to work around ambiguous operator error with clang
- return LieVector(hx);
+ return hx;
}
};
diff --git a/gtsam_unstable/dynamics/IMUFactor.h b/gtsam_unstable/dynamics/IMUFactor.h
index 4ad0635cf..5fb4d77aa 100644
--- a/gtsam_unstable/dynamics/IMUFactor.h
+++ b/gtsam_unstable/dynamics/IMUFactor.h
@@ -7,7 +7,6 @@
#pragma once
#include
-#include
#include
#include
@@ -27,18 +26,18 @@ public:
protected:
/** measurements from the IMU */
- Vector accel_, gyro_;
+ Vector3 accel_, gyro_;
double dt_; /// time between measurements
public:
/** Standard constructor */
- IMUFactor(const Vector& accel, const Vector& gyro,
+ IMUFactor(const Vector3& accel, const Vector3& gyro,
double dt, const Key& key1, const Key& key2, const SharedNoiseModel& model)
: Base(model, key1, key2), accel_(accel), gyro_(gyro), dt_(dt) {}
/** Full IMU vector specification */
- IMUFactor(const Vector& imu_vector,
+ IMUFactor(const Vector6& imu_vector,
double dt, const Key& key1, const Key& key2, const SharedNoiseModel& model)
: Base(model, key1, key2), accel_(imu_vector.head(3)), gyro_(imu_vector.tail(3)), dt_(dt) {}
@@ -61,15 +60,15 @@ public:
void print(const std::string& s="", const gtsam::KeyFormatter& formatter = gtsam::DefaultKeyFormatter) const {
std::string a = "IMUFactor: " + s;
Base::print(a, formatter);
- gtsam::print(accel_, "accel");
- gtsam::print(gyro_, "gyro");
+ gtsam::print((Vector)accel_, "accel");
+ gtsam::print((Vector)gyro_, "gyro");
std::cout << "dt: " << dt_ << std::endl;
}
// access
- const Vector& gyro() const { return gyro_; }
- const Vector& accel() const { return accel_; }
- Vector z() const { return concatVectors(2, &accel_, &gyro_); }
+ const Vector3& gyro() const { return gyro_; }
+ const Vector3& accel() const { return accel_; }
+ Vector6 z() const { return (Vector6() << accel_, gyro_);}
/**
* Error evaluation with optional derivatives - calculates
@@ -78,10 +77,10 @@ public:
virtual Vector evaluateError(const PoseRTV& x1, const PoseRTV& x2,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none) const {
- const Vector meas = z();
- if (H1) *H1 = numericalDerivative21(
+ const Vector6 meas = z();
+ if (H1) *H1 = numericalDerivative21(
boost::bind(This::predict_proxy, _1, _2, dt_, meas), x1, x2, 1e-5);
- if (H2) *H2 = numericalDerivative22(
+ if (H2) *H2 = numericalDerivative22(
boost::bind(This::predict_proxy, _1, _2, dt_, meas), x1, x2, 1e-5);
return predict_proxy(x1, x2, dt_, meas);
}
@@ -96,10 +95,10 @@ public:
private:
/** copy of the measurement function formulated for numerical derivatives */
- static LieVector predict_proxy(const PoseRTV& x1, const PoseRTV& x2,
- double dt, const Vector& meas) {
- Vector hx = x1.imuPrediction(x2, dt);
- return LieVector(meas - hx);
+ static Vector6 predict_proxy(const PoseRTV& x1, const PoseRTV& x2,
+ double dt, const Vector6& meas) {
+ Vector6 hx = x1.imuPrediction(x2, dt);
+ return meas - hx;
}
};
diff --git a/gtsam_unstable/dynamics/Pendulum.h b/gtsam_unstable/dynamics/Pendulum.h
index 8cfc3cbcd..0100e17c7 100644
--- a/gtsam_unstable/dynamics/Pendulum.h
+++ b/gtsam_unstable/dynamics/Pendulum.h
@@ -9,7 +9,6 @@
#pragma once
-#include
#include
namespace gtsam {
@@ -21,11 +20,11 @@ namespace gtsam {
* - For implicit Euler method: q_{k+1} = q_k + h*v_{k+1}
* - For sympletic Euler method: q_{k+1} = q_k + h*v_{k+1}
*/
-class PendulumFactor1: public NoiseModelFactor3 {
+class PendulumFactor1: public NoiseModelFactor3 {
public:
protected:
- typedef NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
/** default constructor to allow for serialization */
PendulumFactor1() {}
@@ -38,7 +37,7 @@ public:
///Constructor. k1: q_{k+1}, k: q_k, velKey: velocity variable depending on the chosen method, h: time step
PendulumFactor1(Key k1, Key k, Key velKey, double h, double mu = 1000.0)
- : Base(noiseModel::Constrained::All(LieScalar::Dim(), fabs(mu)), k1, k, velKey), h_(h) {}
+ : Base(noiseModel::Constrained::All(1, fabs(mu)), k1, k, velKey), h_(h) {}
/// @return a deep copy of this factor
virtual gtsam::NonlinearFactor::shared_ptr clone() const {
@@ -46,15 +45,15 @@ public:
gtsam::NonlinearFactor::shared_ptr(new PendulumFactor1(*this))); }
/** q_k + h*v - q_k1 = 0, with optional derivatives */
- Vector evaluateError(const LieScalar& qk1, const LieScalar& qk, const LieScalar& v,
+ Vector evaluateError(const double& qk1, const double& qk, const double& v,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
- const size_t p = LieScalar::Dim();
+ const size_t p = 1;
if (H1) *H1 = -eye(p);
if (H2) *H2 = eye(p);
if (H3) *H3 = eye(p)*h_;
- return qk1.localCoordinates(qk.compose(LieScalar(v*h_)));
+ return (Vector(1) << qk+v*h_-qk1);
}
}; // \PendulumFactor1
@@ -67,11 +66,11 @@ public:
* - For implicit Euler method: v_{k+1} = v_k - h*g/L*sin(q_{k+1})
* - For sympletic Euler method: v_{k+1} = v_k - h*g/L*sin(q_k)
*/
-class PendulumFactor2: public NoiseModelFactor3 {
+class PendulumFactor2: public NoiseModelFactor3 {
public:
protected:
- typedef NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
/** default constructor to allow for serialization */
PendulumFactor2() {}
@@ -86,7 +85,7 @@ public:
///Constructor. vk1: v_{k+1}, vk: v_k, qkey: q's key depending on the chosen method, h: time step
PendulumFactor2(Key vk1, Key vk, Key qkey, double h, double r = 1.0, double g = 9.81, double mu = 1000.0)
- : Base(noiseModel::Constrained::All(LieScalar::Dim(), fabs(mu)), vk1, vk, qkey), h_(h), g_(g), r_(r) {}
+ : Base(noiseModel::Constrained::All(1, fabs(mu)), vk1, vk, qkey), h_(h), g_(g), r_(r) {}
/// @return a deep copy of this factor
virtual gtsam::NonlinearFactor::shared_ptr clone() const {
@@ -94,15 +93,15 @@ public:
gtsam::NonlinearFactor::shared_ptr(new PendulumFactor2(*this))); }
/** v_k - h*g/L*sin(q) - v_k1 = 0, with optional derivatives */
- Vector evaluateError(const LieScalar& vk1, const LieScalar& vk, const LieScalar& q,
+ Vector evaluateError(const double & vk1, const double & vk, const double & q,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
- const size_t p = LieScalar::Dim();
+ const size_t p = 1;
if (H1) *H1 = -eye(p);
if (H2) *H2 = eye(p);
- if (H3) *H3 = -eye(p)*h_*g_/r_*cos(q.value());
- return vk1.localCoordinates(LieScalar(vk - h_*g_/r_*sin(q)));
+ if (H3) *H3 = -eye(p)*h_*g_/r_*cos(q);
+ return (Vector(1) << vk - h_ * g_ / r_ * sin(q) - vk1);
}
}; // \PendulumFactor2
@@ -114,11 +113,11 @@ public:
* p_k = -D_1 L_d(q_k,q_{k+1},h) = \frac{1}{h}mr^{2}\left(q_{k+1}-q_{k}\right)+mgrh(1-\alpha)\,\sin\left((1-\alpha)q_{k}+\alpha q_{k+1}\right)
* = (1/h)mr^2 (q_{k+1}-q_k) + mgrh(1-alpha) sin ((1-alpha)q_k+\alpha q_{k+1})
*/
-class PendulumFactorPk: public NoiseModelFactor3 {
+class PendulumFactorPk: public NoiseModelFactor3 {
public:
protected:
- typedef NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
/** default constructor to allow for serialization */
PendulumFactorPk() {}
@@ -136,7 +135,7 @@ public:
///Constructor
PendulumFactorPk(Key pKey, Key qKey, Key qKey1,
double h, double m = 1.0, double r = 1.0, double g = 9.81, double alpha = 0.0, double mu = 1000.0)
- : Base(noiseModel::Constrained::All(LieScalar::Dim(), fabs(mu)), pKey, qKey, qKey1),
+ : Base(noiseModel::Constrained::All(1, fabs(mu)), pKey, qKey, qKey1),
h_(h), m_(m), r_(r), g_(g), alpha_(alpha) {}
/// @return a deep copy of this factor
@@ -145,11 +144,11 @@ public:
gtsam::NonlinearFactor::shared_ptr(new PendulumFactorPk(*this))); }
/** 1/h mr^2 (qk1-qk)+mgrh (1-a) sin((1-a)pk + a*pk1) - pk = 0, with optional derivatives */
- Vector evaluateError(const LieScalar& pk, const LieScalar& qk, const LieScalar& qk1,
+ Vector evaluateError(const double & pk, const double & qk, const double & qk1,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
- const size_t p = LieScalar::Dim();
+ const size_t p = 1;
double qmid = (1-alpha_)*qk + alpha_*qk1;
double mr2_h = 1/h_*m_*r_*r_;
@@ -159,7 +158,7 @@ public:
if (H2) *H2 = eye(p)*(-mr2_h + mgrh*(1-alpha_)*(1-alpha_)*cos(qmid));
if (H3) *H3 = eye(p)*( mr2_h + mgrh*(1-alpha_)*(alpha_)*cos(qmid));
- return pk.localCoordinates(LieScalar(mr2_h*(qk1-qk) + mgrh*(1-alpha_)*sin(qmid)));
+ return (Vector(1) << mr2_h * (qk1 - qk) + mgrh * (1 - alpha_) * sin(qmid) - pk);
}
}; // \PendulumFactorPk
@@ -170,11 +169,11 @@ public:
* p_k1 = D_2 L_d(q_k,q_{k+1},h) = \frac{1}{h}mr^{2}\left(q_{k+1}-q_{k}\right)-mgrh\alpha\sin\left((1-\alpha)q_{k}+\alpha q_{k+1}\right)
* = (1/h)mr^2 (q_{k+1}-q_k) - mgrh alpha sin ((1-alpha)q_k+\alpha q_{k+1})
*/
-class PendulumFactorPk1: public NoiseModelFactor3 {
+class PendulumFactorPk1: public NoiseModelFactor3 {
public:
protected:
- typedef NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
/** default constructor to allow for serialization */
PendulumFactorPk1() {}
@@ -192,7 +191,7 @@ public:
///Constructor
PendulumFactorPk1(Key pKey1, Key qKey, Key qKey1,
double h, double m = 1.0, double r = 1.0, double g = 9.81, double alpha = 0.0, double mu = 1000.0)
- : Base(noiseModel::Constrained::All(LieScalar::Dim(), fabs(mu)), pKey1, qKey, qKey1),
+ : Base(noiseModel::Constrained::All(1, fabs(mu)), pKey1, qKey, qKey1),
h_(h), m_(m), r_(r), g_(g), alpha_(alpha) {}
/// @return a deep copy of this factor
@@ -201,11 +200,11 @@ public:
gtsam::NonlinearFactor::shared_ptr(new PendulumFactorPk1(*this))); }
/** 1/h mr^2 (qk1-qk) - mgrh a sin((1-a)pk + a*pk1) - pk1 = 0, with optional derivatives */
- Vector evaluateError(const LieScalar& pk1, const LieScalar& qk, const LieScalar& qk1,
+ Vector evaluateError(const double & pk1, const double & qk, const double & qk1,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
- const size_t p = LieScalar::Dim();
+ const size_t p = 1;
double qmid = (1-alpha_)*qk + alpha_*qk1;
double mr2_h = 1/h_*m_*r_*r_;
@@ -215,7 +214,7 @@ public:
if (H2) *H2 = eye(p)*(-mr2_h - mgrh*(1-alpha_)*alpha_*cos(qmid));
if (H3) *H3 = eye(p)*( mr2_h - mgrh*alpha_*alpha_*cos(qmid));
- return pk1.localCoordinates(LieScalar(mr2_h*(qk1-qk) - mgrh*alpha_*sin(qmid)));
+ return (Vector(1) << mr2_h * (qk1 - qk) - mgrh * alpha_ * sin(qmid) - pk1);
}
}; // \PendulumFactorPk1
diff --git a/gtsam_unstable/dynamics/PoseRTV.cpp b/gtsam_unstable/dynamics/PoseRTV.cpp
index 2246baee1..ed8d54696 100644
--- a/gtsam_unstable/dynamics/PoseRTV.cpp
+++ b/gtsam_unstable/dynamics/PoseRTV.cpp
@@ -57,18 +57,17 @@ void PoseRTV::print(const string& s) const {
}
/* ************************************************************************* */
-PoseRTV PoseRTV::Expmap(const Vector& v) {
- assert(v.size() == 9);
- Pose3 newPose = Pose3::Expmap(sub(v, 0, 6));
- Velocity3 newVel = Velocity3::Expmap(sub(v, 6, 9));
+PoseRTV PoseRTV::Expmap(const Vector9& v) {
+ Pose3 newPose = Pose3::Expmap(v.head<6>());
+ Velocity3 newVel = Velocity3::Expmap(v.tail<3>());
return PoseRTV(newPose, newVel);
}
/* ************************************************************************* */
-Vector PoseRTV::Logmap(const PoseRTV& p) {
- Vector Lx = Pose3::Logmap(p.Rt_);
- Vector Lv = Velocity3::Logmap(p.v_);
- return concatVectors(2, &Lx, &Lv);
+Vector9 PoseRTV::Logmap(const PoseRTV& p) {
+ Vector6 Lx = Pose3::Logmap(p.Rt_);
+ Vector3 Lv = Velocity3::Logmap(p.v_);
+ return (Vector9() << Lx, Lv);
}
/* ************************************************************************* */
@@ -84,9 +83,9 @@ PoseRTV PoseRTV::retract(const Vector& v) const {
Vector PoseRTV::localCoordinates(const PoseRTV& p1) const {
const Pose3& x0 = pose(), &x1 = p1.pose();
// First order approximation
- Vector poseLogmap = x0.localCoordinates(x1);
- Vector lv = rotation().unrotate(p1.velocity() - v_).vector();
- return concatVectors(2, &poseLogmap, &lv);
+ Vector6 poseLogmap = x0.localCoordinates(x1);
+ Vector3 lv = rotation().unrotate(p1.velocity() - v_).vector();
+ return (Vector(9) << poseLogmap, lv);
}
/* ************************************************************************* */
@@ -190,16 +189,16 @@ PoseRTV PoseRTV::generalDynamics(
}
/* ************************************************************************* */
-Vector PoseRTV::imuPrediction(const PoseRTV& x2, double dt) const {
+Vector6 PoseRTV::imuPrediction(const PoseRTV& x2, double dt) const {
// split out states
const Rot3 &r1 = R(), &r2 = x2.R();
const Velocity3 &v1 = v(), &v2 = x2.v();
- Vector imu(6);
+ Vector6 imu;
// acceleration
Vector accel = v1.localCoordinates(v2) / dt;
- imu.head(3) = r2.transpose() * (accel - g);
+ imu.head<3>() = r2.transpose() * (accel - g);
// rotation rates
// just using euler angles based on matlab code
@@ -211,7 +210,7 @@ Vector PoseRTV::imuPrediction(const PoseRTV& x2, double dt) const {
// normalize yaw in difference (as per Mitch's code)
dR(2) = Rot2::fromAngle(dR(2)).theta();
dR /= dt;
- imu.tail(3) = Enb * dR;
+ imu.tail<3>() = Enb * dR;
// imu.tail(3) = r1.transpose() * dR;
return imu;
diff --git a/gtsam_unstable/dynamics/PoseRTV.h b/gtsam_unstable/dynamics/PoseRTV.h
index ae4ddade4..43d018752 100644
--- a/gtsam_unstable/dynamics/PoseRTV.h
+++ b/gtsam_unstable/dynamics/PoseRTV.h
@@ -86,8 +86,8 @@ public:
* expmap/logmap are poor approximations that assume independence of components
* Currently implemented using the poor retract/unretract approximations
*/
- static PoseRTV Expmap(const Vector& v);
- static Vector Logmap(const PoseRTV& p);
+ static PoseRTV Expmap(const Vector9& v);
+ static Vector9 Logmap(const PoseRTV& p);
static PoseRTV identity() { return PoseRTV(); }
@@ -129,7 +129,7 @@ public:
/// Dynamics predictor for both ground and flying robots, given states at 1 and 2
/// Always move from time 1 to time 2
/// @return imu measurement, as [accel, gyro]
- Vector imuPrediction(const PoseRTV& x2, double dt) const;
+ Vector6 imuPrediction(const PoseRTV& x2, double dt) const;
/// predict measurement and where Point3 for x2 should be, as a way
/// of enforcing a velocity constraint
diff --git a/gtsam_unstable/dynamics/SimpleHelicopter.h b/gtsam_unstable/dynamics/SimpleHelicopter.h
index 52dcea2db..06d485a88 100644
--- a/gtsam_unstable/dynamics/SimpleHelicopter.h
+++ b/gtsam_unstable/dynamics/SimpleHelicopter.h
@@ -9,7 +9,6 @@
#include
#include
-#include
#include
namespace gtsam {
@@ -24,10 +23,10 @@ namespace gtsam {
* Note: this factor is necessary if one needs to smooth the entire graph. It's not needed
* in sequential update method.
*/
-class Reconstruction : public NoiseModelFactor3 {
+class Reconstruction : public NoiseModelFactor3 {
double h_; // time step
- typedef NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
public:
Reconstruction(Key gKey1, Key gKey, Key xiKey, double h, double mu = 1000.0) :
Base(noiseModel::Constrained::All(Pose3::Dim(), fabs(mu)), gKey1, gKey,
@@ -41,7 +40,7 @@ public:
gtsam::NonlinearFactor::shared_ptr(new Reconstruction(*this))); }
/** \f$ log((g_k\exp(h\xi_k))^{-1}g_{k+1}) = 0, with optional derivatives */
- Vector evaluateError(const Pose3& gk1, const Pose3& gk, const LieVector& xik,
+ Vector evaluateError(const Pose3& gk1, const Pose3& gk, const Vector6& xik,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
@@ -74,7 +73,7 @@ public:
/**
* Implement the Discrete Euler-Poincare' equation:
*/
-class DiscreteEulerPoincareHelicopter : public NoiseModelFactor3 {
+class DiscreteEulerPoincareHelicopter : public NoiseModelFactor3 {
double h_; /// time step
Matrix Inertia_; /// Inertia tensors Inertia = [ J 0; 0 M ]
@@ -87,7 +86,7 @@ class DiscreteEulerPoincareHelicopter : public NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
public:
DiscreteEulerPoincareHelicopter(Key xiKey1, Key xiKey_1, Key gKey,
@@ -108,7 +107,7 @@ public:
* where pk = CT_TLN(h*xi_k)*Inertia*xi_k
* pk_1 = CT_TLN(-h*xi_k_1)*Inertia*xi_k_1
* */
- Vector evaluateError(const LieVector& xik, const LieVector& xik_1, const Pose3& gk,
+ Vector evaluateError(const Vector6& xik, const Vector6& xik_1, const Pose3& gk,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
@@ -149,7 +148,7 @@ public:
}
#if 0
- Vector computeError(const LieVector& xik, const LieVector& xik_1, const Pose3& gk) const {
+ Vector computeError(const Vector6& xik, const Vector6& xik_1, const Pose3& gk) const {
Vector pk = Pose3::dExpInv_exp(h_*xik).transpose()*Inertia_*xik;
Vector pk_1 = Pose3::dExpInv_exp(-h_*xik_1).transpose()*Inertia_*xik_1;
@@ -161,13 +160,13 @@ public:
return hx;
}
- Vector evaluateError(const LieVector& xik, const LieVector& xik_1, const Pose3& gk,
+ Vector evaluateError(const Vector6& xik, const Vector6& xik_1, const Pose3& gk,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
if (H1) {
(*H1) = numericalDerivative31(
- boost::function(
+ boost::function(
boost::bind(&DiscreteEulerPoincareHelicopter::computeError, *this, _1, _2, _3)
),
xik, xik_1, gk, 1e-5
@@ -175,7 +174,7 @@ public:
}
if (H2) {
(*H2) = numericalDerivative32(
- boost::function(
+ boost::function(
boost::bind(&DiscreteEulerPoincareHelicopter::computeError, *this, _1, _2, _3)
),
xik, xik_1, gk, 1e-5
@@ -183,7 +182,7 @@ public:
}
if (H3) {
(*H3) = numericalDerivative33(
- boost::function(
+ boost::function(
boost::bind(&DiscreteEulerPoincareHelicopter::computeError, *this, _1, _2, _3)
),
xik, xik_1, gk, 1e-5
diff --git a/gtsam_unstable/dynamics/VelocityConstraint3.h b/gtsam_unstable/dynamics/VelocityConstraint3.h
index 83506e2d5..1a432ba1e 100644
--- a/gtsam_unstable/dynamics/VelocityConstraint3.h
+++ b/gtsam_unstable/dynamics/VelocityConstraint3.h
@@ -1,21 +1,20 @@
/**
* @file VelocityConstraint3.h
- * @brief A simple 3-way factor constraining LieScalar poses and velocity
+ * @brief A simple 3-way factor constraining double poses and velocity
* @author Duy-Nguyen Ta
*/
#pragma once
-#include
#include
namespace gtsam {
-class VelocityConstraint3 : public NoiseModelFactor3 {
+class VelocityConstraint3 : public NoiseModelFactor3 {
public:
protected:
- typedef NoiseModelFactor3 Base;
+ typedef NoiseModelFactor3 Base;
/** default constructor to allow for serialization */
VelocityConstraint3() {}
@@ -28,7 +27,7 @@ public:
///TODO: comment
VelocityConstraint3(Key key1, Key key2, Key velKey, double dt, double mu = 1000.0)
- : Base(noiseModel::Constrained::All(LieScalar::Dim(), fabs(mu)), key1, key2, velKey), dt_(dt) {}
+ : Base(noiseModel::Constrained::All(1, fabs(mu)), key1, key2, velKey), dt_(dt) {}
virtual ~VelocityConstraint3() {}
/// @return a deep copy of this factor
@@ -37,15 +36,15 @@ public:
gtsam::NonlinearFactor::shared_ptr(new VelocityConstraint3(*this))); }
/** x1 + v*dt - x2 = 0, with optional derivatives */
- Vector evaluateError(const LieScalar& x1, const LieScalar& x2, const LieScalar& v,
+ Vector evaluateError(const double& x1, const double& x2, const double& v,
boost::optional H1 = boost::none,
boost::optional H2 = boost::none,
boost::optional H3 = boost::none) const {
- const size_t p = LieScalar::Dim();
+ const size_t p = 1;
if (H1) *H1 = eye(p);
if (H2) *H2 = -eye(p);
if (H3) *H3 = eye(p)*dt_;
- return x2.localCoordinates(x1.compose(LieScalar(v*dt_)));
+ return (Vector(1) << x1+v*dt_-x2);
}
private:
diff --git a/gtsam_unstable/dynamics/tests/testIMUSystem.cpp b/gtsam_unstable/dynamics/tests/testIMUSystem.cpp
index be7078d9a..550b0e33c 100644
--- a/gtsam_unstable/dynamics/tests/testIMUSystem.cpp
+++ b/gtsam_unstable/dynamics/tests/testIMUSystem.cpp
@@ -62,10 +62,9 @@ TEST( testIMUSystem, optimize_chain ) {
// create measurements
SharedDiagonal model = noiseModel::Unit::Create(6);
- Vector imu12(6), imu23(6), imu34(6);
- imu12 = pose1.imuPrediction(pose2, dt);
- imu23 = pose2.imuPrediction(pose3, dt);
- imu34 = pose3.imuPrediction(pose4, dt);
+ Vector6 imu12 = pose1.imuPrediction(pose2, dt);
+ Vector6 imu23 = pose2.imuPrediction(pose3, dt);
+ Vector6 imu34 = pose3.imuPrediction(pose4, dt);
// assemble simple graph with IMU measurements and velocity constraints
NonlinearFactorGraph graph;
@@ -109,10 +108,9 @@ TEST( testIMUSystem, optimize_chain_fullfactor ) {
// create measurements
SharedDiagonal model = noiseModel::Isotropic::Sigma(9, 1.0);
- Vector imu12(6), imu23(6), imu34(6);
- imu12 = pose1.imuPrediction(pose2, dt);
- imu23 = pose2.imuPrediction(pose3, dt);
- imu34 = pose3.imuPrediction(pose4, dt);
+ Vector6 imu12 = pose1.imuPrediction(pose2, dt);
+ Vector6 imu23 = pose2.imuPrediction(pose3, dt);
+ Vector6 imu34 = pose3.imuPrediction(pose4, dt);
// assemble simple graph with IMU measurements and velocity constraints
NonlinearFactorGraph graph;
diff --git a/gtsam_unstable/dynamics/tests/testPendulumFactors.cpp b/gtsam_unstable/dynamics/tests/testPendulumFactors.cpp
index ce176787c..5a4593270 100644
--- a/gtsam_unstable/dynamics/tests/testPendulumFactors.cpp
+++ b/gtsam_unstable/dynamics/tests/testPendulumFactors.cpp
@@ -18,8 +18,8 @@ namespace {
const double g = 9.81, l = 1.0;
const double deg2rad = M_PI/180.0;
- LieScalar origin, q1(deg2rad*30.0), q2(deg2rad*31.0);
- LieScalar v1(deg2rad*1.0/h), v2((v1-h*g/l*sin(q1)));
+ double q1(deg2rad*30.0), q2(deg2rad*31.0);
+ double v1(deg2rad*1.0/h), v2((v1-h*g/l*sin(q1)));
}
@@ -46,7 +46,7 @@ TEST( testPendulumFactorPk, evaluateError) {
// hard constraints don't need a noise model
PendulumFactorPk constraint(P(1), Q(1), Q(2), h);
- LieScalar pk( 1/h * (q2-q1) + h*g*sin(q1) );
+ double pk( 1/h * (q2-q1) + h*g*sin(q1) );
// verify error function
EXPECT(assert_equal(zero(1), constraint.evaluateError(pk, q1, q2), tol));
@@ -57,7 +57,7 @@ TEST( testPendulumFactorPk1, evaluateError) {
// hard constraints don't need a noise model
PendulumFactorPk1 constraint(P(2), Q(1), Q(2), h);
- LieScalar pk1( 1/h * (q2-q1) );
+ double pk1( 1/h * (q2-q1) );
// verify error function
EXPECT(assert_equal(zero(1), constraint.evaluateError(pk1, q1, q2), tol));
diff --git a/gtsam_unstable/dynamics/tests/testVelocityConstraint3.cpp b/gtsam_unstable/dynamics/tests/testVelocityConstraint3.cpp
index db4b7c586..ac27ae563 100644
--- a/gtsam_unstable/dynamics/tests/testVelocityConstraint3.cpp
+++ b/gtsam_unstable/dynamics/tests/testVelocityConstraint3.cpp
@@ -8,23 +8,16 @@
#include