Skip to content

Commit

Permalink
Implement None check for ComposableNodeContainer (#341) (#371)
Browse files Browse the repository at this point in the history
(cherry picked from commit 35b2ca9)

Co-authored-by: methylDragon <[email protected]>
  • Loading branch information
mergify[bot] and methylDragon authored Jul 24, 2023
1 parent 3e54bf2 commit abce4dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 5 additions & 3 deletions launch_ros/launch_ros/actions/composable_node_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ def execute(self, context: LaunchContext) -> Optional[List[Action]]:
"""
load_actions = None # type: Optional[List[Action]]
valid_composable_nodes = []
for node_object in self.__composable_node_descriptions:
if node_object.condition() is None or node_object.condition().evaluate(context):
valid_composable_nodes.append(node_object)
if self.__composable_node_descriptions:
for node_object in self.__composable_node_descriptions:
if node_object.condition() is None or node_object.condition().evaluate(context):
valid_composable_nodes.append(node_object)

if (
valid_composable_nodes is not None and
len(valid_composable_nodes) > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ def test_composable_node_container_empty_list_of_nodes():
assert get_node_name_count(context, f'/{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}') == 0


def test_composable_node_container_no_list_of_nodes():
"""Test launching a ComposableNodeContainer with no passed in list of nodes."""
actions = [
ComposableNodeContainer(
package='rclcpp_components',
executable='component_container',
name=TEST_CONTAINER_NAME,
namespace=TEST_CONTAINER_NAMESPACE
),
]

context = _assert_launch_no_errors(actions)
assert get_node_name_count(context, f'/{TEST_CONTAINER_NAMESPACE}/{TEST_CONTAINER_NAME}') == 1
assert get_node_name_count(context, f'/{TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}') == 0


def test_composable_node_container_in_group_with_launch_configuration_in_description():
"""
Test launch configuration is passed to ComposableNode description inside GroupAction.
Expand Down

0 comments on commit abce4dd

Please sign in to comment.