Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/Code/LocalizationFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class UnaryFactor: public NoiseModelFactor1<Pose2> {

Vector evaluateError(const Pose2& q, OptionalMatrixType H) const override {
const Rot2& R = q.rotation();
if (H) (*H) = (gtsam::Matrix(2, 3) <<
R.c(), -R.s(), 0.0,
R.s(), R.c(), 0.0).finished();
return (Vector(2) << q.x() - mx_, q.y() - my_).finished();
if (H) (*H) = gtsam::Matrix23{{R.c(), -R.s(), 0.0}, {R.s(), R.c(), 0.0}};
return Vector{{q.x() - mx_, q.y() - my_}};
}
};
3 changes: 1 addition & 2 deletions examples/CombinedImuFactorsExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ int main(int argc, char* argv[]) {

// Assemble prior noise model and add it the graph.`
auto pose_noise_model = noiseModel::Diagonal::Sigmas(
(Vector(6) << 0.01, 0.01, 0.01, 0.5, 0.5, 0.5)
.finished()); // rad,rad,rad,m, m, m
Vector{{0.01, 0.01, 0.01, 0.5, 0.5, 0.5}}); // rad,rad,rad,m, m, m
auto velocity_noise_model = noiseModel::Isotropic::Sigma(3, 0.1); // m/s
auto bias_noise_model = noiseModel::Isotropic::Sigma(6, 1e-3);

