启动文件:
之前需要多个命令行,来操作,很不方便。
学习lauch file ,用命令脚本来控制。
# turtlesim/launch/multisim.launch.py ,
from launch import LaunchDescription
import launch_ros.actionsdef generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
namespace= "turtlesim1", package='turtlesim', executable='turtlesim_node', output='screen'),
launch_ros.actions.Node(
namespace= "turtlesim2", package='turtlesim', executable='turtlesim_node', output='screen'),
])
ros2 launch turtlesim multisim.launch.py
创建2个node节点。
启动文件:
ros2 launch 《package name》 <youname>.launch.py
具体原理??
Launching/monitoring multiple nodes with Launch — ROS 2 Documentation: Foxy documentation
launch 文件,工程构建: