diff --git a/controller_manager/test/test_controller_spawner_wildcard_entries.yaml b/controller_manager/test/test_controller_spawner_wildcard_entries.yaml index bead4f96f3..1a05ac03d6 100644 --- a/controller_manager/test/test_controller_spawner_wildcard_entries.yaml +++ b/controller_manager/test/test_controller_spawner_wildcard_entries.yaml @@ -4,3 +4,7 @@ joint_names: ["joint1"] param1: 1.0 param2: 2.0 + +wildcard_ctrl_3: + ros__parameters: + param3: 3.0 diff --git a/controller_manager/test/test_spawner_unspawner.cpp b/controller_manager/test/test_spawner_unspawner.cpp index 206379c384..107c557dbb 100644 --- a/controller_manager/test/test_spawner_unspawner.cpp +++ b/controller_manager/test/test_spawner_unspawner.cpp @@ -375,12 +375,13 @@ TEST_F(TestLoadController, spawner_test_with_wildcard_entries_with_no_ctrl_name) // Provide controller type via the parsed file EXPECT_EQ( call_spawner( - "wildcard_ctrl_1 wildcard_ctrl_2 -c test_controller_manager --controller-manager-timeout 1.0 " + "wildcard_ctrl_1 wildcard_ctrl_2 wildcard_ctrl_3 -c test_controller_manager " + "--controller-manager-timeout 1.0 " "-p " + test_file_path), 0); - auto verify_ctrl_parameter = [](const auto & ctrl_node) + auto verify_ctrl_parameter = [](const auto & ctrl_node, bool has_param_3) { if (!ctrl_node->has_parameter("joint_names")) { @@ -401,25 +402,39 @@ TEST_F(TestLoadController, spawner_test_with_wildcard_entries_with_no_ctrl_name) ctrl_node->declare_parameter("param2", -10.0); } ASSERT_THAT(ctrl_node->get_parameter("param2").as_double(), 2.0); + + if (!ctrl_node->has_parameter("param3")) + { + ctrl_node->declare_parameter("param3", -10.0); + } + ASSERT_THAT(ctrl_node->get_parameter("param3").as_double(), has_param_3 ? 3.0 : -10.0); }; - ASSERT_EQ(cm_->get_loaded_controllers().size(), 2ul); + ASSERT_EQ(cm_->get_loaded_controllers().size(), 3ul); - auto wildcard_ctrl_1 = cm_->get_loaded_controllers()[0]; - ASSERT_EQ(wildcard_ctrl_1.info.name, "wildcard_ctrl_2"); - ASSERT_EQ(wildcard_ctrl_1.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME); + auto wildcard_ctrl_3 = cm_->get_loaded_controllers()[0]; + ASSERT_EQ(wildcard_ctrl_3.info.name, "wildcard_ctrl_3"); + ASSERT_EQ(wildcard_ctrl_3.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME); ASSERT_EQ( - wildcard_ctrl_1.c->get_lifecycle_state().id(), + wildcard_ctrl_3.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE); - verify_ctrl_parameter(wildcard_ctrl_1.c->get_node()); + verify_ctrl_parameter(wildcard_ctrl_3.c->get_node(), true); auto wildcard_ctrl_2 = cm_->get_loaded_controllers()[1]; - ASSERT_EQ(wildcard_ctrl_2.info.name, "wildcard_ctrl_1"); + ASSERT_EQ(wildcard_ctrl_2.info.name, "wildcard_ctrl_2"); ASSERT_EQ(wildcard_ctrl_2.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME); ASSERT_EQ( wildcard_ctrl_2.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE); - verify_ctrl_parameter(wildcard_ctrl_2.c->get_node()); + verify_ctrl_parameter(wildcard_ctrl_2.c->get_node(), false); + + auto wildcard_ctrl_1 = cm_->get_loaded_controllers()[2]; + ASSERT_EQ(wildcard_ctrl_1.info.name, "wildcard_ctrl_1"); + ASSERT_EQ(wildcard_ctrl_1.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME); + ASSERT_EQ( + wildcard_ctrl_1.c->get_lifecycle_state().id(), + lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE); + verify_ctrl_parameter(wildcard_ctrl_1.c->get_node(), false); } TEST_F(TestLoadController, unload_on_kill)