Skip to content

Commit a9bf70d

Browse files
committed
[update]update README.md
1 parent c3bc5c2 commit a9bf70d

File tree

2 files changed

+107
-11
lines changed

2 files changed

+107
-11
lines changed

README.md

Lines changed: 106 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,40 @@ $ sudo chmod 777 /dev/ttyUSB0
3535
from launch import LaunchDescription
3636
from launch_ros.actions import Node
3737

38+
'''
39+
parameters=[
40+
{'product_name': 'LDLiDAR_LD06'},
41+
{'topic_name': 'LiDAR/LD06'},
42+
{'port_name': '/dev/ttyUSB0'},
43+
{'frame_id': 'lidar_frame'},
44+
{'laser_scan_dir': True},
45+
{'enable_angle_crop_func': False},
46+
{'angle_crop_min': 135.0},
47+
{'angle_crop_max': 225.0}
48+
]
49+
---
50+
Parameter Description:
51+
---
52+
- Set laser scan directon:
53+
1. Set counterclockwise, example: {'laser_scan_dir': True}
54+
2. Set clockwise, example: {'laser_scan_dir': False}
55+
- Angle crop setting, Mask data within the set angle range:
56+
1. Enable angle crop fuction:
57+
1.1. enable angle crop, example: {'enable_angle_crop_func': True}
58+
1.2. disable angle crop, example: {'enable_angle_crop_func': False}
59+
2. Angle cropping interval setting:
60+
- The distance and intensity data within the set angle range will be set to 0.
61+
- angle >= 'angle_crop_min' and angle <= 'angle_crop_max' which is [angle_crop_min, angle_crop_max], unit is degress.
62+
example:
63+
{'angle_crop_min': 135.0}
64+
{'angle_crop_max': 225.0}
65+
which is [135.0, 225.0], angle unit is degress.
66+
'''
67+
3868
def generate_launch_description():
3969
return LaunchDescription([
4070
Node(
71+
# ldlidar publisher node
4172
package='ldlidar_stl_ros2',
4273
executable='ldlidar_stl_ros2_node',
4374
name='LD06',
@@ -46,7 +77,11 @@ def generate_launch_description():
4677
{'product_name': 'LDLiDAR_LD06'},
4778
{'topic_name': 'LiDAR/LD06'},
4879
{'port_name': '/dev/ttyUSB0'},
49-
{'frame_id': 'lidar_frame'}
80+
{'frame_id': 'lidar_frame'},
81+
{'laser_scan_dir': True},
82+
{'enable_angle_crop_func': False},
83+
{'angle_crop_min': 135.0},
84+
{'angle_crop_max': 225.0}
5085
]
5186
)
5287
])
@@ -61,10 +96,22 @@ $ cd ~/ldlidar_ros2_ws
6196
$ colcon build
6297
```
6398
## 3. 运行方法
99+
### 3.1. 设置功能包环境变量
100+
101+
- 编译完成后需要将编译生成的相关文件加入环境变量,便于 ROS 环境可以识别, 执行命令如下所示, 该命令是临时给终端加入环境变量,意味着您如果重新打开新的终端,也需要重新执行如下命令.
102+
103+
```bash
104+
$ cd ~/ldlidar_ros2_ws
105+
$ source install/setup.bash
106+
```
107+
- 为了重新打开终端后,永久不用执行上述添加环境变量的命令,可以进行如下操作.
108+
109+
```bash
110+
$ echo "source ~/ldlidar_ros2_ws/install/setup.bash" >> ~/.bashrc
111+
$ source ~/.bashrc
112+
```
113+
### 3.2. 启动激光雷达节点
64114

65-
```bash
66-
$ source install/setup.bash
67-
```
68115
- 产品型号为 LDROBOT LiDAR LD06
69116

70117
``` bash
@@ -93,7 +140,7 @@ $ rviz2
93140
> This SDK is only applicable to the LiDAR products sold by Shenzhen LDROBOT Co., LTD. The product models are :
94141
> - LDROBOT LiDAR LD06
95142
> - LDROBOT LiDAR LD19
96-
## 0. get LiDAR ROS2 Package
143+
## step 0: get LiDAR ROS2 Package
97144
```bash
98145
$ cd ~
99146

@@ -124,9 +171,40 @@ $ sudo chmod 777 /dev/ttyUSB0
124171
from launch import LaunchDescription
125172
from launch_ros.actions import Node
126173

174+
'''
175+
parameters=[
176+
{'product_name': 'LDLiDAR_LD06'},
177+
{'topic_name': 'LiDAR/LD06'},
178+
{'port_name': '/dev/ttyUSB0'},
179+
{'frame_id': 'lidar_frame'},
180+
{'laser_scan_dir': True},
181+
{'enable_angle_crop_func': False},
182+
{'angle_crop_min': 135.0},
183+
{'angle_crop_max': 225.0}
184+
]
185+
---
186+
Parameter Description:
187+
---
188+
- Set laser scan directon:
189+
1. Set counterclockwise, example: {'laser_scan_dir': True}
190+
2. Set clockwise, example: {'laser_scan_dir': False}
191+
- Angle crop setting, Mask data within the set angle range:
192+
1. Enable angle crop fuction:
193+
1.1. enable angle crop, example: {'enable_angle_crop_func': True}
194+
1.2. disable angle crop, example: {'enable_angle_crop_func': False}
195+
2. Angle cropping interval setting:
196+
- The distance and intensity data within the set angle range will be set to 0.
197+
- angle >= 'angle_crop_min' and angle <= 'angle_crop_max' which is [angle_crop_min, angle_crop_max], unit is degress.
198+
example:
199+
{'angle_crop_min': 135.0}
200+
{'angle_crop_max': 225.0}
201+
which is [135.0, 225.0], angle unit is degress.
202+
'''
203+
127204
def generate_launch_description():
128205
return LaunchDescription([
129206
Node(
207+
# ldlidar publisher node
130208
package='ldlidar_stl_ros2',
131209
executable='ldlidar_stl_ros2_node',
132210
name='LD06',
@@ -135,7 +213,11 @@ def generate_launch_description():
135213
{'product_name': 'LDLiDAR_LD06'},
136214
{'topic_name': 'LiDAR/LD06'},
137215
{'port_name': '/dev/ttyUSB0'},
138-
{'frame_id': 'lidar_frame'}
216+
{'frame_id': 'lidar_frame'},
217+
{'laser_scan_dir': True},
218+
{'enable_angle_crop_func': False},
219+
{'angle_crop_min': 135.0},
220+
{'angle_crop_max': 225.0}
139221
]
140222
)
141223
])
@@ -152,9 +234,23 @@ $ colcon build
152234
```
153235
## step 3: run
154236

