ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Maybe not the best solution, but might be easier to read. You could use the OpaqueFunction Action to wrap creating your Node. Something like (untested, but the idea will work):

...
from launch.actions import OpaqueFunction

def start_my_executable(context, *args, **kwargs) -> List[LaunchDescriptionEntity]:
    package_path = get_package_share_directory('my_package')
    color_param = context.perform_substitution(LaunchConfiguration('color'))
    config_file_name = 'red.yml' if color_param else 'blue.yml'
    config_file = os.path.join(package_path, 'config', config_file_name)
    return [Node(... , parameters=[config_file])]

def generate_launch_description():
    ...
    launch_description.add_action(OpaqueFunction(function=start_my_executable)