add ROS 2 launch scripts for starting the AGV Pro

This commit is contained in:
X-lanni
2025-06-06 13:38:07 +08:00
parent d398ba0a22
commit 9187b9fb85
5 changed files with 107 additions and 16 deletions
@@ -22,19 +22,7 @@ def generate_launch_description():
parameters=[driver_dir], parameters=[driver_dir],
) )
rviz_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'rviz', 'lslidar.rviz')
rviz_node = Node(
package='rviz2',
namespace='',
executable='rviz2',
name='rviz2',
arguments=['-d', rviz_dir],
output='screen')
return LaunchDescription([ return LaunchDescription([
driver_node, driver_node
rviz_node,
]) ])
@@ -7,7 +7,7 @@
device_ip_difop: 192.168.1.102 #雷达目的ip device_ip_difop: 192.168.1.102 #雷达目的ip
msop_port: 2368 #雷达目的端口号 msop_port: 2368 #雷达目的端口号
difop_port: 2369 #雷达源端口号 difop_port: 2369 #雷达源端口号
lidar_name: M10 #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 L10 N10_P lidar_name: N10_P #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 L10 N10_P
angle_disable_min: 0.0 #角度裁剪开始值 angle_disable_min: 0.0 #角度裁剪开始值
angle_disable_max: 0.0 #角度裁剪结束值 angle_disable_max: 0.0 #角度裁剪结束值
min_range: 0.0 #雷达接收距离最小值 min_range: 0.0 #雷达接收距离最小值
@@ -15,11 +15,11 @@
use_gps_ts: false #雷达是否使用GPS授时 use_gps_ts: false #雷达是否使用GPS授时
scan_topic: /scan #设置激光数据topic名称 scan_topic: /scan #设置激光数据topic名称
interface_selection: serial #接口选择:net 为网口,serial 为串口。 interface_selection: serial #接口选择:net 为网口,serial 为串口。
serial_port_: /dev/ttyUSB0 #串口连接时的串口号 serial_port_: /dev/agv_lidar #串口连接时的串口号
high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。
compensation: false #M10系列是否使用角度补偿功能 compensation: false #M10系列是否使用角度补偿功能
pubScan: true #是否发布scan话题 pubScan: true #是否发布scan话题
pubPointCloud2: false #是否发布pointcloud2话题 pubPointCloud2: false #是否发布pointcloud2话题
pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称
# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 # pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能
# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 # in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能
+23
View File
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.8)
project(agv_pro_bringup)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
@@ -0,0 +1,58 @@
import os
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument,IncludeLaunchDescription
from launch.substitutions import LaunchConfiguration
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
port_name_arg = LaunchConfiguration('port_name',default='ttyS0')
namespace = LaunchConfiguration('namespace', default='')
urdf_file = os.path.join(
get_package_share_directory('agv_pro_description'),
'urdf',
'agv_pro.urdf'
)
with open(urdf_file, 'r') as file:
robot_description_content = file.read()
return LaunchDescription([
DeclareLaunchArgument(
'port_name',
default_value=port_name_arg,
description='port name, e.g. ttyS0'),
Node(
package='agv_pro_base',
executable='agv_pro_node',
name='agv_pro_node',
output='screen',
parameters=[{
'port_name': port_name_arg,
'namespace': namespace,
}],
),
Node(
package='joint_state_publisher',
executable='joint_state_publisher',
name='joint_state_publisher'
),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
parameters=[{'robot_description': robot_description_content}]
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([os.path.join(
get_package_share_directory('lslidar_driver'),'launch'),
'lslidar_launch.py'])
)
])
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>agv_pro_bringup</name>
<version>1.0.0</version>
<description>ROS 2 launch scripts for starting the AGV Pro</description>
<maintainer email="weijun.xie@elephantrobotics.com">lanni</maintainer>
<license>BSD-3-Clause license</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>agv_pro_description</exec_depend>
<exec_depend>agv_pro_base</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>