155-
```bash
156-
$ source install/setup.bash
157-
```
237+
### step3.1: package environment variable settings
238+
239+
- After the compilation is completed, you need to add the relevant files generated by the compilation to the environment variables, so that the ROS environment can recognize them. The execution command is as follows. This command is to temporarily add environment variables to the terminal, which means that if you reopen a new terminal, you also need to re-execute it. The following command.
240+
241+
```bash
242+
$ cd ~/ldlidar_ros2_ws
243+
$ source install/setup.bash
244+
```
245+
246+
- In order to never need to execute the above command to add environment variables after reopening the terminal, you can do the following.
247+
248+
```bash
249+
$ echo "source ~/ldlidar_ros2_ws/install/setup.bash" >> ~/.bashrc
250+
$ source ~/.bashrc
251+
```
252+
### step3.2: start LiDAR node
253+
158254
- The product is LDROBOT LiDAR LD06
159255

160256
``` bash
@@ -165,7 +261,7 @@ $ source install/setup.bash
165261
$ ros2 launch ldlidar_stl_ros2 ld19.launch.py
166262
```
167263

168-
## step 3: test
264+
## step 4: test
169265

170266
> The code supports ubuntu 20.04 ros2 foxy version and above, using rviz2 visualization.
171267

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
6363
node->get_parameter("angle_crop_min", angle_crop_min);
6464
node->get_parameter("angle_crop_max", angle_crop_max);
6565

66-
RCLCPP_INFO(node->get_logger(), " [ldrobot] SDK Pack Version is v2.2.9");
66+
RCLCPP_INFO(node->get_logger(), " [ldrobot] SDK Pack Version is v2.2.10");
6767
RCLCPP_INFO(node->get_logger(), " [ldrobot] <product_name>: %s ,<topic_name>: %s ,<port_name>: %s ,<frame_id>: %s",
6868
product_name.c_str(), topic_name.c_str(), port_name.c_str(), frame_id.c_str());
6969

0 commit comments

Comments
 (0)