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

Revision history [back]

Hi,

If you use the simple_launch package*, conditions boil down to a with block as follows:

from simple_launch import SimpleLauncher

def generate_launch_description():
    sl = SimpleLauncher()

    sl.declare_arg('viz', default_value=False, description='Run RViz')

    with sl.group(if_arg='viz'):
        sl.node('rviz2', 'rviz2')

return sl.launch_description()

More complex conditions can be combined, and the opaque_function approach can always be taken when actual Python (not launch) logic is needed.

  • disclaimer: I am the author of this package