ExcuteProcess :
ros2 riviz2 rivz2 |
ExecuteProcess.launch.py
#!/usr/bin/env python3 import os from launch import LaunchDescription from launch.actions import ExecuteProcess, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node # this is the function launch system will look for def generate_launch_description(): # create and return launch description object return LaunchDescription( [ ExecuteProcess( cmd=["ros2", "run", "rviz2", "rviz2"], output="screen" ), ] ) |
Node :
ros2 run turtlesim turtlesim_node ros2 run turtlesim draw_square |
Node.launch.py
#!/usr/bin/env python3 import os from launch import LaunchDescription from launch.actions import ExecuteProcess, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node # this is the function launch system will look for def generate_launch_description(): turtlesim_node = Node( package='turtlesim', executable='turtlesim_node', parameters=[], arguments=[], output="screen", ) turtlesim_teleop_node = Node( package='turtlesim', executable='draw_square', parameters=[], arguments=[], output="screen", ) # create and return launch description object return LaunchDescription( [ turtlesim_node, turtlesim_teleop_node, ] ) |
package.xml
<exec_depend>ros2launch</exec_depend> |
setup.py
import os from glob import glob from setuptools import setup package_name = 'my_package' setup( # Other parameters ... data_files=[ # ... Other data files # Include all launch files. This is the most important line here! (os.path.join('share', package_name), glob('launch/*.launch.py')) ] ) |
CMakeLists.txt
# Install launch files. install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/ ) |
ros2 launch my_pkg_cpp ExecuteProcess.launch.py ros2 launch my_pkg_cpp Node.launch.py |
[Reference]
[1] https://puzzling-cashew-c4c.notion.site/ROS-2-Launch-launch-file-55c2125808ef4b64bade278852b37d6e
[2] https://docs.ros.org/en/foxy/Tutorials/Launch/Launch-system.html
[3] https://docs.ros.org/en/foxy/Tutorials/Launch/Using-ROS2-Launch-For-Large-Projects.html
'ROS > ROS2Foxy' 카테고리의 다른 글
Static Transform Publisher using TF2 (0) | 2022.06.17 |
---|---|
URDF using rviz2 (0) | 2022.06.09 |
Broadcasting single frames using static_transform_publisher (0) | 2022.06.03 |
Create a new package for interfaces (0) | 2022.05.11 |
ros2 launch (0) | 2022.05.04 |