Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
launch_launch: Sample program to call a launch file from a launch file (https://ar-ray.hatenablog.com/entry/2021/08/15/203449)
import launch
import launch_ros.actions
def generate_launch_description():
param0 = launch.substitutions.LaunchConfiguration('param0', default="0")
param1 = launch.substitutions.LaunchConfiguration('param1', default="0")
param2 = launch.substitutions.LaunchConfiguration('param2', default="0")
param3 = launch.substitutions.LaunchConfiguration('param3', default="0")
argment0 = launch.actions.DeclareLaunchArgument("param0", default_value="1")
argment1 = launch.actions.DeclareLaunchArgument("param1", default_value="2")
argment2 = launch.actions.DeclareLaunchArgument("param2", default_value="3")
argment3 = launch.actions.DeclareLaunchArgument("param3", default_value="4")
param_node = launch_ros.actions.Node(
package="launch_launch", executable="param", output="screen",
parameters=[{
"param0": param0,
"param1": param1,
"param2": param2,
"param3": param3,
}]
)
return launch.LaunchDescription([
argment0,
argment1,
# argment2,
# argment3,
param_node,
])
import launch
from ament_index_python.packages import get_package_share_directory
from launch.launch_description_sources import PythonLaunchDescriptionSource
def generate_launch_description():
launch_launch_share_dir = get_package_share_directory("launch_launch")
read_launch = launch.actions.IncludeLaunchDescription(
PythonLaunchDescriptionSource([launch_launch_share_dir + "/launch/base.launch.py"]),
launch_arguments={
"param0": "10",
"param1": "20",
"param2": "30",
"param3": "40",
}.items()
)
return launch.LaunchDescription([
read_launch,
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment