Skip to content

Commit

Permalink
Add error for invalid height_type
Browse files Browse the repository at this point in the history
  • Loading branch information
kosuke55 committed Dec 1, 2021
1 parent 9daa4f6 commit 5e41cda
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions grid_map_pcl/src/GridMapPclLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ float GridMapPclLoader::calculateElevationFromPointsInsideGridMapCell(
std::max_element(clusterSizes.begin(), clusterSizes.end());
const size_t maxIndex = std::distance(clusterSizes.begin(), maxIt);
height = heights[maxIndex];
} else {
return std::nan("1");
}

return height;
}

Expand All @@ -185,6 +188,17 @@ GridMapPclLoader::Pointcloud::Ptr GridMapPclLoader::getPointcloudInsideGridMapCe

void GridMapPclLoader::loadParameters(const std::string& filename) {
params_.loadParameters(filename);

const int height_type = params_.get().gridMap_.height_type_;
if ((std::set<int>{0, 1, 2}).count(height_type) == 0) {
ROS_ERROR_STREAM(
"Invalid height type: " + std::to_string(height_type) +
"\nValid types are below" +
"\n0: Smallest value among the average values of each cluster" +
"\n1: Largest value among the average values of each cluster" +
"\n2: Mean value of the cluster with the most points");
}

pointcloudProcessor_.loadParameters(filename);
}

Expand Down

0 comments on commit 5e41cda

Please sign in to comment.