-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(map_loader): add partial map loading interface in pointcloud_map…
…_loader (#1938) * first commit Signed-off-by: kminoda <koji.minoda@tier4.jp> * reverted unnecessary modification Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * renamed some classes Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * move autoware_map_msgs to autoware_msgs repos Signed-off-by: kminoda <koji.m.minoda@gmail.com> * catch up with the modification in autoware_map_msgs Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * aligned with autoware_map_msgs change (differential/partial modules seperation) Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * debugged * debugged Signed-off-by: kminoda <koji.minoda@tier4.jp> * added min-max info and others Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * minor fix Signed-off-by: kminoda <koji.minoda@tier4.jp> * already_loaded -> cached Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * load_ -> get_ Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * resolve pre-commit Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * minor fix Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * update readme Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * update readme Signed-off-by: kminoda <koji.minoda@tier4.jp> * minor fix in readme Signed-off-by: kminoda <koji.minoda@tier4.jp> * grammarly Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * ci(pre-commit): autofix * fix copyright Signed-off-by: kminoda <koji.minoda@tier4.jp> * fix launch file Signed-off-by: kminoda <koji.minoda@tier4.jp> * remove leaf_size param Signed-off-by: kminoda <koji.minoda@tier4.jp> * removed unnecessary things Signed-off-by: kminoda <koji.minoda@tier4.jp> * removed downsample for now Signed-off-by: kminoda <koji.minoda@tier4.jp> * removed differential_map_loader for this PR (would make another PR for this) Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * removed differential_map_loader, debugged Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * removed leaf_size description Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * refactor sphereAndBoxOverlapExists Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * added test for sphereAndBoxOverlapExists Signed-off-by: kminoda <koji.minoda@tier4.jp> * ci(pre-commit): autofix * remove downsample function for now Signed-off-by: kminoda <koji.minoda@tier4.jp> * remove fmt from target_link_libraries in test Signed-off-by: kminoda <koji.minoda@tier4.jp> * minor fix in cmakelists.txt Signed-off-by: kminoda <koji.minoda@tier4.jp> Signed-off-by: kminoda <koji.minoda@tier4.jp> Signed-off-by: kminoda <koji.m.minoda@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
99f7920
commit 8bbc505
Showing
17 changed files
with
491 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ autoware_package() | |
ament_auto_package( | ||
INSTALL_TO_SHARE | ||
launch | ||
config | ||
) |
4 changes: 4 additions & 0 deletions
4
launch/tier4_map_launch/config/pointcloud_map_loader.param.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/**: | ||
ros__parameters: | ||
enable_whole_load: true | ||
enable_partial_load: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/**: | ||
ros__parameters: | ||
enable_whole_load: true | ||
enable_partial_load: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<launch> | ||
<arg name="pointcloud_map_path"/> | ||
<arg name="pointcloud_map_loader_param_path" default="$(find-pkg-share map_loader)/config/pointcloud_map_loader.param.yaml"/> | ||
|
||
<node pkg="map_loader" exec="pointcloud_map_loader" name="pointcloud_map_loader" output="screen"> | ||
<remap from="output/pointcloud_map" to="/map/pointcloud_map"/> | ||
<remap from="service/get_partial_pcd_map" to="/map/get_partial_pointcloud_map"/> | ||
<param name="pcd_paths_or_directory" value="[$(var pointcloud_map_path)]"/> | ||
<param from="$(var pointcloud_map_loader_param_path)"/> | ||
</node> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
map/map_loader/src/pointcloud_map_loader/partial_map_loader_module.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "partial_map_loader_module.hpp" | ||
|
||
PartialMapLoaderModule::PartialMapLoaderModule( | ||
rclcpp::Node * node, const std::map<std::string, PCDFileMetadata> & pcd_file_metadata_dict) | ||
: logger_(node->get_logger()), all_pcd_file_metadata_dict_(pcd_file_metadata_dict) | ||
{ | ||
get_partial_pcd_maps_service_ = node->create_service<GetPartialPointCloudMap>( | ||
"service/get_partial_pcd_map", std::bind( | ||
&PartialMapLoaderModule::onServiceGetPartialPointCloudMap, | ||
this, std::placeholders::_1, std::placeholders::_2)); | ||
} | ||
|
||
void PartialMapLoaderModule::partialAreaLoad( | ||
const autoware_map_msgs::msg::AreaInfo area, | ||
GetPartialPointCloudMap::Response::SharedPtr & response) const | ||
{ | ||
// iterate over all the available pcd map grids | ||
|
||
for (const auto & ele : all_pcd_file_metadata_dict_) { | ||
std::string path = ele.first; | ||
PCDFileMetadata metadata = ele.second; | ||
|
||
// assume that the map ID = map path (for now) | ||
std::string map_id = path; | ||
|
||
// skip if the pcd file is not within the queried area | ||
if (!isGridWithinQueriedArea(area, metadata)) continue; | ||
|
||
autoware_map_msgs::msg::PointCloudMapCellWithID pointcloud_map_cell_with_id = | ||
loadPointCloudMapCellWithID(path, map_id); | ||
response->new_pointcloud_with_ids.push_back(pointcloud_map_cell_with_id); | ||
} | ||
} | ||
|
||
bool PartialMapLoaderModule::onServiceGetPartialPointCloudMap( | ||
GetPartialPointCloudMap::Request::SharedPtr req, GetPartialPointCloudMap::Response::SharedPtr res) | ||
{ | ||
auto area = req->area; | ||
partialAreaLoad(area, res); | ||
res->header.frame_id = "map"; | ||
return true; | ||
} | ||
|
||
autoware_map_msgs::msg::PointCloudMapCellWithID PartialMapLoaderModule::loadPointCloudMapCellWithID( | ||
const std::string path, const std::string map_id) const | ||
{ | ||
sensor_msgs::msg::PointCloud2 pcd; | ||
if (pcl::io::loadPCDFile(path, pcd) == -1) { | ||
RCLCPP_ERROR_STREAM(logger_, "PCD load failed: " << path); | ||
} | ||
autoware_map_msgs::msg::PointCloudMapCellWithID pointcloud_map_cell_with_id; | ||
pointcloud_map_cell_with_id.pointcloud = pcd; | ||
pointcloud_map_cell_with_id.cell_id = map_id; | ||
return pointcloud_map_cell_with_id; | ||
} |
59 changes: 59 additions & 0 deletions
59
map/map_loader/src/pointcloud_map_loader/partial_map_loader_module.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef POINTCLOUD_MAP_LOADER__PARTIAL_MAP_LOADER_MODULE_HPP_ | ||
#define POINTCLOUD_MAP_LOADER__PARTIAL_MAP_LOADER_MODULE_HPP_ | ||
|
||
#include "utils.hpp" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include "autoware_map_msgs/srv/get_partial_point_cloud_map.hpp" | ||
|
||
#include <pcl/common/common.h> | ||
#include <pcl/filters/voxel_grid.h> | ||
#include <pcl/io/pcd_io.h> | ||
#include <pcl/point_cloud.h> | ||
#include <pcl/point_types.h> | ||
#include <pcl_conversions/pcl_conversions.h> | ||
|
||
#include <map> | ||
#include <string> | ||
#include <vector> | ||
|
||
class PartialMapLoaderModule | ||
{ | ||
using GetPartialPointCloudMap = autoware_map_msgs::srv::GetPartialPointCloudMap; | ||
|
||
public: | ||
explicit PartialMapLoaderModule( | ||
rclcpp::Node * node, const std::map<std::string, PCDFileMetadata> & pcd_file_metadata_dict); | ||
|
||
private: | ||
rclcpp::Logger logger_; | ||
|
||
std::map<std::string, PCDFileMetadata> all_pcd_file_metadata_dict_; | ||
rclcpp::Service<GetPartialPointCloudMap>::SharedPtr get_partial_pcd_maps_service_; | ||
|
||
bool onServiceGetPartialPointCloudMap( | ||
GetPartialPointCloudMap::Request::SharedPtr req, | ||
GetPartialPointCloudMap::Response::SharedPtr res); | ||
void partialAreaLoad( | ||
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; | ||
}; | ||
|
||
#endif // POINTCLOUD_MAP_LOADER__PARTIAL_MAP_LOADER_MODULE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.