Fix pbstream exporting binaries (#945)

googlecartographer/cartographer#1286 modified Submap::ToProto such that grids for unfinished submaps are no longer serialized. This commit fixes the breakage this introduced in the pbstream exporting binaries.
master
Christoph Schütte 2018-07-19 19:51:47 +02:00 committed by Wally B. Feed
parent 2df3b83c80
commit 4b39ee68c7
4 changed files with 17 additions and 2 deletions

View File

@ -60,7 +60,8 @@ std::unique_ptr<nav_msgs::OccupancyGrid> LoadOccupancyGridMsg(
::cartographer::mapping::proto::SerializedData proto;
::cartographer::mapping::ValueConversionTables conversion_lookup_tables;
while (deserializer.ReadNextSerializedData(&proto)) {
if (proto.has_submap()) {
if (proto.has_submap() &&
(Has2DGrid(proto.submap()) || Has3DGrids(proto.submap()))) {
const auto& submap = proto.submap();
const ::cartographer::mapping::SubmapId id{
submap.submap_id().trajectory_id(),

View File

@ -53,7 +53,8 @@ void Run(const std::string& pbstream_filename, const std::string& map_filestem,
::cartographer::mapping::proto::SerializedData proto;
::cartographer::mapping::ValueConversionTables conversion_lookup_tables;
while (deserializer.ReadNextSerializedData(&proto)) {
if (proto.has_submap()) {
if (proto.has_submap() &&
(Has2DGrid(proto.submap()) || Has3DGrids(proto.submap()))) {
const auto& submap = proto.submap();
const ::cartographer::mapping::SubmapId id{
submap.submap_id().trajectory_id(),

View File

@ -53,4 +53,14 @@ std::unique_ptr<::cartographer::io::SubmapTextures> FetchSubmapTextures(
return response;
}
bool Has2DGrid(const ::cartographer::mapping::proto::Submap& submap) {
return submap.has_submap_2d() && submap.submap_2d().has_grid();
}
bool Has3DGrids(const ::cartographer::mapping::proto::Submap& submap) {
return submap.has_submap_3d() &&
submap.submap_3d().has_low_resolution_hybrid_grid() &&
submap.submap_3d().has_high_resolution_hybrid_grid();
}
} // namespace cartographer_ros

View File

@ -35,6 +35,9 @@ std::unique_ptr<::cartographer::io::SubmapTextures> FetchSubmapTextures(
const ::cartographer::mapping::SubmapId& submap_id,
ros::ServiceClient* client);
bool Has2DGrid(const ::cartographer::mapping::proto::Submap& submap);
bool Has3DGrids(const ::cartographer::mapping::proto::Submap& submap);
} // namespace cartographer_ros
#endif // CARTOGRAPHER_ROS_CARTOGRAPHER_ROS_SUBMAP_H