MCPcopy Create free account
hub / github.com/PRBonn/MapClosures / BuildLinearSystem

Function BuildLinearSystem

cpp/map_closures/GroundAlign.cpp:131–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131LinearSystem BuildLinearSystem(const Vector3dVector &points) {
132 auto compute_jacobian_and_residual =
133 [](const Eigen::Vector3d &point) -> std::pair<Eigen::Matrix<double, 1, 3>, double> {
134 return {Eigen::Matrix<double, 1, 3>(1.0, point.y(), -point.x()), point.z()};
135 };
136
137 auto sum_linear_systems = [](LinearSystem a, const LinearSystem &b) -> LinearSystem {
138 a.first += b.first;
139 a.second += b.second;
140 return a;
141 };
142
143 const auto linear_system =
144 std::transform_reduce(points.cbegin(), points.cend(),
145 LinearSystem(Eigen::Matrix3d::Zero(), Eigen::Vector3d::Zero()),
146 sum_linear_systems, [&](const Eigen::Vector3d &point) {
147 const auto [J, residual] = compute_jacobian_and_residual(point);
148 const double w = std::exp(-1.0 * residual * residual);
149 return LinearSystem(J.transpose() * w * J, // JTJ
150 J.transpose() * w * residual); // JTr
151 });
152 return linear_system;
153}
154} // namespace
155
156namespace map_closures {

Callers 1

AlignToLocalGroundFunction · 0.85

Calls 2

cbeginMethod · 0.80
cendMethod · 0.80

Tested by

no test coverage detected