ldrobotSensorTeam / ldlidar_stl_ros

LDROBOT DTOF LiDAR ROS Package
MIT License
22 stars 13 forks source link
ld06 ld19 ros

此SDK仅适用于深圳乐动机器人有限公司销售的激光雷达产品,产品型号为:

  • LDROBOT LiDAR LD06
  • LDROBOT LiDAR LD19

    0. 获取雷达的ROS功能包

    
    cd ~

mkdir -p ldlidar_ros_ws/src

cd ldlidar_ros_ws/src

git clone https://github.com/ldrobotSensorTeam/ldlidar_stl_ros.git

或者

git clone https://gitee.com/ldrobotSensorTeam/ldlidar_stl_ros.git


## 1. 系统设置
- 第一步,通过板载串口或者USB转串口模块(例如,cp2102模块)的方式使雷达连接到你的系统主板.
- 第二步,设置雷达在系统中挂载的串口设备-x权限(以/dev/ttyUSB0为例)
    - 实际使用时,根据雷达在你的系统中的实际挂载情况来设置,可以使用`ls -l /dev`命令查看.

``` bash
cd ~/ldlidar_ros_ws

sudo chmod 777 /dev/ttyUSB0
<?xml version="1.0"?>
<launch>
<arg name="topic_name" default="scan"/>
<arg name="frame_id" default="base_laser"/>
<arg name="port_name" default="/dev/ttyUSB0"/>
<arg name="port_baudrate" default="230400"/>
<arg name="fix_to_base_link" default="true"/>

<!-- ldldiar message publisher node -->
 <node name="LD06" pkg="ldlidar_stl_ros" type="ldlidar_stl_ros_node" output="screen" >
  <param name="product_name" value="LDLiDAR_LD06"/>
  <param name="topic_name" value="$(arg topic_name)"/>
  <param name="frame_id" value="$(arg frame_id)"/>
  <param name="port_name" value ="$(arg port_name)"/>
  <param name="port_baudrate" value ="$(arg port_baudrate)"/>
  <!-- Set laser scan directon: -->
  <!--    1. Set counterclockwise, example: <param name="laser_scan_dir" type="bool" value="true"/> -->
  <!--    2. Set clockwise,        example: <param name="laser_scan_dir" type="bool" value="false"/> -->
  <param name="laser_scan_dir" type="bool" value="true"/>
  <!-- Angle crop setting, Mask data within the set angle range -->
  <!--    1. Enable angle crop fuction: -->
  <!--       1.1. enable angle crop,  example: <param name="enable_angle_crop_func" type="bool" value="true"/> -->
  <!--       1.2. disable angle crop, example: <param name="enable_angle_crop_func" type="bool" value="false"/> -->
  <param name="enable_angle_crop_func" type="bool" value="false"/>
  <!--    2. Angle cropping interval setting, The distance and intensity data within the set angle range will be set to 0 --> 
  <!--       angle >= "angle_crop_min" and angle <= "angle_crop_max", unit is degress -->
  <param name="angle_crop_min" type="double" value="135.0"/>
  <param name="angle_crop_max" type="double" value="225.0"/>
 </node>
<!-- ldlidar message subscriber node -->
 <!-- node name="ListenLD06" pkg="ldlidar_stl_ros" type="ldlidar_stl_ros_listen_node" output="screen">
  <param name="topic_name" value="scan"/>
 </node -->
 <!-- publisher tf transform, parents frame is base_link, child frame is base_laser -->
 <!-- args="x y z yaw pitch roll parents_frame_id child_frame_id period_in_ms"-->
 <node name="base_to_laser" pkg="tf" type="static_transform_publisher"  args="0.0 0.0 0.18 0 0.0 0.0 base_link base_laser 50" if="$(arg fix_to_base_link)"/>
</launch>

2. 编译方法

rosdep install --from-paths src --ignore-src -r -y

- 使用catkin编译
```bash
cd ~/ldlidar_ros_ws

catkin_make

3. 运行方法

3.1. 设置功能包环境变量

4. 测试

