[ROS2] How best to conditionally include a prefix in a launch.py file
I have a simple .launch.py file in ROS2 Foxy:
def generate_launch_description():
n = launch_ros.actions.Node(
package='my_pkg',
executable='my_node',
prefix='some_prefix'
)
return launch.LaunchDescription([n])
However, I'd like to only add the launch prefix if some condition is True.
I have several nodes where I'd be conditionally adding the prefix, so putting an if around the all of the launch_ros.actions.Node() calls would be rather ugly.
Any advice on the cleanest way to do this? Can I use substitutions for this somehow?