Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ros-controls/ros2_control
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2ef793ae6a335d8fe48199b6a1774b28726ee161
Choose a base ref
..
head repository: ros-controls/ros2_control
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9bfa9b77a898a4681432165debf251ff6e02d2a5
Choose a head ref
Showing with 6 additions and 68 deletions.
  1. +6 −13 controller_manager/controller_manager/spawner.py
  2. +0 −55 controller_manager/test/test_spawner_unspawner.cpp
19 changes: 6 additions & 13 deletions controller_manager/controller_manager/spawner.py
Original file line number Diff line number Diff line change
@@ -265,24 +265,17 @@ def main(args=None):
node, controller_manager_name, controller_names, [], True, True, 5.0
)
if not ret.ok:
node.get_logger().error("Failed to deactivate controller")
node.get_logger().error(
bcolors.FAIL + "Failed to deactivate controller" + bcolors.ENDC
)
return 1

<<<<<<< HEAD
node.get_logger().info("Deactivated controller")

elif args.stopped:
node.get_logger().warn('"--stopped" flag is deprecated use "--inactive" instead')

ret = unload_controller(node, controller_manager_name, controller_name)
if not ret.ok:
node.get_logger().error("Failed to unload controller")
return 1
=======
node.get_logger().info(
f"Successfully deactivated controllers : {controller_names}"
)
>>>>>>> 9e57adf (Fix unload of controllers when spawned with `--unload-on-kill` (#1717))

elif args.stopped:
node.get_logger().warn('"--stopped" flag is deprecated use "--inactive" instead')

unload_status = True
for controller_name in controller_names:
55 changes: 0 additions & 55 deletions controller_manager/test/test_spawner_unspawner.cpp
Original file line number Diff line number Diff line change
@@ -254,8 +254,6 @@ TEST_F(TestLoadController, unload_on_kill)
ASSERT_EQ(cm_->get_loaded_controllers().size(), 0ul);
}

<<<<<<< HEAD
=======
TEST_F(TestLoadController, unload_on_kill_activate_as_group)
{
// Launch spawner with unload on kill
@@ -275,59 +273,6 @@ TEST_F(TestLoadController, unload_on_kill_activate_as_group)
ASSERT_EQ(cm_->get_loaded_controllers().size(), 0ul);
}

TEST_F(TestLoadController, spawner_test_fallback_controllers)
{
const std::string test_file_path = ament_index_cpp::get_package_prefix("controller_manager") +
"/test/test_controller_spawner_with_fallback_controllers.yaml";

cm_->set_parameter(rclcpp::Parameter("ctrl_1.type", test_controller::TEST_CONTROLLER_CLASS_NAME));
cm_->set_parameter(rclcpp::Parameter("ctrl_2.type", test_controller::TEST_CONTROLLER_CLASS_NAME));
cm_->set_parameter(rclcpp::Parameter("ctrl_3.type", test_controller::TEST_CONTROLLER_CLASS_NAME));

ControllerManagerRunner cm_runner(this);
EXPECT_EQ(call_spawner("ctrl_1 -c test_controller_manager --load-only -p " + test_file_path), 0);

ASSERT_EQ(cm_->get_loaded_controllers().size(), 1ul);
{
auto ctrl_1 = cm_->get_loaded_controllers()[0];
ASSERT_EQ(ctrl_1.info.name, "ctrl_1");
ASSERT_EQ(ctrl_1.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
ASSERT_TRUE(ctrl_1.info.fallback_controllers_names.empty());
ASSERT_EQ(
ctrl_1.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);
}

// Try to spawn now the controller with fallback controllers inside the yaml
EXPECT_EQ(
call_spawner("ctrl_2 ctrl_3 -c test_controller_manager --load-only -p " + test_file_path), 0);

ASSERT_EQ(cm_->get_loaded_controllers().size(), 3ul);
{
auto ctrl_1 = cm_->get_loaded_controllers()[0];
ASSERT_EQ(ctrl_1.info.name, "ctrl_1");
ASSERT_EQ(ctrl_1.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
ASSERT_TRUE(ctrl_1.info.fallback_controllers_names.empty());
ASSERT_EQ(
ctrl_1.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);

auto ctrl_2 = cm_->get_loaded_controllers()[1];
ASSERT_EQ(ctrl_2.info.name, "ctrl_2");
ASSERT_EQ(ctrl_2.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
ASSERT_THAT(
ctrl_2.info.fallback_controllers_names, testing::ElementsAre("ctrl_6", "ctrl_7", "ctrl_8"));
ASSERT_EQ(
ctrl_2.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);

auto ctrl_3 = cm_->get_loaded_controllers()[2];
ASSERT_EQ(ctrl_3.info.name, "ctrl_3");
ASSERT_EQ(ctrl_3.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
ASSERT_THAT(ctrl_3.info.fallback_controllers_names, testing::ElementsAre("ctrl_9"));
ASSERT_EQ(
ctrl_3.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);
}
}

>>>>>>> 9e57adf (Fix unload of controllers when spawned with `--unload-on-kill` (#1717))
TEST_F(TestLoadController, spawner_with_many_controllers)
{
std::stringstream ss;