Skip to content

Commit

Permalink
fix(map_loader): apply clang-tidy (autowarefoundation#2668)
Browse files Browse the repository at this point in the history
* fix(map_loader): apply clang-tidy

Signed-off-by: kminoda <koji.minoda@tier4.jp>

* ci(pre-commit): autofix

Signed-off-by: kminoda <koji.minoda@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and maxime-clem committed Jan 30, 2023
1 parent a070986 commit 634a5e9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DifferentialMapLoaderModule::DifferentialMapLoaderModule(
}

void DifferentialMapLoaderModule::differentialAreaLoad(
const autoware_map_msgs::msg::AreaInfo area, const std::vector<std::string> & cached_ids,
const autoware_map_msgs::msg::AreaInfo & area, const std::vector<std::string> & cached_ids,
GetDifferentialPointCloudMap::Response::SharedPtr & response) const
{
// iterate over all the available pcd map grids
Expand All @@ -52,7 +52,7 @@ void DifferentialMapLoaderModule::differentialAreaLoad(
}
}

for (int i = 0; i < static_cast<int>(cached_ids.size()); ++i) {
for (size_t i = 0; i < cached_ids.size(); ++i) {
if (should_remove[i]) {
response->ids_to_remove.push_back(cached_ids[i]);
}
Expand All @@ -72,7 +72,7 @@ bool DifferentialMapLoaderModule::onServiceGetDifferentialPointCloudMap(

autoware_map_msgs::msg::PointCloudMapCellWithID
DifferentialMapLoaderModule::loadPointCloudMapCellWithID(
const std::string path, const std::string map_id) const
const std::string & path, const std::string & map_id) const
{
sensor_msgs::msg::PointCloud2 pcd;
if (pcl::io::loadPCDFile(path, pcd) == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class DifferentialMapLoaderModule
GetDifferentialPointCloudMap::Request::SharedPtr req,
GetDifferentialPointCloudMap::Response::SharedPtr res);
void differentialAreaLoad(
const autoware_map_msgs::msg::AreaInfo area_info, const std::vector<std::string> & cached_ids,
const autoware_map_msgs::msg::AreaInfo & area_info, const std::vector<std::string> & cached_ids,
GetDifferentialPointCloudMap::Response::SharedPtr & response) const;
autoware_map_msgs::msg::PointCloudMapCellWithID loadPointCloudMapCellWithID(
const std::string path, const std::string map_id) const;
const std::string & path, const std::string & map_id) const;
};

#endif // POINTCLOUD_MAP_LOADER__DIFFERENTIAL_MAP_LOADER_MODULE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PartialMapLoaderModule::PartialMapLoaderModule(
}

void PartialMapLoaderModule::partialAreaLoad(
const autoware_map_msgs::msg::AreaInfo area,
const autoware_map_msgs::msg::AreaInfo & area,
GetPartialPointCloudMap::Response::SharedPtr & response) const
{
// iterate over all the available pcd map grids
Expand Down Expand Up @@ -56,7 +56,7 @@ bool PartialMapLoaderModule::onServiceGetPartialPointCloudMap(
}

autoware_map_msgs::msg::PointCloudMapCellWithID PartialMapLoaderModule::loadPointCloudMapCellWithID(
const std::string path, const std::string map_id) const
const std::string & path, const std::string & map_id) const
{
sensor_msgs::msg::PointCloud2 pcd;
if (pcl::io::loadPCDFile(path, pcd) == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class PartialMapLoaderModule
GetPartialPointCloudMap::Request::SharedPtr req,
GetPartialPointCloudMap::Response::SharedPtr res);
void partialAreaLoad(
const autoware_map_msgs::msg::AreaInfo area,
const autoware_map_msgs::msg::AreaInfo & area,
GetPartialPointCloudMap::Response::SharedPtr & response) const;
autoware_map_msgs::msg::PointCloudMapCellWithID loadPointCloudMapCellWithID(
const std::string path, const std::string map_id) const;
const std::string & path, const std::string & map_id) const;
};

#endif // POINTCLOUD_MAP_LOADER__PARTIAL_MAP_LOADER_MODULE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ sensor_msgs::msg::PointCloud2 downsample(
}

PointcloudMapLoaderModule::PointcloudMapLoaderModule(
rclcpp::Node * node, const std::vector<std::string> & pcd_paths, const std::string publisher_name,
const bool use_downsample)
rclcpp::Node * node, const std::vector<std::string> & pcd_paths,
const std::string & publisher_name, const bool use_downsample)
: logger_(node->get_logger())
{
rclcpp::QoS durable_qos{1};
Expand Down Expand Up @@ -72,12 +72,11 @@ sensor_msgs::msg::PointCloud2 PointcloudMapLoaderModule::loadPCDFiles(
sensor_msgs::msg::PointCloud2 whole_pcd;
sensor_msgs::msg::PointCloud2 partial_pcd;

for (int i = 0; i < static_cast<int>(pcd_paths.size()); ++i) {
for (size_t i = 0; i < pcd_paths.size(); ++i) {
auto & path = pcd_paths[i];
if (i % 50 == 0) {
RCLCPP_INFO_STREAM(
logger_,
fmt::format("Load {} ({} out of {})", path, i + 1, static_cast<int>(pcd_paths.size())));
logger_, fmt::format("Load {} ({} out of {})", path, i + 1, pcd_paths.size()));
}

if (pcl::io::loadPCDFile(path, partial_pcd) == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PointcloudMapLoaderModule
public:
explicit PointcloudMapLoaderModule(
rclcpp::Node * node, const std::vector<std::string> & pcd_paths,
const std::string publisher_name, const bool use_downsample);
const std::string & publisher_name, const bool use_downsample);

private:
rclcpp::Logger logger_;
Expand Down

0 comments on commit 634a5e9

Please sign in to comment.