Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(map): add pointcloud divider and pointcloud merger #100

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
395b108
Added point cloud merger
anhnv3991 Jul 24, 2024
f9512a7
Update README and remove unused svg file
anhnv3991 Jul 24, 2024
1625802
style(pre-commit): autofix
pre-commit-ci[bot] Jul 24, 2024
521a063
Fix pre-commit
anhnv3991 Jul 24, 2024
5cb8e10
style(pre-commit): autofix
pre-commit-ci[bot] Jul 24, 2024
9911118
Fix spell check
anhnv3991 Jul 24, 2024
5e4674f
style(pre-commit): autofix
pre-commit-ci[bot] Jul 24, 2024
ac08ba0
Fix pre-commit ci
anhnv3991 Jul 24, 2024
068e456
Fix pre-commit ci
anhnv3991 Jul 24, 2024
63afecb
Fix pre-commit ci
anhnv3991 Jul 24, 2024
e838ffa
Add autoware_ prefix to nodes
anhnv3991 Aug 2, 2024
6fe65b6
style(pre-commit): autofix
pre-commit-ci[bot] Aug 2, 2024
a41188f
Merge branch 'main' into feature/add_pointcloud_merger
anhnv3991 Aug 2, 2024
283ee21
Add autoware_ prefix to pointcloud merger and divider; refactor code;…
anhnv3991 Aug 5, 2024
94ca610
Follow autoware directory structure
anhnv3991 Aug 15, 2024
ad4e036
Move parameters to yaml files, create schema json files, and apply cl…
anhnv3991 Aug 15, 2024
d214daa
Merge branch 'autowarefoundation:main' into refactor/pointcloud_divid…
anhnv3991 Aug 15, 2024
f0e4986
Fix an error while reading PCD file
anhnv3991 Aug 16, 2024
57def1f
Merge branch 'autowarefoundation:main' into refactor/pointcloud_divid…
anhnv3991 Aug 16, 2024
021555b
style(pre-commit): autofix
pre-commit-ci[bot] Aug 16, 2024
2d88828
Fix pre-commit ci
anhnv3991 Aug 16, 2024
6946dca
Fix pre-commit-optional
anhnv3991 Aug 16, 2024
a7eab69
style(pre-commit): autofix
pre-commit-ci[bot] Aug 16, 2024
39f2b34
Fix merger's schema file
anhnv3991 Aug 16, 2024
2649643
style(pre-commit): autofix
pre-commit-ci[bot] Aug 16, 2024
fed2b39
Merge branch 'main' into refactor/pointcloud_divider_merger
YamatoAndo Aug 28, 2024
6ef8d89
Fixed review comments
anhnv3991 Sep 3, 2024
7412487
style(pre-commit): autofix
pre-commit-ci[bot] Sep 3, 2024
07e473b
Merge branch 'main' into refactor/pointcloud_divider_merger
anhnv3991 Sep 3, 2024
5e2acc4
Fixed spell check
anhnv3991 Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions map/autoware_pointcloud_divider/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_pointcloud_divider)

find_package(autoware_cmake REQUIRED)
autoware_package()
ament_auto_find_build_dependencies()

# Enable support for C++17
if (${CMAKE_VERSION} VERSION_LESS "3.1.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
else ()
set(CMAKE_CXX_STANDARD 17)
endif ()

# Find packages
find_package(yaml-cpp REQUIRED)
find_package(PCL REQUIRED COMPONENTS common io filters)

include_directories(include)

# Add divider library
ament_auto_add_library(${PROJECT_NAME} SHARED src/pointcloud_divider_node.cpp src/voxel_grid_filter.cpp src/pcd_divider.cpp)
target_link_libraries(${PROJECT_NAME} yaml-cpp ${PCL_LIBRARIES})
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "autoware::pointcloud_divider::PointCloudDivider"
EXECUTABLE ${PROJECT_NAME}_node
)

install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)

ament_auto_package(INSTALL_TO_SHARE launch config)
28 changes: 28 additions & 0 deletions map/autoware_pointcloud_divider/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2023, MAP IV

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 changes: 102 additions & 0 deletions map/autoware_pointcloud_divider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# autoware_pointcloud_divider

(Updated 2024/08/16)
anhnv3991 marked this conversation as resolved.
Show resolved Hide resolved

