此SDK仅适用于深圳乐动机器人有限公司销售的激光雷达产品,产品型号为:
- LDROBOT LiDAR LD06
- LDROBOT LiDAR LD19
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
ls -l /dev
命令查看.cd ~/ldlidar_ros_ws
sudo chmod 777 /dev/ttyUSB0
launch/
目录下雷达产品型号对应的lanuch文件中的port_name
值,以ld06.launch为例,如下所示.<?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>
cd ~/ldlidar_ros_ws
rosdep install --from-paths src --ignore-src -r -y
cd ~/ldlidar_ros_ws
catkin_make
编译完成后需要将编译生成的相关文件加入环境变量,便于 ROS 环境可以识别, 执行命令如下所示, 该命令是临时给终端加入环境变量,意味着您如果重 新打开新的终端,也需要重新执行如下命令.
cd ~/ldlidar_ros_ws
source devel/setup.bash
为了重新打开终端后,永久不用执行上述添加环境变量的命令,可以进行如下操作.
echo "source ~/ldlidar_ros_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
产品型号为 LDROBOT LiDAR LD06
roslaunch ldlidar_stl_ros ld06.launch
# if ROS_DISTRO in 'kinetic' or 'melodic'
roslaunch ldlidar_stl_ros viewer_ld06_kinetic_melodic.launch
# if ROS_DISTRO in 'noetic'
roslaunch ldlidar_stl_ros viewer_ld06_noetic.launch
产品型号为 LDROBOT LiDAR LD19
roslaunch ldlidar_stl_ros ld19.launch
# if ROS_DISTRO in 'kinetic' or 'melodic'
roslaunch ldlidar_stl_ros viewer_ld19_kinetic_melodic.launch
# if ROS_DISTRO in 'noetic'
roslaunch ldlidar_stl_ros viewer_ld19_noetic.launch
代码支持ubuntu16.04 ROS kinetic、ubuntu18.04 ROS melodic、ubuntu20.04 ROS noetic版本下测试,使用rviz可视化。
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
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
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)
cd ~/ldlidar_ros_ws
sudo chmod 777 /dev/ttyUSB0
port_name
value in the Lanuch file corresponding to the radar product model under launch/
, using ld06.launch
as an example, as shown below.<?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>
cd ~/ldlidar_ros_ws
rosdep install --from-paths src --ignore-src -r -y
cd ~/ldlidar_ros_ws
catkin_make
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.
cd ~/ldlidar_ros_ws
source devel/setup.bash
In order to never need to execute the above command to add environment variables after reopening the terminal, you can do the following.
echo "source ~/ldlidar_ros_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
The product is LDROBOT LiDAR LD06
roslaunch ldlidar_stl_ros ld06.launch
# if ROS_DISTRO in 'kinetic' or 'melodic'
roslaunch ldlidar_stl_ros viewer_ld06_kinetic_melodic.launch
# if ROS_DISTRO in 'noetic'
roslaunch ldlidar_stl_ros viewer_ld06_noetic.launch
The product is LDROBOT LiDAR LD19
roslaunch ldlidar_stl_ros ld19.launch
# if ROS_DISTRO in 'kinetic' or 'melodic'
roslaunch ldlidar_stl_ros viewer_ld19_kinetic_melodic.launch
# if ROS_DISTRO in 'noetic'
roslaunch ldlidar_stl_ros viewer_ld19_noetic.launch
The code was tested under ubuntu16.04 ROS kinetic、ubuntu18.04 ROS melodic、ubuntu20.04 ROS noetic, using rviz visualization.
rviz
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。