Skip to content

Commit 7fba025

Browse files
authored
Add tests for multiple controller ros args (#2155)
1 parent 119d08c commit 7fba025

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

controller_manager/test/test_spawner_unspawner.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,9 @@ TEST_F(TestLoadController, test_spawner_parsed_controller_ros_args)
812812

813813
// Now test the remapping of the service name with the controller_ros_args
814814
EXPECT_EQ(
815-
call_spawner(
816-
"ctrl_2 -c test_controller_manager --controller-ros-args '-r /ctrl_2/set_bool:=/set_bool'"),
815+
call_spawner("ctrl_2 -c test_controller_manager --controller-ros-args '-r "
816+
"/ctrl_2/set_bool:=/set_bool' --controller-ros-args '--param "
817+
"run_cycle:=20 -p test_cycle:=-11.0'"),
817818
0);
818819

819820
ASSERT_EQ(cm_->get_loaded_controllers().size(), 2ul);
@@ -826,6 +827,20 @@ TEST_F(TestLoadController, test_spawner_parsed_controller_ros_args)
826827
node->create_client<example_interfaces::srv::SetBool>("/ctrl_2/set_bool");
827828
ASSERT_FALSE(ctrl_2_set_bool_service->wait_for_service(std::chrono::seconds(2)));
828829
ASSERT_FALSE(ctrl_2_set_bool_service->service_is_ready());
830+
831+
// Check the parameter run_cycle to have the right value
832+
ASSERT_EQ("ctrl_2", cm_->get_loaded_controllers()[0].info.name);
833+
auto ctrl_2 = cm_->get_loaded_controllers()[0].c->get_node();
834+
if (!ctrl_2->has_parameter("run_cycle"))
835+
{
836+
ctrl_2->declare_parameter("run_cycle", -200);
837+
}
838+
ASSERT_THAT(ctrl_2->get_parameter("run_cycle").as_int(), 20);
839+
if (!ctrl_2->has_parameter("test_cycle"))
840+
{
841+
ctrl_2->declare_parameter("test_cycle", 1231.0);
842+
}
843+
ASSERT_THAT(ctrl_2->get_parameter("test_cycle").as_double(), -11.0);
829844
}
830845

831846
class TestLoadControllerWithoutRobotDescription

0 commit comments

Comments
 (0)