在launch
目录里创建launch文件或py文件后,ros2 launch
不能直接找到,会报错1
file 'file.launch' was not found in the share directory of package 'package_name' which is at '/home/user/catkin_ws/install/package_name/share/package_name'
需要在CMakeLists里加一句1
2install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME})
再编译后,会把launch文件复制到share
目录里。
- 使用xml
1 | <launch> |
args
的写法一直查不到,按ROS1的写法是错的,节点会退出: <node pkg ="tf2_ros" exec="static_transform_publisher" name="map_odom_tf" args="1 0 0 0 0 0 map odom 100" />
- 使用python
1 | cd ~/ros2_ws |
加入下面内容:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='duckiebot',
namespace='duckietown',
executable='duckiebot_node',
name='duckiebot_node1'
),
Node(
package='control',
namespace='duckietown',
executable='control_node',
name='control_node1'
)
])