Expand Down
9 changes: 4 additions & 5 deletions examples/GaussianProcessWnoaSE3Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ int main() {
// Define measurement noise model and WNOA process noise covariance.
// These define the prior belief about measurement and process uncertainties.
Eigen::Matrix<double, kDoF, kDoF> measurement_cov =
1e-2 * (Eigen::Matrix<double, kDoF, 1>() << 0.1, 0.1, 0.1, 1.0, 1.0, 1.0)
.finished()
.asDiagonal();
1e-2 *
Eigen::Matrix<double, kDoF, 1>{{0.1}, {0.1}, {0.1}, {1.0}, {1.0}, {1.0}}
.asDiagonal();
const auto noise_model =
gtsam::noiseModel::Gaussian::Covariance(measurement_cov);

Expand Down Expand Up @@ -182,8 +182,7 @@ int main() {

// Create initial trajectory estimate using constant velocity assumption.
// This provides a reasonable starting point for the optimizer.
const Velocity initial_twist =
(Velocity() << 0.0, 0.0, 0.0, -1.0, 0.0, 0.0).finished();
const Velocity initial_twist{{0.0}, {0.0}, {0.0}, {-1.0}, {0.0}, {0.0}};
gtsam::Values values_init;
Pose running_pose = values_gt.at<Pose>(estimated_states_vec.front().pose);
values_init.insert(estimated_states_vec.front().pose, running_pose);
Expand Down
8 changes: 3 additions & 5 deletions examples/IMUKittiExampleGPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,9 @@ int main(int argc, char* argv[]) {
vector<GpsMeasurement> gps_measurements;
loadKittiData(kitti_calibration, imu_measurements, gps_measurements);

Vector6 BodyP =
(Vector6() << kitti_calibration.body_ptx, kitti_calibration.body_pty,
kitti_calibration.body_ptz, kitti_calibration.body_prx,
kitti_calibration.body_pry, kitti_calibration.body_prz)
.finished();
Vector6 BodyP{kitti_calibration.body_ptx, kitti_calibration.body_pty,
kitti_calibration.body_ptz, kitti_calibration.body_prx,
kitti_calibration.body_pry, kitti_calibration.body_prz};
auto body_T_imu = Pose3::Expmap(BodyP);
if (!body_T_imu.equals(Pose3(), 1e-5)) {
printf(
Expand Down
3 changes: 1 addition & 2 deletions examples/ImuFactorsExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ int main(int argc, char* argv[]) {

// Assemble prior noise model and add it the graph.`
auto pose_noise_model = noiseModel::Diagonal::Sigmas(
(Vector(6) << 0.01, 0.01, 0.01, 0.5, 0.5, 0.5)
.finished()); // rad,rad,rad,m, m, m
Vector{{0.01, 0.01, 0.01, 0.5, 0.5, 0.5}}); // rad,rad,rad,m, m, m
auto velocity_noise_model = noiseModel::Isotropic::Sigma(3, 0.1); // m/s
auto bias_noise_model = noiseModel::Isotropic::Sigma(6, 1e-3);

Expand Down
5 changes: 2 additions & 3 deletions examples/LeggedEstimatorReplayExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ struct ReplayConfig : public LeggedEstimatorParams {
Vector3 gravity = Vector3(0.0, 0.0, -9.81);
Point3 initialPosition = Point3(0.0, 0.0, 0.76);
Vector3 initialVelocity = Vector3::Zero();
Vector initialBaseCovarianceDiagonal =
(Vector(9) << 1e-2, 1e-2, 1e-6, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05)
.finished();
Vector initialBaseCovarianceDiagonal{
{1e-2, 1e-2, 1e-6, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05}};
double sigmaGyro = 8e-4;
double sigmaIntegration = 1e-3;
double sigmaAcc = 2e-2;
Expand Down
4 changes: 2 additions & 2 deletions examples/LocalizationExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class UnaryFactor: public NoiseModelFactorN<Pose2> {
// H = [ cos(q.theta) -sin(q.theta) 0 ]
// [ sin(q.theta) cos(q.theta) 0 ]
const Rot2& R = q.rotation();
if (H) (*H) = (gtsam::Matrix(2, 3) << R.c(), -R.s(), 0.0, R.s(), R.c(), 0.0).finished();
return (Vector(2) << q.x() - mx_, q.y() - my_).finished();
if (H) (*H) = gtsam::Matrix{{R.c(), -R.s(), 0.0}, {R.s(), R.c(), 0.0}};
return Vector{{q.x() - mx_, q.y() - my_}};
}

// The second is a 'clone' function that allows the factor to be copied. Under most
Expand Down
2 changes: 1 addition & 1 deletion examples/Pose2SLAMExample_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main (int argc, char** argv) {
// we are in build/examples, data is in examples/Data
NonlinearFactorGraph::shared_ptr graph;
Values::shared_ptr initial;
SharedDiagonal model = noiseModel::Diagonal::Sigmas((Vector(3) << 0.05, 0.05, 5.0 * M_PI / 180.0).finished());
SharedDiagonal model = noiseModel::Diagonal::Sigmas(Vector{{0.05, 0.05, 5.0 * M_PI / 180.0}});
string graph_file = findExampleDataFile("w100.graph");
std::tie(graph, initial) = load2D(graph_file, model);
initial->print("Initial estimate:\n");
Expand Down
2 changes: 1 addition & 1 deletion examples/Pose3Localization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(const int argc, const char* argv[]) {

// Add prior on the first key
auto priorModel = noiseModel::Diagonal::Variances(
(Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
Vector{{1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4}});
Key firstKey = 0;
for (const auto key : initial->keys()) {
std::cout << "Adding prior to g2o file " << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ int main(int argc, char* argv[]) {
ExpressionFactorGraph graph;

// Specify uncertainty on first pose prior and also for between factor (simplicity reasons)
auto poseNoise = noiseModel::Diagonal::Sigmas((Vector(6)<<0.3,0.3,0.3,0.1,0.1,0.1).finished());
auto poseNoise = noiseModel::Diagonal::Sigmas(Vector{{0.3,0.3,0.3,0.1,0.1,0.1}});

// Uncertainty bearing range measurement;
auto bearingRangeNoise = noiseModel::Diagonal::Sigmas((Vector(3)<<0.01,0.03,0.05).finished());
auto bearingRangeNoise = noiseModel::Diagonal::Sigmas(Vector{{0.01,0.03,0.05}});

// Expressions for body-frame at key 0 and sensor-tf
Pose3_ x_('x', 0);
Expand Down Expand Up @@ -99,4 +99,4 @@ int main(int argc, char* argv[]) {

return 0;
}
/* ************************************************************************* */
/* ************************************************************************* */
2 changes: 1 addition & 1 deletion examples/Pose3SLAMExample_g2o.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(const int argc, const char* argv[]) {

// Add prior on the first key
auto priorModel = noiseModel::Diagonal::Variances(
(Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
Vector{{1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4}});
Key firstKey = 0;
for (const auto key : initial->keys()) {
std::cout << "Adding prior to g2o file " << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/Pose3SLAMExample_initializePose3Chordal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(const int argc, const char* argv[]) {

// Add prior on the first key
auto priorModel = noiseModel::Diagonal::Variances(
(Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
Vector{{1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4}});
Key firstKey = 0;
for (const auto key : initial->keys()) {
std::cout << "Adding prior to g2o file " << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/Pose3SLAMExample_initializePose3Gradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(const int argc, const char* argv[]) {

// Add prior on the first key
auto priorModel = noiseModel::Diagonal::Variances(
(Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
Vector{{1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4}});
Key firstKey = 0;
for (const auto key : initial->keys()) {
std::cout << "Adding prior to g2o file " << std::endl;
Expand Down
5 changes: 2 additions & 3 deletions examples/SelfCalibrationExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ int main(int argc, char* argv[]) {
pointNoise); // add directly to graph

// Add a prior on the calibration.
auto calNoise = noiseModel::Diagonal::Sigmas(
(Vector(5) << 500, 500, 0.1, 100, 100).finished());
auto calNoise =
noiseModel::Diagonal::Sigmas(Vector{{500, 500, 0.1, 100, 100}});
graph.addPrior(Symbol('K', 0), K, calNoise);

// Create the initial estimate to the solution
Expand All @@ -102,4 +102,3 @@ int main(int argc, char* argv[]) {

return 0;
}

2 changes: 1 addition & 1 deletion examples/elaboratePoint2KalmanFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ int main() {

// And update using z2 ...
Point2 z2(2.0, 0.0);
SharedDiagonal R2 = noiseModel::Diagonal::Sigmas((gtsam::Vector2() << 0.25, 0.25).finished());
SharedDiagonal R2 = noiseModel::Diagonal::Sigmas(gtsam::Vector2{0.25, 0.25});
PriorFactor<Point2> factor8(X(2), z2, R2);

// Linearize the factor and add it to the linear factor graph
Expand Down
2 changes: 1 addition & 1 deletion gtsam/base/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ GTSAM_EXPORT Matrix vector_scale(const Matrix& A, const Vector& v, bool inf_mask
*/

inline Matrix3 skewSymmetric(double wx, double wy, double wz) {
return (Matrix3() << 0.0, -wz, +wy, +wz, 0.0, -wx, -wy, +wx, 0.0).finished();
return Matrix3{{0.0, -wz, +wy}, {+wz, 0.0, -wx}, {-wy, +wx, 0.0}};
}

template <class Derived>
Expand Down
28 changes: 14 additions & 14 deletions gtsam/base/tests/testCholesky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ TEST(cholesky, choleskyPartial0) {

/* ************************************************************************* */
TEST(cholesky, choleskyPartial) {
Matrix ABC = (Matrix(7,7) <<
4.0375, 3.4584, 3.5735, 2.4815, 2.1471, 2.7400, 2.2063,
0., 4.7267, 3.8423, 2.3624, 2.8091, 2.9579, 2.5914,
0., 0., 5.1600, 2.0797, 3.4690, 3.2419, 2.9992,
0., 0., 0., 1.8786, 1.0535, 1.4250, 1.3347,
0., 0., 0., 0., 3.0788, 2.6283, 2.3791,
0., 0., 0., 0., 0., 2.9227, 2.4056,
0., 0., 0., 0., 0., 0., 2.5776).finished();
Matrix ABC{
{4.0375, 3.4584, 3.5735, 2.4815, 2.1471, 2.7400, 2.2063},
{0., 4.7267, 3.8423, 2.3624, 2.8091, 2.9579, 2.5914},
{0., 0., 5.1600, 2.0797, 3.4690, 3.2419, 2.9992},
{0., 0., 0., 1.8786, 1.0535, 1.4250, 1.3347},
{0., 0., 0., 0., 3.0788, 2.6283, 2.3791},
{0., 0., 0., 0., 0., 2.9227, 2.4056},
{0., 0., 0., 0., 0., 0., 2.5776}};

// Do partial Cholesky on 3 frontal scalar variables
Matrix RSL(ABC);
Expand All @@ -68,9 +68,9 @@ TEST(cholesky, choleskyPartial) {

/* ************************************************************************* */
TEST(cholesky, BadScalingCholesky) {
Matrix A = (Matrix(2,2) <<
1e-40, 0.0,
0.0, 1.0).finished();
Matrix A{
{1e-40, 0.0},
{0.0, 1.0}};

Matrix R(A.transpose() * A);
choleskyPartial(R, 2);
Expand All @@ -83,9 +83,9 @@ TEST(cholesky, BadScalingCholesky) {

/* ************************************************************************* */
TEST(cholesky, BadScalingSVD) {
Matrix A = (Matrix(2,2) <<
1.0, 0.0,
0.0, 1e-40).finished();
Matrix A{
{1.0, 0.0},
{0.0, 1e-40}};

Matrix U, V;
Vector S;
Expand Down
Loading