26 #include "cartographer/mapping/proto/trajectory.pb.h" 27 #include "cartographer/mapping_2d/proto/range_data_inserter_options.pb.h" 30 #include "nav_msgs/OccupancyGrid.h" 36 const std::vector<::cartographer::mapping::TrajectoryNode>&
38 const string& map_frame,
39 const ::cartographer::mapping_2d::proto::SubmapsOptions& submaps_options,
40 const std::string& stem) {
41 ::nav_msgs::OccupancyGrid occupancy_grid;
49 void Write3DAssets(
const std::vector<::cartographer::mapping::TrajectoryNode>&
51 const double voxel_size,
const std::string& stem) {
52 namespace carto = ::cartographer;
53 const auto file_writer_factory = [](
const string&
filename) {
54 return carto::common::make_unique<carto::io::StreamFileWriter>(
filename);
57 carto::io::NullPointsProcessor null_points_processor;
58 carto::io::XRayPointsProcessor xy_xray_points_processor(
60 carto::transform::Rigid3f::Rotation(
61 Eigen::AngleAxisf(-M_PI / 2.
f, Eigen::Vector3f::UnitY())),
62 {}, stem +
"_xray_xy", file_writer_factory, &null_points_processor);
63 carto::io::XRayPointsProcessor yz_xray_points_processor(
65 carto::transform::Rigid3f::Rotation(
66 Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitZ())),
67 {}, stem +
"_xray_yz", file_writer_factory, &xy_xray_points_processor);
68 carto::io::XRayPointsProcessor xz_xray_points_processor(
70 carto::transform::Rigid3f::Rotation(
71 Eigen::AngleAxisf(-M_PI / 2.
f, Eigen::Vector3f::UnitZ())),
72 {}, stem +
"_xray_xz", file_writer_factory, &yz_xray_points_processor);
73 carto::io::PlyWritingPointsProcessor ply_writing_points_processor(
74 file_writer_factory(stem +
".ply"), &xz_xray_points_processor);
76 for (
const auto& node : trajectory_nodes) {
77 const carto::sensor::RangeData range_data =
78 carto::sensor::TransformRangeData(
79 carto::sensor::Decompress(node.constant_data->range_data_3d),
80 node.pose.cast<
float>());
82 auto points_batch = carto::common::make_unique<carto::io::PointsBatch>();
83 points_batch->origin = range_data.origin;
84 points_batch->points = range_data.returns;
85 ply_writing_points_processor.Process(std::move(points_batch));
87 ply_writing_points_processor.Flush();
void Write3DAssets(const std::vector<::cartographer::mapping::TrajectoryNode > &trajectory_nodes, const double voxel_size, const std::string &stem)
void Write2DAssets(const std::vector<::cartographer::mapping::TrajectoryNode > &trajectory_nodes, const string &map_frame, const ::cartographer::mapping_2d::proto::SubmapsOptions &submaps_options, const std::string &stem)
void BuildOccupancyGrid2D(const std::vector<::cartographer::mapping::TrajectoryNode > &trajectory_nodes, const string &map_frame, const ::cartographer::mapping_2d::proto::SubmapsOptions &submaps_options,::nav_msgs::OccupancyGrid *const occupancy_grid)
void WriteOccupancyGridToPgmAndYaml(const ::nav_msgs::OccupancyGrid &occupancy_grid, const std::string &stem)