diff --git a/cartographer/mapping/map_builder.cc b/cartographer/mapping/map_builder.cc index 9644060..8b46045 100644 --- a/cartographer/mapping/map_builder.cc +++ b/cartographer/mapping/map_builder.cc @@ -88,6 +88,11 @@ int MapBuilder::AddTrajectoryBuilder( trajectory_options.trajectory_builder_2d_options(), trajectory_id, sparse_pose_graph_2d_.get()))); } + if (trajectory_options.pure_localization()) { + constexpr int kSubmapsToKeep = 3; + sparse_pose_graph_->AddTrimmer(common::make_unique( + trajectory_id, kSubmapsToKeep)); + } return trajectory_id; } diff --git a/cartographer/mapping/proto/trajectory_builder_options.proto b/cartographer/mapping/proto/trajectory_builder_options.proto index 98d50f5..5366a6f 100644 --- a/cartographer/mapping/proto/trajectory_builder_options.proto +++ b/cartographer/mapping/proto/trajectory_builder_options.proto @@ -24,4 +24,5 @@ message TrajectoryBuilderOptions { trajectory_builder_2d_options = 1; optional mapping_3d.proto.LocalTrajectoryBuilderOptions trajectory_builder_3d_options = 2; + optional bool pure_localization = 3; } diff --git a/cartographer/mapping/trajectory_builder.cc b/cartographer/mapping/trajectory_builder.cc index 0eee6ed..a223804 100644 --- a/cartographer/mapping/trajectory_builder.cc +++ b/cartographer/mapping/trajectory_builder.cc @@ -31,6 +31,8 @@ proto::TrajectoryBuilderOptions CreateTrajectoryBuilderOptions( *options.mutable_trajectory_builder_3d_options() = mapping_3d::CreateLocalTrajectoryBuilderOptions( parameter_dictionary->GetDictionary("trajectory_builder_3d").get()); + options.set_pure_localization( + parameter_dictionary->GetBool("pure_localization")); return options; } diff --git a/configuration_files/trajectory_builder.lua b/configuration_files/trajectory_builder.lua index 75d91ad..52338a0 100644 --- a/configuration_files/trajectory_builder.lua +++ b/configuration_files/trajectory_builder.lua @@ -18,4 +18,5 @@ include "trajectory_builder_3d.lua" TRAJECTORY_BUILDER = { trajectory_builder_2d = TRAJECTORY_BUILDER_2D, trajectory_builder_3d = TRAJECTORY_BUILDER_3D, + pure_localization = false, }