ros2 / launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Apache License 2.0
124 stars 139 forks source link

Add AndCondition, OrCondition to conditions #678

Closed LukeSchmitt96 closed 1 year ago

LukeSchmitt96 commented 1 year ago

This pull request adds AndCondition and OrCondition to the conditions module. These classes can be used to evaluate a list or tuple of strings or Conditions. Implementing this change would tidy up somewhat messy conditional statements like

condition=(IfCondition(condition1) and IfCondition(condition2))

simplifying them to something like

condition=AndCondition([condition1, condition2])

This change addresses the third "combine multiple conditions" option in #105.

methylDragon commented 1 year ago

Use the And and Or substitutions instead

https://github.com/ros2/launch/blob/rolling/launch/test/launch/substitutions/test_boolean_substitution.py

LukeSchmitt96 commented 1 year ago

Didn't catch those when reviewing — thanks for the heads up.

eliasdc commented 6 months ago

Use the And and Or substitutions instead

https://github.com/ros2/launch/blob/rolling/launch/test/launch/substitutions/test_boolean_substitution.py

Not sure if these are equivalent, you can't link existing Conditions with And and Or substitutions.

Example:

AndCondition([
    LaunchConfigurationNotEquals("param_1", "value_1"),
    LaunchConfigurationNotEquals("param_2", "value_2")
]),

or how would this be solved?