@@ -23,14 +23,22 @@ namespace cartographer {
23
23
namespace pose_graph {
24
24
namespace {
25
25
26
- void AddRotationParameters (Pose3D* pose, ceres::Problem* problem) {
26
+ void AddRotation3D (Pose3D* pose, ceres::Problem* problem) {
27
27
auto rotation = pose->mutable_rotation ();
28
28
problem->AddParameterBlock (rotation->data (), rotation->size ());
29
29
if (pose->constant ()) {
30
30
problem->SetParameterBlockConstant (rotation->data ());
31
31
}
32
32
}
33
33
34
+ void AddImuOrientation (ImuCalibration* imu_node, ceres::Problem* problem) {
35
+ auto imu_orientation = imu_node->mutable_orientation ();
36
+ problem->AddParameterBlock (imu_orientation->data (), imu_orientation->size ());
37
+ if (imu_node->constant ()) {
38
+ problem->SetParameterBlockConstant (imu_orientation->data ());
39
+ }
40
+ }
41
+
34
42
} // namespace
35
43
36
44
RotationContraint3D::RotationContraint3D (
@@ -62,25 +70,20 @@ void RotationContraint3D::AddToOptimizer(Nodes* nodes,
62
70
return ;
63
71
}
64
72
65
- auto imu_calibration_node =
73
+ auto imu_node =
66
74
common::FindOrNull (nodes->imu_calibration_nodes , imu_calibration_);
67
- if (imu_calibration_node == nullptr ) {
75
+ if (imu_node == nullptr ) {
68
76
LOG (INFO) << " Imu calibration node was not found." ;
69
77
return ;
70
78
}
71
79
72
- AddRotationParameters (first_node, problem);
73
- AddRotationParameters (second_node, problem);
74
- auto imu_orientation = imu_calibration_node->mutable_orientation ();
75
- problem->AddParameterBlock (imu_orientation->data (), imu_orientation->size ());
76
- if (imu_calibration_node->constant ()) {
77
- problem->SetParameterBlockConstant (imu_orientation->data ());
78
- }
79
-
80
- problem->AddResidualBlock (ceres_cost_.get (), nullptr /* loss function */ ,
80
+ AddRotation3D (first_node, problem);
81
+ AddRotation3D (second_node, problem);
82
+ AddImuOrientation (imu_node, problem);
83
+ problem->AddResidualBlock (ceres_cost_.get (), ceres_loss (),
81
84
first_node->mutable_rotation ()->data (),
82
85
second_node->mutable_rotation ()->data (),
83
- imu_orientation ->data ());
86
+ imu_node-> mutable_orientation () ->data ());
84
87
}
85
88
86
89
proto::CostFunction RotationContraint3D::ToCostFunctionProto () const {
0 commit comments