我下载了官方包在ROS2滚动中使用YDlidar X4,但是每次运行
ros2 launch ydlidar_ros2_driver ydlidar_launch.py
时,都会出现以下错误:
INFO] [launch]: All log files can be found below /home/ohmin/.ros/log/2023-02-27-02-37-46-155449-ohmin-13510
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ydlidar_ros2_driver_node-1]: process started with pid [13511]
[INFO] [static_transform_publisher-2]: process started with pid [13513]
[static_transform_publisher-2] [WARN] [1677433066.231842522] []: Old-style arguments are deprecated; see --help for new-style arguments
[ydlidar_ros2_driver_node-1] [INFO] [1677433066.236957516] [ydlidar_ros2_driver_node]: [YDLIDAR INFO] Current ROS Driver Version: 1.0.1
[ydlidar_ros2_driver_node-1]
[ydlidar_ros2_driver_node-1] terminate called after throwing an instance of 'rclcpp::exceptions::UninitializedStaticallyTypedParameterException'
[ydlidar_ros2_driver_node-1] what(): Statically typed parameter 'fixed_resolution' must be initialized.
[static_transform_publisher-2] [INFO] [1677433066.238474174] [static_tf_pub_laser]: Spinning until stopped - publishing transform
[static_transform_publisher-2] translation: ('0.000000', '0.000000', '0.020000')
[static_transform_publisher-2] rotation: ('0.000000', '0.000000', '0.000000', '1.000000')
[static_transform_publisher-2] from 'base_link' to 'laser_frame'
[ERROR] [ydlidar_ros2_driver_node-1]: process has died [pid 13511, exit code -6, cmd '/home/ohmin/ydlidar_ros2_ws/install/ydlidar_ros2_driver/lib/ydlidar_ros2_driver/ydlidar_ros2_driver_node --ros-args -r __node:=ydlidar_ros2_driver_node --params-file /home/ohmin/ydlidar_ros2_ws/install/ydlidar_ros2_driver/share/ydlidar_ros2_driver/params/ydlidar.yaml'].
ydlidar_launch.py
,如下:
#!/usr/bin/python3
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.yaml'),
description='FPath to the ROS2 parameters file to use.')
driver_node = Node(package='ydlidar_ros2_driver',
executable='ydlidar_ros2_driver_node',
name='ydlidar_ros2_driver_node',
output='screen',
emulate_tty=True,
parameters=[parameter_file],
)
tf2_node = Node(package='tf2_ros',
executable='static_transform_publisher',
name='static_tf_pub_laser',
arguments=['0', '0', '0.02','0', '0', '0', '1','base_link','laser_frame'],
)
return LaunchDescription([
params_declare,
driver_node,
tf2_node,
])
有人知道如何解决这个问题吗?
当我在
./tri_test
中执行 YDLidar-SDK/build
来测试我的激光雷达时,它会旋转一小会儿,最终停止并出现以下错误:
0. ydlidar
1. ydlidar3
Please select the lidar port:1
Baudrate:
0. 115200
1. 128000
2. 150000
3. 153600
4. 230400
5. 460800
6. 512000
Please select the lidar baudrate:1
Whether the Lidar is one-way communication[yes/no]:yes
[YDLIDAR] SDK initializing
[YDLIDAR] SDK has been initialized
[YDLIDAR] SDK Version: 1.1.4
[YDLIDAR] Lidar successfully connected
[YDLIDAR] Lidar running correctly! The health status: good
[YDLIDAR] Lidar init success, Elapsed time 624 ms
[YDLIDAR] Start to getting intensity flag
[YDLIDAR] Auto set intensity 0
[YDLIDAR] End to getting intensity flag
[YDLIDAR] Create thread 0x265FF640
[YDLIDAR] Successed to start scan mode, Elapsed time 1174 ms
timeout count: 1
timeout count: 2
timeout count: 1
0x265FF640 thread has been canceled
[YDLIDAR] Failed to turn on the Lidar, because the lidar is [Device Tremble].
Fail to start Unknown error
我还尝试在
python3 plot_tof_test.py
中运行 YDLidar-SDK/python/examples
来测试是否存在一些机械缺陷,但由于我更正了波特率和单通道,这个 python 命令可以正常运行。
以下是我的 ydlidar.yaml。
ydlidar_ros2_driver_node:
ros__parameters:
port: /dev/ttyUSB0
frame_id: laser_frame
ignore_array: ""
baudrate: 128000
lidar_type: 1
device_type: 0
sample_rate: 5
abnormal_check_count: 4
resolution_fixed: true
reversion: true
inverted: true
auto_reconnect: true
isSingleChannel: false
intensity: false
support_motor_dtr: false
angle_max: 180.0
angle_min: -180.0
range_max: 10
range_min: 0.12
frequency: 10.0
invalid_range_is_inf: false
我面临着同样的问题,你在这方面发现什么有用的东西吗
致以诚挚的问候 医学博士