代码支持ubuntu16.04 ROS kinetic、ubuntu18.04 ROS melodic、ubuntu20.04 ROS noetic版本下测试,使用rviz可视化。

This SDK is only applicable to the LiDAR products sold by Shenzhen LDROBOT Co., LTD. The product models are :

  • LDROBOT LiDAR LD06
  • LDROBOT LiDAR LD19

    step0: get LiDAR ROS Package

    
    cd ~

mkdir -p ldlidar_ros_ws/src

cd ldlidar_ros_ws/src

git clone https://github.com/ldrobotSensorTeam/ldlidar_stl_ros.git

or

git clone https://gitee.com/ldrobotSensorTeam/ldlidar_stl_ros.git

## step 1: system setup
- Connect the LiDAR to your system motherboard via an onboard serial port or usB-to-serial module (for example, CP2102 module).

- Set the -x permission for the serial port device mounted by the radar in the system (for example, /dev/ttyUSB0)

  - In actual use, the LiDAR can be set according to the actual mounted status of your system, you can use 'ls -l /dev' command to view.

``` bash
cd ~/ldlidar_ros_ws

sudo chmod 777 /dev/ttyUSB0
<?xml version="1.0"?>
<launch>
<arg name="topic_name" default="scan"/>
<arg name="frame_id" default="base_laser"/>
<arg name="port_name" default="/dev/ttyUSB0"/>
<arg name="port_baudrate" default="230400"/>
<arg name="fix_to_base_link" default="true"/>

<!-- ldldiar message publisher node -->
 <node name="LD06" pkg="ldlidar_stl_ros" type="ldlidar_stl_ros_node" output="screen" >
  <param name="product_name" value="LDLiDAR_LD06"/>
  <param name="topic_name" value="$(arg topic_name)"/>
  <param name="frame_id" value="$(arg frame_id)"/>
  <param name="port_name" value ="$(arg port_name)"/>
  <param name="port_baudrate" value ="$(arg port_baudrate)"/>
  <!-- Set laser scan directon: -->
  <!--    1. Set counterclockwise, example: <param name="laser_scan_dir" type="bool" value="true"/> -->
  <!--    2. Set clockwise,        example: <param name="laser_scan_dir" type="bool" value="false"/> -->
  <param name="laser_scan_dir" type="bool" value="true"/>
  <!-- Angle crop setting, Mask data within the set angle range -->
  <!--    1. Enable angle crop fuction: -->
  <!--       1.1. enable angle crop,  example: <param name="enable_angle_crop_func" type="bool" value="true"/> -->
  <!--       1.2. disable angle crop, example: <param name="enable_angle_crop_func" type="bool" value="false"/> -->
  <param name="enable_angle_crop_func" type="bool" value="false"/>
  <!--    2. Angle cropping interval setting, The distance and intensity data within the set angle range will be set to 0 --> 
  <!--       angle >= "angle_crop_min" and angle <= "angle_crop_max", unit is degress -->
  <param name="angle_crop_min" type="double" value="135.0"/>
  <param name="angle_crop_max" type="double" value="225.0"/>
 </node>
<!-- ldlidar message subscriber node -->
 <!-- node name="ListenLD06" pkg="ldlidar_stl_ros" type="ldlidar_stl_ros_listen_node" output="screen">
  <param name="topic_name" value="scan"/>
 </node -->
 <!-- publisher tf transform, parents frame is base_link, child frame is base_laser -->
 <!-- args="x y z yaw pitch roll parents_frame_id child_frame_id period_in_ms"-->
 <node name="base_to_laser" pkg="tf" type="static_transform_publisher"  args="0.0 0.0 0.18 0 0.0 0.0 base_link base_laser 50" if="$(arg fix_to_base_link)"/>
</launch>

step 2: build

rosdep install --from-paths src --ignore-src -r -y


- build compile
```bash
cd ~/ldlidar_ros_ws

catkin_make

step 3: run

step3.1: package environment variable settings

step 4: test

The code was tested under ubuntu16.04 ROS kinetic、ubuntu18.04 ROS melodic、ubuntu20.04 ROS noetic, using rviz visualization.