from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package = 'camera',
executable = 'camera_pub.py',
),
Node(
package = 'processor',
executable = 'image_processor.py',
),
Node(
package = 'serial',
executable = 'serial_controller.py'
),
])
上面代码为我的launch文件,用于启动三个节点。在编译时没有报错。
from setuptools import setup
import os
from glob import glob
package_name = 'initiator'
setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='raine',
maintainer_email='raine@todo.todo',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
"camera_node = camera.camera_pub:main",
"processor_node = processor.image_processor:main",
"serial_node = serial.serial_controller:main"
],
},
)
上面代码为我在setup文件里配置
上图为运行时报错,显示找不到LaunchDescription
上图为VS Code里程序