1 // Ceres Solver - A fast non-linear least squares minimizer
2 // Copyright 2016 Google Inc. All rights reserved.
3 // http://ceres-solver.org/
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors may be
14 // used to endorse or promote products derived from this software without
15 // specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
29 // Author: vitus@google.com (Michael Vitus)
31 // Defines the types used in the 2D pose graph SLAM formulation. Each vertex of
32 // the graph has a unique integer ID with a position and orientation. There are
33 // delta transformation constraints between two vertices.
35 #ifndef CERES_EXAMPLES_POSE_GRAPH_2D_TYPES_H_
36 #define CERES_EXAMPLES_POSE_GRAPH_2D_TYPES_H_
41 #include "normalize_angle.h"
46 // The state for each vertex in the pose graph.
52 // The name of the data type in the g2o file format.
53 static std::string name() {
58 std::istream& operator>>(std::istream& input, Pose2d& pose) {
59 input >> pose.x >> pose.y >> pose.yaw_radians;
60 // Normalize the angle between -pi to pi.
61 pose.yaw_radians = NormalizeAngle(pose.yaw_radians);
65 // The constraint between two vertices in the pose graph. The constraint is the
66 // transformation from vertex id_begin to vertex id_end.
75 // The inverse of the covariance matrix for the measurement. The order of the
76 // entries are x, y, and yaw.
77 Eigen::Matrix3d information;
79 // The name of the data type in the g2o file format.
80 static std::string name() {
85 std::istream& operator>>(std::istream& input, Constraint2d& constraint) {
86 input >> constraint.id_begin >> constraint.id_end >> constraint.x >>
87 constraint.y >> constraint.yaw_radians >>
88 constraint.information(0, 0) >> constraint.information(0, 1) >>
89 constraint.information(0, 2) >> constraint.information(1, 1) >>
90 constraint.information(1, 2) >> constraint.information(2, 2);
92 // Set the lower triangular part of the information matrix.
93 constraint.information(1, 0) = constraint.information(0, 1);
94 constraint.information(2, 0) = constraint.information(0, 2);
95 constraint.information(2, 1) = constraint.information(1, 2);
97 // Normalize the angle between -pi to pi.
98 constraint.yaw_radians = NormalizeAngle(constraint.yaw_radians);
102 } // namespace examples
105 #endif // CERES_EXAMPLES_POSE_GRAPH_2D_TYPES_H_