Registration of external points processors in AssetsWriter (#830)
Added RegisterPointsProcessor method to AssetsWriter class. This allows to register new points processors to the pipeline builder. As the new points processors may write files to the disk, the CreateFileWriterFactory method is exposed.master
parent
2ed4eb4f66
commit
1dd49247a4
|
@ -66,10 +66,8 @@ std::unique_ptr<carto::io::PointsProcessorPipelineBuilder>
|
||||||
CreatePipelineBuilder(
|
CreatePipelineBuilder(
|
||||||
const std::vector<carto::mapping::proto::Trajectory>& trajectories,
|
const std::vector<carto::mapping::proto::Trajectory>& trajectories,
|
||||||
const std::string file_prefix) {
|
const std::string file_prefix) {
|
||||||
const auto file_writer_factory = [file_prefix](const std::string& filename) {
|
const auto file_writer_factory =
|
||||||
return carto::common::make_unique<carto::io::StreamFileWriter>(file_prefix +
|
AssetsWriter::CreateFileWriterFactory(file_prefix);
|
||||||
filename);
|
|
||||||
};
|
|
||||||
auto builder =
|
auto builder =
|
||||||
carto::common::make_unique<carto::io::PointsProcessorPipelineBuilder>();
|
carto::common::make_unique<carto::io::PointsProcessorPipelineBuilder>();
|
||||||
carto::io::RegisterBuiltInPointsProcessors(trajectories, file_writer_factory,
|
carto::io::RegisterBuiltInPointsProcessors(trajectories, file_writer_factory,
|
||||||
|
@ -168,6 +166,12 @@ AssetsWriter::AssetsWriter(const std::string& pose_graph_filename,
|
||||||
CreatePipelineBuilder(all_trajectories_, file_prefix);
|
CreatePipelineBuilder(all_trajectories_, file_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetsWriter::RegisterPointsProcessor(
|
||||||
|
const std::string& name,
|
||||||
|
cartographer::io::PointsProcessorPipelineBuilder::FactoryFunction factory) {
|
||||||
|
point_pipeline_builder_->Register(name, factory);
|
||||||
|
}
|
||||||
|
|
||||||
void AssetsWriter::Run(const std::string& configuration_directory,
|
void AssetsWriter::Run(const std::string& configuration_directory,
|
||||||
const std::string& configuration_basename,
|
const std::string& configuration_basename,
|
||||||
const std::string& urdf_filename,
|
const std::string& urdf_filename,
|
||||||
|
@ -263,4 +267,13 @@ void AssetsWriter::Run(const std::string& configuration_directory,
|
||||||
carto::io::PointsProcessor::FlushResult::kRestartStream);
|
carto::io::PointsProcessor::FlushResult::kRestartStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::cartographer::io::FileWriterFactory AssetsWriter::CreateFileWriterFactory(
|
||||||
|
const std::string& file_path) {
|
||||||
|
const auto file_writer_factory = [file_path](const std::string& filename) {
|
||||||
|
return carto::common::make_unique<carto::io::StreamFileWriter>(file_path +
|
||||||
|
filename);
|
||||||
|
};
|
||||||
|
return file_writer_factory;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cartographer_ros
|
} // namespace cartographer_ros
|
||||||
|
|
|
@ -33,12 +33,23 @@ class AssetsWriter {
|
||||||
const std::vector<std::string>& bag_filenames,
|
const std::vector<std::string>& bag_filenames,
|
||||||
const std::string& output_file_prefix);
|
const std::string& output_file_prefix);
|
||||||
|
|
||||||
|
// Registers a new PointsProcessor type uniquly identified by 'name' which
|
||||||
|
// will be created using 'factory'.
|
||||||
|
void RegisterPointsProcessor(
|
||||||
|
const std::string& name,
|
||||||
|
cartographer::io::PointsProcessorPipelineBuilder::FactoryFunction
|
||||||
|
factory);
|
||||||
|
|
||||||
// Configures a points processing pipeline and pushes the points from the
|
// Configures a points processing pipeline and pushes the points from the
|
||||||
// bag through the pipeline.
|
// bag through the pipeline.
|
||||||
void Run(const std::string& configuration_directory,
|
void Run(const std::string& configuration_directory,
|
||||||
const std::string& configuration_basename,
|
const std::string& configuration_basename,
|
||||||
const std::string& urdf_filename, bool use_bag_transforms);
|
const std::string& urdf_filename, bool use_bag_transforms);
|
||||||
|
|
||||||
|
// Creates a FileWriterFactory which creates a FileWriter for storing assets.
|
||||||
|
static ::cartographer::io::FileWriterFactory CreateFileWriterFactory(
|
||||||
|
const std::string& file_path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> bag_filenames_;
|
std::vector<std::string> bag_filenames_;
|
||||||
std::vector<::cartographer::mapping::proto::Trajectory> all_trajectories_;
|
std::vector<::cartographer::mapping::proto::Trajectory> all_trajectories_;
|
||||||
|
|
Loading…
Reference in New Issue