This is a tool for processing pcd files, and it can perform the following functions:

- Dividing point clouds
- Downsampling point clouds
- Generating metadata to efficiently handle the divided point clouds

## Supported Data Format

**Currently, only `pcl::PointXYZ` and `pcl::PointXYZ` are supported. Any PCD will be loaded as those two types.**
anhnv3991 marked this conversation as resolved.
Show resolved Hide resolved

This tool can be used with files that have data fields other than `XYZI` (e.g., `XYZRGB`) and files that only contain `XYZ`.

- Data fields other than `XYZI` are ignored during loading.
- When loading `XYZ`-only data, the `intensity` field is assigned 0.

## Installation

```bash
cd <PATH_TO_pilot-auto.*> # OR <PATH_TO_autoware>
cd src/
git clone [email protected]:autowarefoundation/autoware_tools.git
cd ..
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --catkin-skip-building-tests --symlink-install --packages-up-to pointcloud_divider
anhnv3991 marked this conversation as resolved.
Show resolved Hide resolved
```

## Usage

- Select directory, process all files found with `find $INPUT_DIR -name "*.pcd"`.

```bash
ros2 launch autoware_pointcloud_divider pointcloud_divider.launch.xml input_pcd_or_dir:=<INPUT_DIR> output_pcd_dir:=<OUTPUT_DIR> prefix:=<PREFIX>
```

| Name | Description |
| ---------- | ------------------------------------- |
| INPUT_DIR | Directory that contains all PCD files |
| OUTPUT_DIR | Output directory name |
| PREFIX | Prefix of output PCD file name |

`INPUT_DIR` and `OUTPUT_DIR` should be specified as **absolute paths**.

NOTE: The folder `OUTPUT_DIR` is auto generated. If it already exists, all files within that folder will be deleted before the tool runs. Hence, users should backup the important files in that folder if necessary.

### Parameters

{{ json_to_markdown("map/autoware_pointcloud_divider/schema/pointcloud_divider.schema.json") }}

How the point cloud is processed.

![node_diagram](docs/how_to_be_downsampled.drawio.svg)

How the PCD file is named

![node_diagram](docs/output_file_name_pattern.drawio.svg)

### Parameter example

1. Dividing point clouds without downsampling

```yaml
use_large_grid: false
leaf_size: -1.0 # any negative number
grid_size_x: 20
grid_size_y: 20
```

2. Dividing and downsampling point clouds

```yaml
use_large_grid: false
leaf_size: 0.2
grid_size_x: 20
grid_size_y: 20
```

## Metadata YAML Format

The metadata file should be named `metadata.yaml`. It contains the following fields:

- `x_resolution`: The resolution along the X-axis.
- `y_resolution`: The resolution along the Y-axis.

Additionally, the file contains entries for individual point cloud files (`.pcd` files) and their corresponding grid coordinates. The key is the file name, and the value is a list containing the X and Y coordinates of the lower-left corner of the grid cell associated with that file. The grid cell's boundaries can be calculated using the `x_resolution` and `y_resolution` values.

For example:

```yaml
x_resolution: 100.0
y_resolution: 150.0
A.pcd: [1200, 2500] # -> 1200 <= x <= 1300, 2500 <= y <= 2650
B.pcd: [1300, 2500] # -> 1300 <= x <= 1400, 2500 <= y <= 2650
C.pcd: [1200, 2650] # -> 1200 <= x <= 1300, 2650 <= y <= 2800
D.pcd: [1400, 2650] # -> 1400 <= x <= 1500, 2650 <= y <= 2800
```

## LICENSE

Parts of files grid_info.hpp, pcd_divider.hpp, and pcd_divider.cpp are copied from [MapIV's pointcloud_divider](https://github.com/MapIV/pointcloud_divider) and are under [BSD-3-Clauses](LICENSE) license. The remaining code are under [Apache License 2.0](../../LICENSE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**:
ros__parameters:
use_large_grid: false
leaf_size: 0.2
grid_size_x: 20.0
grid_size_y: 20.0
input_pcd_or_dir: $(var input_pcd_or_dir) # Path to the folder containing the input PCD files
output_pcd_dir: $(var output_pcd_dir) # Path to the folder containing the segmented PCD files
prefix: $(var prefix) # Prefix for the name of the output PCD files
point_type: "point_xyzi"
Loading
Loading