ROS2_Foxy学习8——launch
ROS2_Foxy学习8——launch
The launch system in ROS 2 is responsible for helping the user describe the configuration of their system and then execute it as described. The configuration of the system includes what programs to run, where to run them, what arguments to pass them, and ROS specific conventions which make it easy to reuse components throughout the system by giving them each different configurations. It is also responsible for monitoring the state of the processes launched, and reporting and/or reacting to changes in the state of those processes.
launch文件的Python模板
| 项目 | 作用 | 项目 | 作用 | 项目 | 作用 |
|---|---|---|---|---|---|
| package | 功能包名(必须) | executable | 可执行程序名(必须) | arguments | 参数列表 |
| output | 输出类型 screen / log | namespace | 名称空间 | name | 节点名 |
| remappings | 重映射 | prefix | 运行命令 |
- 基础
from launch import LaunchDescription from launch_ros.actions import Node def generate_launch_description(): return LaunchDescription([ Node( package='my_package', executable='my_exe', name='my_node', output='screen', arguments=['39','-0.968','abc'] # 程序里面从 argv[1] 开始读取 ) ]) - 延伸
- static_tf
- gdb调试
- 重映射
from launch import LaunchDescription from launch_ros.actions import Node def generate_launch_description(): return LaunchDescription([ # static tf # 参数列表分别是 x,y,z,x,y,z,w,parent_frame,child_frame Node( package='tf2_ros', executable='static_transform_publisher', arguments = ['0.145', '0', '0', '0', '0', '1', '0', 'base_link', 'laser'] ), # gdb调试 Node( package='global_map', executable='global_map', prefix='xterm -e gdb -ex run --args' ), # 重映射 Node( package='turtlesim', executable='mimic', remappings=[ ('/input/pose', '/turtlesim1/turtle1/pose'), ('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'), ] ) ]) - 运行
ros2 launch your_path_to_launch/mylaunch.py