Skip to content

Commit fd91e80

Browse files
committed
Initial version
1 parent 52e661c commit fd91e80

14 files changed

+612
-6
lines changed

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.vscode/
2+
.vscode/settings.json
3+
.vscode/c_cpp_properties.json
14
devel/
25
logs/
36
build/
@@ -16,10 +19,6 @@ msg/_*.py
1619
build_isolated/
1720
devel_isolated/
1821

19-
# Generated by dynamic reconfigure
20-
*.cfgc
21-
/cfg/cpp/
22-
/cfg/*.py
2322

2423
# Ignore generated docs
2524
*.dox

CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.0.2)
2+
project(pointcloud_to_grid)
3+
4+
## Compile as C++11, supported in ROS Kinetic and newer
5+
add_compile_options(-std=c++17 -Ofast)
6+
7+
8+
## Find catkin macros and libraries
9+
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
10+
## is used, also find other catkin packages
11+
find_package(PCL REQUIRED)
12+
include_directories(${PCL_INCLUDE_DIRS})
13+
link_directories(${PCL_LIBRARY_DIRS})
14+
add_definitions(${PCL_DEFINITIONS})
15+
16+
find_package(catkin REQUIRED COMPONENTS
17+
dynamic_reconfigure
18+
sensor_msgs
19+
nav_msgs
20+
pcl_ros
21+
roscpp
22+
)
23+
24+
25+
## Generate dynamic reconfigure parameters in the 'cfg' folder
26+
generate_dynamic_reconfigure_options(
27+
cfg/MyParams.cfg
28+
)
29+
30+
catkin_package(
31+
INCLUDE_DIRS include
32+
#LIBRARIES pointcloud_to_grid
33+
#CATKIN_DEPENDS dynamic_reconfigure nav_msgs pcl_ros roscpp
34+
#DEPENDS roscpp std_msgs
35+
)
36+
37+
38+
## Specify additional locations of header files
39+
## Your package locations should be listed before other locations
40+
link_directories(${PCL_LIBRARY_DIRS})
41+
add_definitions(${PCL_DEFINITIONS})
42+
include_directories(
43+
include
44+
${catkin_LIBRARIES}
45+
${catkin_INCLUDE_DIRS}
46+
${PCL_INCLUDE_DIRS}
47+
)
48+
49+
add_executable(pointcloud_to_grid_node src/pointcloud_to_grid_node.cpp)
50+
#add_dependencies(pointcloud_to_map_node ${PROJECT_NAME}_gencfg)
51+
target_link_libraries(pointcloud_to_grid_node ${catkin_LIBRARIES} ${OpenCV_LIBS} ${PCL_LIBRARIES})
52+
53+

README.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,71 @@
1-
# pointcloud_to_grid
2-
This package converts sensor_msgs/PointCloud2 LIDAR data to nav_msgs/OccupancyGrid 2D map data based on intensity and / or height.
1+
# `pointcloud_to_grid` ROS package
2+
This package converts `sensor_msgs/PointCloud2` LIDAR data to `nav_msgs/OccupancyGrid` 2D map data based on intensity and / or height.
3+
![](doc/grid_map01.gif)
4+
5+
## Build
6+
```
7+
cd ~/catkin_ws/src
8+
git clone https://github.com/jkk-research/pointcloud_to_grid
9+
catkin build pointcloud_to_grid
10+
```
11+
Don't foget to `source ~/catkin_ws/devel/setup.bash`. *Note*: [`catkin tools`](https://catkin-tools.readthedocs.io/en/latest/verbs/catkin_build.html) is recommended, but `catkin_make` also works.
12+
13+
14+
## Features
15+
- Few dependencies (ROS and PCL mainly) [ROS installation](http://wiki.ros.org/ROS/Installation)
16+
- Simple as possible
17+
- Fast
18+
19+
## Conventions & definitions
20+
![](doc/grid_map_conventions.svg)
21+
22+
# Getting started
23+
24+
Issue the following commands to start roscore, download and play sample data, and start the algorithm with visualization.
25+
26+
In a **new terminal** start roscore:
27+
28+
```
29+
roscore
30+
```
31+
32+
In a **new terminal** go to your bag folder (e.g. `~/Downloads`):
33+
34+
```
35+
cd ~/Downloads
36+
```
37+
38+
Download a sample rosbag (~3,3 GB):
39+
40+
```r
41+
wget https://laesze-my.sharepoint.com/:u:/g/personal/herno_o365_sze_hu/EYl_ahy5pgBBhNHt5ZkiBikBoy_j_x95E96rDtTsxueB_A?download=1 -O leaf-2021-04-23-campus.bag
42+
```
43+
44+
Play rosbag:
45+
46+
```r
47+
rosbag play -l ~/Downloads/leaf-2021-04-23-campus.bag
48+
```
49+
50+
Start the algorithm in a **new terminal** :
51+
```r
52+
roslaunch pointcloud_to_grid demo.launch
53+
```
54+
55+
Start the visualization in a **new terminal** :
56+
```r
57+
roslaunch pointcloud_to_grid rviz.launch
58+
```
59+
60+
61+
## Related solutions
62+
- [github.com/ANYbotics/grid_map](https://github.com/ANYbotics/grid_map) - This is a C++ library with ROS interface to manage two-dimensional grid maps with multiple data layers.
63+
- [github.com/306327680/PointCloud-to-grid-map](https://github.com/306327680/PointCloud-to-grid-map) - A similar solution but instead PointCloud2 it uses PointCloud
64+
65+
66+
## Cite & paper
67+
68+
If you use any of this code please consider citing TODO:
69+
70+
```bibtex
71+
```

cfg/MyParams.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/env/python
2+
PACKAGE = "my_dyn_rec"
3+
4+
from dynamic_reconfigure.parameter_generator_catkin import *
5+
6+
gen = ParameterGenerator()
7+
8+
#List of parameters
9+
gen.add("position_x", double_t, 0, "center position x", -5.0, -20.0, 22.0) # default min max
10+
gen.add("position_y", double_t, 0, "center position y", 0.0, -20.0, 20.0)
11+
gen.add("cell_size", double_t, 0, "size of a grid cell", 0.5, 0.01, 5.0)
12+
gen.add("length_x", double_t, 0, "In meters", 80.0, 0.1, 200.0)
13+
gen.add("length_y", double_t, 0, "In meters", 80.0, 0.1, 200.0)
14+
gen.add("intensity_factor", double_t, 0, "Multiply intensity", 0.2, 0.001, 10.0)
15+
gen.add("height_factor", double_t, 0, "Multiply height", 1.0, 0.001, 10.0)
16+
gen.add("cloud_in_topic", str_t, 0, "A LIDAR topic to subscribe. Restart needed if it changes.", "/left_os1/os1_cloud_node/points")
17+
gen.add("mapi_topic_name", str_t, 0, "Intensity map topic name. Restart needed if it changes.", "/lidargrid_i")
18+
gen.add("maph_topic_name", str_t, 0, "Height map topic name. Restart needed if it changes.", "/lidargrid_h")
19+
gen.add("debug", bool_t, 0, "publish debug topics too", True)
20+
21+
exit(gen.generate(PACKAGE, "my_dyn_rec", "MyParams"))

doc/default.rviz

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
Panels:
2+
- Class: rviz/Displays
3+
Help Height: 78
4+
Name: Displays
5+
Property Tree Widget:
6+
Expanded:
7+
- /Global Options1
8+
- /PointCloud21/Autocompute Value Bounds1
9+
Splitter Ratio: 0.5
10+
Tree Height: 639
11+
- Class: rviz/Selection
12+
Name: Selection
13+
- Class: rviz/Tool Properties
14+
Expanded:
15+
- /2D Pose Estimate1
16+
- /2D Nav Goal1
17+
- /Publish Point1
18+
Name: Tool Properties
19+
Splitter Ratio: 0.5886790156364441
20+
- Class: rviz/Views
21+
Expanded:
22+
- /Current View1
23+
Name: Views
24+
Splitter Ratio: 0.5
25+
- Class: rviz/Time
26+
Experimental: false
27+
Name: Time
28+
SyncMode: 0
29+
SyncSource: PointCloud2
30+
Preferences:
31+
PromptSaveOnExit: true
32+
Toolbars:
33+
toolButtonStyle: 2
34+
Visualization Manager:
35+
Class: ""
36+
Displays:
37+
- Class: rviz/Axes
38+
Enabled: true
39+
Length: 10
40+
Name: Axes
41+
Radius: 1
42+
Reference Frame: <Fixed Frame>
43+
Value: true
44+
- Alpha: 1
45+
Autocompute Intensity Bounds: false
46+
Autocompute Value Bounds:
47+
Max Value: 15.610125541687012
48+
Min Value: -0.7803434133529663
49+
Value: true
50+
Axis: Z
51+
Channel Name: intensity
52+
Class: rviz/PointCloud2
53+
Color: 255; 255; 255
54+
Color Transformer: Intensity
55+
Decay Time: 0
56+
Enabled: true
57+
Invert Rainbow: true
58+
Max Color: 255; 255; 255
59+
Max Intensity: 2000
60+
Min Color: 0; 0; 0
61+
Min Intensity: 0
62+
Name: PointCloud2
63+
Position Transformer: XYZ
64+
Queue Size: 10
65+
Selectable: false
66+
Size (Pixels): 3
67+
Size (m): 0.2199999988079071
68+
Style: Flat Squares
69+
Topic: /left_os1/os1_cloud_node/points
70+
Unreliable: false
71+
Use Fixed Frame: true
72+
Use rainbow: true
73+
Value: true
74+
- Alpha: 0.699999988079071
75+
Class: rviz/Map
76+
Color Scheme: raw
77+
Draw Behind: false
78+
Enabled: true
79+
Name: Intensity grid
80+
Topic: /lidargrid_i
81+
Unreliable: false
82+
Use Timestamp: false
83+
Value: true
84+
- Alpha: 0.699999988079071
85+
Class: rviz/Map
86+
Color Scheme: map
87+
Draw Behind: true
88+
Enabled: true
89+
Name: Height grid
90+
Topic: /lidargrid_h
91+
Unreliable: false
92+
Use Timestamp: false
93+
Value: true
94+
Enabled: true
95+
Global Options:
96+
Background Color: 255; 255; 255
97+
Default Light: true
98+
Fixed Frame: base_link
99+
Frame Rate: 30
100+
Name: root
101+
Tools:
102+
- Class: rviz/Interact
103+
Hide Inactive Objects: true
104+
- Class: rviz/MoveCamera
105+
- Class: rviz/Select
106+
- Class: rviz/FocusCamera
107+
- Class: rviz/Measure
108+
- Class: rviz/SetInitialPose
109+
Theta std deviation: 0.2617993950843811
110+
Topic: /initialpose
111+
X std deviation: 0.5
112+
Y std deviation: 0.5
113+
- Class: rviz/SetGoal
114+
Topic: /move_base_simple/goal
115+
- Class: rviz/PublishPoint
116+
Single click: true
117+
Topic: /clicked_point
118+
Value: true
119+
Views:
120+
Current:
121+
Angle: -1.5700007677078247
122+
Class: rviz/TopDownOrtho
123+
Enable Stereo Rendering:
124+
Stereo Eye Separation: 0.05999999865889549
125+
Stereo Focal Distance: 1
126+
Swap Stereo Eyes: false
127+
Value: false
128+
Invert Z Axis: false
129+
Name: Current View
130+
Near Clip Distance: 0.009999999776482582
131+
Scale: 8.64981746673584
132+
Target Frame: <Fixed Frame>
133+
Value: TopDownOrtho (rviz)
134+
X: 0
135+
Y: 0
136+
Saved: ~
137+
Window Geometry:
138+
Displays:
139+
collapsed: false
140+
Height: 904
141+
Hide Left Dock: false
142+
Hide Right Dock: false
143+
QMainWindow State: 000000ff00000000fd00000004000000000000015000000300fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000004a00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000002e000003000000009b00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000300fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000002e000003000000008400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000005980000003efc0100000002fb0000000800540069006d0065010000000000000598000001bf00fffffffb0000000800540069006d00650100000000000004500000000000000000000003310000030000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
144+
Selection:
145+
collapsed: false
146+
Time:
147+
collapsed: false
148+
Tool Properties:
149+
collapsed: false
150+
Views:
151+
collapsed: false
152+
Width: 1432
153+
X: 59
154+
Y: 124

doc/grid_map01.gif

3 MB
Loading

doc/grid_map_conventions.pdf

119 KB
Binary file not shown.

doc/grid_map_conventions.png

59.9 KB
Loading

doc/grid_map_conventions.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)