From b2d23015333b67764ce5fc665a40fd3880eadd04 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 6 Jun 2016 17:12:42 -0700 Subject: [PATCH] Fixed remaining default constructor calls --- gtsam/geometry/CameraSet.h | 5 +++-- gtsam/geometry/Pose2.h | 4 ++-- gtsam/geometry/tests/testPoint2.cpp | 4 ++-- gtsam/nonlinear/ExtendedKalmanFilter-inl.h | 14 ++++++-------- gtsam/slam/EssentialMatrixFactor.h | 2 +- .../slam/tests/testSmartProjectionCameraFactor.cpp | 10 ++-------- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/gtsam/geometry/CameraSet.h b/gtsam/geometry/CameraSet.h index 3cbe10651..a5cb5d046 100644 --- a/gtsam/geometry/CameraSet.h +++ b/gtsam/geometry/CameraSet.h @@ -106,7 +106,8 @@ public: // Allocate result size_t m = this->size(); - std::vector z(m); + std::vector z; + z.reserve(m); // Allocate derivatives if (E) E->resize(ZDim * m, N); @@ -116,7 +117,7 @@ public: for (size_t i = 0; i < m; i++) { MatrixZD Fi; Eigen::Matrix Ei; - z[i] = this->at(i).project2(point, Fs ? &Fi : 0, E ? &Ei : 0); + z.emplace_back(this->at(i).project2(point, Fs ? &Fi : 0, E ? &Ei : 0)); if (Fs) (*Fs)[i] = Fi; if (E) E->block(ZDim * i, 0) = Ei; } diff --git a/gtsam/geometry/Pose2.h b/gtsam/geometry/Pose2.h index b4a618db6..1ba384857 100644 --- a/gtsam/geometry/Pose2.h +++ b/gtsam/geometry/Pose2.h @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- - * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) @@ -88,7 +88,7 @@ public: /// @{ /** Construct from canonical coordinates \f$ [T_x,T_y,\theta] \f$ (Lie algebra) */ - Pose2(const Vector& v) { + Pose2(const Vector& v) : Pose2() { *this = Expmap(v); } diff --git a/gtsam/geometry/tests/testPoint2.cpp b/gtsam/geometry/tests/testPoint2.cpp index 87deba16c..04bab71ee 100644 --- a/gtsam/geometry/tests/testPoint2.cpp +++ b/gtsam/geometry/tests/testPoint2.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- - * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) @@ -119,7 +119,7 @@ TEST( Point2, unit) { namespace { /* ************************************************************************* */ // some shared test values - Point2 x1, x2(1, 1), x3(1, 1); + Point2 x1(0,0), x2(1, 1), x3(1, 1); Point2 l1(1, 0), l2(1, 1), l3(2, 2), l4(1, 3); /* ************************************************************************* */ diff --git a/gtsam/nonlinear/ExtendedKalmanFilter-inl.h b/gtsam/nonlinear/ExtendedKalmanFilter-inl.h index e0c4da94e..e85aceb15 100644 --- a/gtsam/nonlinear/ExtendedKalmanFilter-inl.h +++ b/gtsam/nonlinear/ExtendedKalmanFilter-inl.h @@ -61,16 +61,14 @@ namespace gtsam { } /* ************************************************************************* */ - template - ExtendedKalmanFilter::ExtendedKalmanFilter(Key key_initial, T x_initial, - noiseModel::Gaussian::shared_ptr P_initial) { - - // Set the initial linearization point to the provided mean - x_ = x_initial; - + template + ExtendedKalmanFilter::ExtendedKalmanFilter( + Key key_initial, T x_initial, noiseModel::Gaussian::shared_ptr P_initial) + : x_(x_initial) // Set the initial linearization point + { // Create a Jacobian Prior Factor directly P_initial. // Since x0 is set to the provided mean, the b vector in the prior will be zero - // TODO Frank asks: is there a reason why noiseModel is not simply P_initial ? + // TODO(Frank): is there a reason why noiseModel is not simply P_initial? int n = traits::GetDimension(x_initial); priorFactor_ = JacobianFactor::shared_ptr( new JacobianFactor(key_initial, P_initial->R(), Vector::Zero(n), diff --git a/gtsam/slam/EssentialMatrixFactor.h b/gtsam/slam/EssentialMatrixFactor.h index 0273ef6dd..e6b312b95 100644 --- a/gtsam/slam/EssentialMatrixFactor.h +++ b/gtsam/slam/EssentialMatrixFactor.h @@ -162,7 +162,7 @@ public: // The point d*P1 = (x,y,1) is computed in constructor as dP1_ // Project to normalized image coordinates, then uncalibrate - Point2 pn; + Point2 pn(0,0); if (!DE && !Dd) { Point3 _1T2 = E.direction().point3(); diff --git a/gtsam/slam/tests/testSmartProjectionCameraFactor.cpp b/gtsam/slam/tests/testSmartProjectionCameraFactor.cpp index 7eefb2398..0488c0f49 100644 --- a/gtsam/slam/tests/testSmartProjectionCameraFactor.cpp +++ b/gtsam/slam/tests/testSmartProjectionCameraFactor.cpp @@ -300,20 +300,14 @@ TEST( SmartProjectionCameraFactor, perturbPoseAndOptimizeFromSfM_tracks ) { SfM_Track track1; for (size_t i = 0; i < 3; ++i) { - SfM_Measurement measures; - measures.first = i + 1; // cameras are from 1 to 3 - measures.second = measurements_cam1.at(i); - track1.measurements.push_back(measures); + track1.measurements.emplace_back(i + 1, measurements_cam1.at(i)); } SmartFactor::shared_ptr smartFactor1(new SmartFactor(unit2)); smartFactor1->add(track1); SfM_Track track2; for (size_t i = 0; i < 3; ++i) { - SfM_Measurement measures; - measures.first = i + 1; // cameras are from 1 to 3 - measures.second = measurements_cam2.at(i); - track2.measurements.push_back(measures); + track2.measurements.emplace_back(i + 1, measurements_cam2.at(i)); } SmartFactor::shared_ptr smartFactor2(new SmartFactor(unit2)); smartFactor2->add(track2);