YDLIDAR_X3驱动安装

本文为安装笔记,感谢官方的售后及工程师在安装过程中提供的帮助。

Step1

必须要首先安装YDLidar-SDK,否则会报错"make cmake_check_build_system"。
YDLidar-SDKgithub下载地址

cd YDLidar-SDK
mkdir build && cd build
cmake ..
make
sudo make install

Step2

安装ROS驱动
github地址
官网地址(注意:目前官网没有X3,选择X2 ROS。X2! X2! X2!!!)

#1.构建ROS_workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
#1.1 在src文件夹下创建CMakeList.txt
catkin_init_workspace
#1.2 对工作空间首次编译
cd ~/catkin_ws
catkin_make
#1.3 设置环境变量
#1.3.1 设置路径到".bashrc"文件,添加永久工作区环境变量,否则可用单次软件包环境设置"source ./devel/setup.sh"
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
#1.3.2 更新环境变量
source ~/.bashrc

# (可选)查看包路径
echo $ROS_PACKAGE_PATH
# (可选)创建串行端口别名
chmod 0777 src/ydlidar_ros_driver-master/startup/*
sudo sh src/ydlidar_ros_driver-master/startup/initenv.sh

#2.将下载的驱动解压放入~/catkin_ws/src/

#3.编译驱动
cd ~/catkin_ws
catkin_make

Step3

rviz查看扫描结果

# 将lidar_view.launch文件中的"lidar.launch"改为"X2.launch"
roslaunch ydlidar_ros_driver lidar_view.launch

注意:

官网教程中会先运行ydlidar_ros_driver (roslaunch ydlidar_ros_driver X2.launch)再执行rviz查看扫描结果,前面的线程必须要停止再执行后面的(roslaunch ydlidar_ros_driver lidar_view.launch)否则会报Error:“Reason given for shutdown: [[/ydlidar_lidar_publisher] Reason: new node registered with same name]”

#!/usr/bin/python3 # Copyright 2020, EAIBOT # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch_ros.actions import LifecycleNode from launch_ros.actions import Node from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration from launch.actions import LogInfo import lifecycle_msgs.msg import os def generate_launch_description(): share_dir = get_package_share_directory('ydlidar_ros2_driver') parameter_file = LaunchConfiguration('params_file') node_name = 'ydlidar_ros2_driver_node' params_declare = DeclareLaunchArgument('params_file', default_value=os.path.join( share_dir, 'params', 'ydlidar_x3.yaml'), description='FPath to the ROS2 parameters file to use.') driver_node = LifecycleNode(name='ydlidar_ros2_driver_node',namespace='/') driver_node.node_package='ydlidar_ros2_driver', driver_node.output='screen', driver_node.emulate_tty=True, driver_node.parameters=[parameter_file], driver_node.node_executable='ydlidar_ros2_driver_node', # tf2_node = Node(node_executable='static_transform_publisher') # tf2_node.node_name='static_tf_pub_laser', # tf2_node.node_package='tf2_ros',
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值