Skip to content

Commit 7f3ebab

Browse files
committed
Use Matrix initializer_list constructor instead of comma initializers
1 parent a3b8a34 commit 7f3ebab

201 files changed

Lines changed: 2366 additions & 2681 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/Code/LocalizationFactor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ class UnaryFactor: public NoiseModelFactor1<Pose2> {
1111

1212
Vector evaluateError(const Pose2& q, OptionalMatrixType H) const override {
1313
const Rot2& R = q.rotation();
14-
if (H) (*H) = (gtsam::Matrix(2, 3) <<
15-
R.c(), -R.s(), 0.0,
16-
R.s(), R.c(), 0.0).finished();
17-
return (Vector(2) << q.x() - mx_, q.y() - my_).finished();
14+
if (H) (*H) = gtsam::Matrix23{{R.c(), -R.s(), 0.0}, {R.s(), R.c(), 0.0}};
15+
return Vector{{q.x() - mx_, q.y() - my_}};
1816
}
1917
};

examples/CombinedImuFactorsExample.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ int main(int argc, char* argv[]) {
175175

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

examples/GaussianProcessWnoaSE3Example.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ int main() {
117117
// Define measurement noise model and WNOA process noise covariance.
118118
// These define the prior belief about measurement and process uncertainties.
119119
Eigen::Matrix<double, kDoF, kDoF> measurement_cov =
120-
1e-2 * (Eigen::Matrix<double, kDoF, 1>() << 0.1, 0.1, 0.1, 1.0, 1.0, 1.0)
121-
.finished()
122-
.asDiagonal();
120+
1e-2 *
121+
Eigen::Matrix<double, kDoF, 1>{{0.1}, {0.1}, {0.1}, {1.0}, {1.0}, {1.0}}
122+
.asDiagonal();
123123
const auto noise_model =
124124
gtsam::noiseModel::Gaussian::Covariance(measurement_cov);
125125

@@ -182,8 +182,7 @@ int main() {
182182

183183
// Create initial trajectory estimate using constant velocity assumption.
184184
// This provides a reasonable starting point for the optimizer.
185-
const Velocity initial_twist =
186-
(Velocity() << 0.0, 0.0, 0.0, -1.0, 0.0, 0.0).finished();
185+
const Velocity initial_twist{{0.0}, {0.0}, {0.0}, {-1.0}, {0.0}, {0.0}};
187186
gtsam::Values values_init;
188187
Pose running_pose = values_gt.at<Pose>(estimated_states_vec.front().pose);
189188
values_init.insert(estimated_states_vec.front().pose, running_pose);

examples/IMUKittiExampleGPS.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,9 @@ int main(int argc, char* argv[]) {
160160
vector<GpsMeasurement> gps_measurements;
161161
loadKittiData(kitti_calibration, imu_measurements, gps_measurements);
162162

163-
Vector6 BodyP =
164-
(Vector6() << kitti_calibration.body_ptx, kitti_calibration.body_pty,
165-
kitti_calibration.body_ptz, kitti_calibration.body_prx,
166-
kitti_calibration.body_pry, kitti_calibration.body_prz)
167-
.finished();
163+
Vector6 BodyP{kitti_calibration.body_ptx, kitti_calibration.body_pty,
164+
kitti_calibration.body_ptz, kitti_calibration.body_prx,
165+
kitti_calibration.body_pry, kitti_calibration.body_prz};
168166
auto body_T_imu = Pose3::Expmap(BodyP);
169167
if (!body_T_imu.equals(Pose3(), 1e-5)) {
170168
printf(

examples/ImuFactorsExample.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ int main(int argc, char* argv[]) {
182182

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

examples/LeggedEstimatorReplayExample.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ struct ReplayConfig : public LeggedEstimatorParams {
7171
Vector3 gravity = Vector3(0.0, 0.0, -9.81);
7272
Point3 initialPosition = Point3(0.0, 0.0, 0.76);
7373
Vector3 initialVelocity = Vector3::Zero();
74-
Vector initialBaseCovarianceDiagonal =
75-
(Vector(9) << 1e-2, 1e-2, 1e-6, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05)
76-
.finished();
74+
Vector initialBaseCovarianceDiagonal{
75+
{1e-2, 1e-2, 1e-6, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05}};
7776
double sigmaGyro = 8e-4;
7877
double sigmaIntegration = 1e-3;
7978
double sigmaAcc = 2e-2;

examples/LocalizationExample.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class UnaryFactor: public NoiseModelFactorN<Pose2> {
9797
// H = [ cos(q.theta) -sin(q.theta) 0 ]
9898
// [ sin(q.theta) cos(q.theta) 0 ]
9999
const Rot2& R = q.rotation();
100-
if (H) (*H) = (gtsam::Matrix(2, 3) << R.c(), -R.s(), 0.0, R.s(), R.c(), 0.0).finished();
101-
return (Vector(2) << q.x() - mx_, q.y() - my_).finished();
100+
if (H) (*H) = gtsam::Matrix{{R.c(), -R.s(), 0.0}, {R.s(), R.c(), 0.0}};
101+
return Vector{{q.x() - mx_, q.y() - my_}};
102102
}
103103

104104
// The second is a 'clone' function that allows the factor to be copied. Under most

examples/Pose2SLAMExample_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main (int argc, char** argv) {
3434
// we are in build/examples, data is in examples/Data
3535
NonlinearFactorGraph::shared_ptr graph;
3636
Values::shared_ptr initial;
37-
SharedDiagonal model = noiseModel::Diagonal::Sigmas((Vector(3) << 0.05, 0.05, 5.0 * M_PI / 180.0).finished());
37+
SharedDiagonal model = noiseModel::Diagonal::Sigmas(Vector{{0.05, 0.05, 5.0 * M_PI / 180.0}});
3838
string graph_file = findExampleDataFile("w100.graph");
3939
std::tie(graph, initial) = load2D(graph_file, model);
4040
initial->print("Initial estimate:\n");

examples/Pose3Localization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int main(const int argc, const char* argv[]) {
4141

4242
// Add prior on the first key
4343
auto priorModel = noiseModel::Diagonal::Variances(
44-
(Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
44+
Vector{{1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4}});
4545
Key firstKey = 0;
4646
for (const auto key : initial->keys()) {
4747
std::cout << "Adding prior to g2o file " << std::endl;

examples/Pose3SLAMExampleExpressions_BearingRangeWithTransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ int main(int argc, char* argv[]) {
4343
ExpressionFactorGraph graph;
4444

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

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

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

100100
return 0;
101101
}
102-
/* ************************************************************************* */
102+
/* ************************************************************************* */

0 commit comments

Comments
 (0)