Make old pbstreams compatible with the new pure_localization_trimmer options. (#1230)

master
Alexander Belyaev 2018-07-03 14:27:38 +02:00 committed by Wally B. Feed
parent ffb5034390
commit ddce76d9fb
2 changed files with 23 additions and 6 deletions

View File

@ -37,7 +37,6 @@
namespace cartographer { namespace cartographer {
namespace mapping { namespace mapping {
namespace { namespace {
using mapping::proto::SerializedData; using mapping::proto::SerializedData;
@ -53,6 +52,25 @@ std::vector<std::string> SelectRangeSensorIds(
return range_sensor_ids; return range_sensor_ids;
} }
void MaybeAddPureLocalizationTrimmer(
const int trajectory_id,
const proto::TrajectoryBuilderOptions& trajectory_options,
PoseGraph* pose_graph) {
if (trajectory_options.pure_localization()) {
LOG(WARNING)
<< "'TrajectoryBuilderOptions::pure_localization' field is deprecated. "
"Use 'TrajectoryBuilderOptions::pure_localization_trimmer' instead.";
pose_graph->AddTrimmer(common::make_unique<PureLocalizationTrimmer>(
trajectory_id, 3 /* max_submaps_to_keep */));
return;
}
if (trajectory_options.has_pure_localization_trimmer()) {
pose_graph->AddTrimmer(common::make_unique<PureLocalizationTrimmer>(
trajectory_id,
trajectory_options.pure_localization_trimmer().max_submaps_to_keep()));
}
}
} // namespace } // namespace
proto::MapBuilderOptions CreateMapBuilderOptions( proto::MapBuilderOptions CreateMapBuilderOptions(
@ -147,11 +165,9 @@ int MapBuilder::AddTrajectoryBuilder(
trimmer_options.min_added_submaps_count())); trimmer_options.min_added_submaps_count()));
} }
} }
if (trajectory_options.has_pure_localization_trimmer()) { MaybeAddPureLocalizationTrimmer(trajectory_id, trajectory_options,
pose_graph_->AddTrimmer(common::make_unique<PureLocalizationTrimmer>( pose_graph_.get());
trajectory_id,
trajectory_options.pure_localization_trimmer().max_submaps_to_keep()));
}
if (trajectory_options.has_initial_trajectory_pose()) { if (trajectory_options.has_initial_trajectory_pose()) {
const auto& initial_trajectory_pose = const auto& initial_trajectory_pose =
trajectory_options.initial_trajectory_pose(); trajectory_options.initial_trajectory_pose();

View File

@ -38,6 +38,7 @@ message TrajectoryBuilderOptions {
} }
OverlappingSubmapsTrimmerOptions2D overlapping_submaps_trimmer_2d = 5; OverlappingSubmapsTrimmerOptions2D overlapping_submaps_trimmer_2d = 5;
bool pure_localization = 3 [deprecated = true];
message PureLocalizationTrimmerOptions { message PureLocalizationTrimmerOptions {
int32 max_submaps_to_keep = 1; int32 max_submaps_to_keep = 1;
} }