Improve pose terminology of 2D optimization problem. (#1053)
Removes the confusing term `initial_pose` from global 2D optimization. It makes sense in other areas like scan matching, but has a completely different meaning there. Also matches the 3D equivalents better. - `local_pose_2d` replaces `initial_pose` as the name for the non-gravity-aligned, local 2D pose in the submap - `global_pose_2d` replaces `pose` as the name for the non-gravity-aligned, global 2D pose that is optimized See the comment in the PR for how this improves readability.master
parent
14465aa23e
commit
d2f29d04b9
|
@ -231,7 +231,7 @@ void OptimizationProblem2D::Solve(
|
||||||
for (const auto& node_id_data : node_data_) {
|
for (const auto& node_id_data : node_data_) {
|
||||||
const bool frozen =
|
const bool frozen =
|
||||||
frozen_trajectories.count(node_id_data.id.trajectory_id) != 0;
|
frozen_trajectories.count(node_id_data.id.trajectory_id) != 0;
|
||||||
C_nodes.Insert(node_id_data.id, FromPose(node_id_data.data.pose));
|
C_nodes.Insert(node_id_data.id, FromPose(node_id_data.data.global_pose_2d));
|
||||||
problem.AddParameterBlock(C_nodes.at(node_id_data.id).data(), 3);
|
problem.AddParameterBlock(C_nodes.at(node_id_data.id).data(), 3);
|
||||||
if (frozen) {
|
if (frozen) {
|
||||||
problem.SetParameterBlockConstant(C_nodes.at(node_id_data.id).data());
|
problem.SetParameterBlockConstant(C_nodes.at(node_id_data.id).data());
|
||||||
|
@ -288,8 +288,8 @@ void OptimizationProblem2D::Solve(
|
||||||
|
|
||||||
// Add a relative pose constraint based on consecutive local SLAM poses.
|
// Add a relative pose constraint based on consecutive local SLAM poses.
|
||||||
const transform::Rigid3d relative_local_slam_pose =
|
const transform::Rigid3d relative_local_slam_pose =
|
||||||
transform::Embed3D(first_node_data.initial_pose.inverse() *
|
transform::Embed3D(first_node_data.local_pose_2d.inverse() *
|
||||||
second_node_data.initial_pose);
|
second_node_data.local_pose_2d);
|
||||||
problem.AddResidualBlock(
|
problem.AddResidualBlock(
|
||||||
SpaCostFunction2D::CreateAutoDiffCostFunction(
|
SpaCostFunction2D::CreateAutoDiffCostFunction(
|
||||||
Constraint::Pose{relative_local_slam_pose,
|
Constraint::Pose{relative_local_slam_pose,
|
||||||
|
@ -315,7 +315,8 @@ void OptimizationProblem2D::Solve(
|
||||||
ToPose(C_submap_id_data.data);
|
ToPose(C_submap_id_data.data);
|
||||||
}
|
}
|
||||||
for (const auto& C_node_id_data : C_nodes) {
|
for (const auto& C_node_id_data : C_nodes) {
|
||||||
node_data_.at(C_node_id_data.id).pose = ToPose(C_node_id_data.data);
|
node_data_.at(C_node_id_data.id).global_pose_2d =
|
||||||
|
ToPose(C_node_id_data.data);
|
||||||
}
|
}
|
||||||
for (const auto& C_landmark : C_landmarks) {
|
for (const auto& C_landmark : C_landmarks) {
|
||||||
landmark_data_[C_landmark.first] = C_landmark.second.ToRigid();
|
landmark_data_[C_landmark.first] = C_landmark.second.ToRigid();
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace pose_graph {
|
||||||
|
|
||||||
struct NodeData2D {
|
struct NodeData2D {
|
||||||
common::Time time;
|
common::Time time;
|
||||||
transform::Rigid2d initial_pose;
|
transform::Rigid2d local_pose_2d;
|
||||||
transform::Rigid2d pose;
|
transform::Rigid2d global_pose_2d;
|
||||||
Eigen::Quaterniond gravity_alignment;
|
Eigen::Quaterniond gravity_alignment;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ void PoseGraph2D::ComputeConstraint(const NodeId& node_id,
|
||||||
optimization_problem_->submap_data()
|
optimization_problem_->submap_data()
|
||||||
.at(submap_id)
|
.at(submap_id)
|
||||||
.global_pose.inverse() *
|
.global_pose.inverse() *
|
||||||
optimization_problem_->node_data().at(node_id).pose;
|
optimization_problem_->node_data().at(node_id).global_pose_2d;
|
||||||
constraint_builder_.MaybeAddConstraint(
|
constraint_builder_.MaybeAddConstraint(
|
||||||
submap_id, submap_data_.at(submap_id).submap.get(), node_id,
|
submap_id, submap_data_.at(submap_id).submap.get(), node_id,
|
||||||
trajectory_nodes_.at(node_id).constant_data.get(),
|
trajectory_nodes_.at(node_id).constant_data.get(),
|
||||||
|
@ -240,16 +240,16 @@ void PoseGraph2D::ComputeConstraintsForNode(
|
||||||
node_id.trajectory_id, constant_data->time, insertion_submaps);
|
node_id.trajectory_id, constant_data->time, insertion_submaps);
|
||||||
CHECK_EQ(submap_ids.size(), insertion_submaps.size());
|
CHECK_EQ(submap_ids.size(), insertion_submaps.size());
|
||||||
const SubmapId matching_id = submap_ids.front();
|
const SubmapId matching_id = submap_ids.front();
|
||||||
const transform::Rigid2d pose = transform::Project2D(
|
const transform::Rigid2d local_pose_2d = transform::Project2D(
|
||||||
constant_data->local_pose *
|
constant_data->local_pose *
|
||||||
transform::Rigid3d::Rotation(constant_data->gravity_alignment.inverse()));
|
transform::Rigid3d::Rotation(constant_data->gravity_alignment.inverse()));
|
||||||
const transform::Rigid2d optimized_pose =
|
const transform::Rigid2d global_pose_2d =
|
||||||
optimization_problem_->submap_data().at(matching_id).global_pose *
|
optimization_problem_->submap_data().at(matching_id).global_pose *
|
||||||
pose_graph::ComputeSubmapPose(*insertion_submaps.front()).inverse() *
|
pose_graph::ComputeSubmapPose(*insertion_submaps.front()).inverse() *
|
||||||
pose;
|
local_pose_2d;
|
||||||
optimization_problem_->AddTrajectoryNode(
|
optimization_problem_->AddTrajectoryNode(
|
||||||
matching_id.trajectory_id,
|
matching_id.trajectory_id,
|
||||||
pose_graph::NodeData2D{constant_data->time, pose, optimized_pose,
|
pose_graph::NodeData2D{constant_data->time, local_pose_2d, global_pose_2d,
|
||||||
constant_data->gravity_alignment});
|
constant_data->gravity_alignment});
|
||||||
for (size_t i = 0; i < insertion_submaps.size(); ++i) {
|
for (size_t i = 0; i < insertion_submaps.size(); ++i) {
|
||||||
const SubmapId submap_id = submap_ids[i];
|
const SubmapId submap_id = submap_ids[i];
|
||||||
|
@ -258,7 +258,8 @@ void PoseGraph2D::ComputeConstraintsForNode(
|
||||||
CHECK(submap_data_.at(submap_id).state == SubmapState::kActive);
|
CHECK(submap_data_.at(submap_id).state == SubmapState::kActive);
|
||||||
submap_data_.at(submap_id).node_ids.emplace(node_id);
|
submap_data_.at(submap_id).node_ids.emplace(node_id);
|
||||||
const transform::Rigid2d constraint_transform =
|
const transform::Rigid2d constraint_transform =
|
||||||
pose_graph::ComputeSubmapPose(*insertion_submaps[i]).inverse() * pose;
|
pose_graph::ComputeSubmapPose(*insertion_submaps[i]).inverse() *
|
||||||
|
local_pose_2d;
|
||||||
constraints_.push_back(Constraint{submap_id,
|
constraints_.push_back(Constraint{submap_id,
|
||||||
node_id,
|
node_id,
|
||||||
{transform::Embed3D(constraint_transform),
|
{transform::Embed3D(constraint_transform),
|
||||||
|
@ -567,7 +568,7 @@ void PoseGraph2D::RunOptimization() {
|
||||||
for (const auto& node : node_data.trajectory(trajectory_id)) {
|
for (const auto& node : node_data.trajectory(trajectory_id)) {
|
||||||
auto& mutable_trajectory_node = trajectory_nodes_.at(node.id);
|
auto& mutable_trajectory_node = trajectory_nodes_.at(node.id);
|
||||||
mutable_trajectory_node.global_pose =
|
mutable_trajectory_node.global_pose =
|
||||||
transform::Embed3D(node.data.pose) *
|
transform::Embed3D(node.data.global_pose_2d) *
|
||||||
transform::Rigid3d::Rotation(
|
transform::Rigid3d::Rotation(
|
||||||
mutable_trajectory_node.constant_data->gravity_alignment);
|
mutable_trajectory_node.constant_data->gravity_alignment);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue