From 792c24d76a142d1c227cf5e9710c69f00d56f561 Mon Sep 17 00:00:00 2001 From: Victor Lopez <3469405+v-lopez@users.noreply.github.com> Date: Sat, 12 Dec 2020 09:37:33 +0100 Subject: [PATCH] Remove lifecycle node (#261) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove LifecycleNode from controller_interface * Handle error on transitions * Comment out unused arg instead of void cast * Add missing state include Co-authored-by: Denis Štogl --- .../controller_interface.hpp | 36 +++++- .../src/controller_interface.cpp | 116 +++++++++++++++--- controller_manager/src/controller_manager.cpp | 23 ++-- .../test/test_controller/test_controller.cpp | 13 +- .../test/test_controller/test_controller.hpp | 7 ++ .../test/test_controller_manager.cpp | 8 +- .../test/test_controller_manager_srvs.cpp | 44 +++---- .../test/test_load_controller.cpp | 36 +++--- 8 files changed, 196 insertions(+), 87 deletions(-) diff --git a/controller_interface/include/controller_interface/controller_interface.hpp b/controller_interface/include/controller_interface/controller_interface.hpp index f5e3131200..73291c681f 100644 --- a/controller_interface/include/controller_interface/controller_interface.hpp +++ b/controller_interface/include/controller_interface/controller_interface.hpp @@ -23,9 +23,10 @@ #include "hardware_interface/loaned_command_interface.hpp" #include "hardware_interface/loaned_state_interface.hpp" +#include "lifecycle_msgs/msg/state.hpp" #include "rclcpp/rclcpp.hpp" -#include "rclcpp_lifecycle/lifecycle_node.hpp" +#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp" namespace controller_interface { @@ -93,13 +94,40 @@ class ControllerInterface : public rclcpp_lifecycle::node_interfaces::LifecycleN update() = 0; CONTROLLER_INTERFACE_PUBLIC - std::shared_ptr - get_lifecycle_node(); + std::shared_ptr + get_node(); + + /** + * The methods below are a substitute to the LifecycleNode methods with the same name. + * We cannot use a LifecycleNode because it would expose change + * state services to the rest of the ROS system. + * Only the Controller Manager should have possibility to change state of s controller. + * + * Hopefully in the future we can use a LifecycleNode where we disable modifications from the outside. + */ + CONTROLLER_INTERFACE_PUBLIC + const rclcpp_lifecycle::State & configure(); + + CONTROLLER_INTERFACE_PUBLIC + const rclcpp_lifecycle::State & cleanup(); + + CONTROLLER_INTERFACE_PUBLIC + const rclcpp_lifecycle::State & deactivate(); + + CONTROLLER_INTERFACE_PUBLIC + const rclcpp_lifecycle::State & activate(); + + CONTROLLER_INTERFACE_PUBLIC + const rclcpp_lifecycle::State & shutdown(); + + CONTROLLER_INTERFACE_PUBLIC + const rclcpp_lifecycle::State & get_current_state() const; protected: std::vector command_interfaces_; std::vector state_interfaces_; - std::shared_ptr lifecycle_node_; + std::shared_ptr node_; + rclcpp_lifecycle::State lifecycle_state_; }; using ControllerInterfaceSharedPtr = std::shared_ptr; diff --git a/controller_interface/src/controller_interface.cpp b/controller_interface/src/controller_interface.cpp index 56ac4c178b..30e63b07fb 100644 --- a/controller_interface/src/controller_interface.cpp +++ b/controller_interface/src/controller_interface.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "controller_interface/controller_interface.hpp" +#include #include #include @@ -25,30 +26,105 @@ namespace controller_interface return_type ControllerInterface::init(const std::string & controller_name) { - lifecycle_node_ = std::make_shared( + node_ = std::make_shared( controller_name, rclcpp::NodeOptions().allow_undeclared_parameters(true). automatically_declare_parameters_from_overrides(true)); + return return_type::SUCCESS; +} - lifecycle_node_->register_on_configure( - std::bind(&ControllerInterface::on_configure, this, std::placeholders::_1)); - - lifecycle_node_->register_on_cleanup( - std::bind(&ControllerInterface::on_cleanup, this, std::placeholders::_1)); - - lifecycle_node_->register_on_activate( - std::bind(&ControllerInterface::on_activate, this, std::placeholders::_1)); - - lifecycle_node_->register_on_deactivate( - std::bind(&ControllerInterface::on_deactivate, this, std::placeholders::_1)); +const rclcpp_lifecycle::State & ControllerInterface::configure() +{ + switch (on_configure(lifecycle_state_)) { + case LifecycleNodeInterface::CallbackReturn::SUCCESS: + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, + "inactive"); + break; + case LifecycleNodeInterface::CallbackReturn::ERROR: + on_error(lifecycle_state_); + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED, "finalized"); + break; + case LifecycleNodeInterface::CallbackReturn::FAILURE: + break; + } + return lifecycle_state_; +} - lifecycle_node_->register_on_shutdown( - std::bind(&ControllerInterface::on_shutdown, this, std::placeholders::_1)); +const rclcpp_lifecycle::State & ControllerInterface::cleanup() +{ + switch (on_cleanup(lifecycle_state_)) { + case LifecycleNodeInterface::CallbackReturn::SUCCESS: + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, "unconfigured"); + break; + case LifecycleNodeInterface::CallbackReturn::ERROR: + on_error(lifecycle_state_); + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED, "finalized"); + break; + case LifecycleNodeInterface::CallbackReturn::FAILURE: + break; + } + return lifecycle_state_; +} +const rclcpp_lifecycle::State & ControllerInterface::deactivate() +{ + switch (on_deactivate(lifecycle_state_)) { + case LifecycleNodeInterface::CallbackReturn::SUCCESS: + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, "inactive"); + break; + case LifecycleNodeInterface::CallbackReturn::ERROR: + on_error(lifecycle_state_); + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED, "finalized"); + break; + case LifecycleNodeInterface::CallbackReturn::FAILURE: + break; + } + return lifecycle_state_; +} +const rclcpp_lifecycle::State & ControllerInterface::activate() +{ + switch (on_activate(lifecycle_state_)) { + case LifecycleNodeInterface::CallbackReturn::SUCCESS: + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, "active"); + break; + case LifecycleNodeInterface::CallbackReturn::ERROR: + on_error(lifecycle_state_); + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED, "finalized"); + break; + case LifecycleNodeInterface::CallbackReturn::FAILURE: + break; + } + return lifecycle_state_; +} - lifecycle_node_->register_on_error( - std::bind(&ControllerInterface::on_error, this, std::placeholders::_1)); +const rclcpp_lifecycle::State & ControllerInterface::shutdown() +{ + switch (on_activate(lifecycle_state_)) { + case LifecycleNodeInterface::CallbackReturn::SUCCESS: + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED, "finalized"); + break; + case LifecycleNodeInterface::CallbackReturn::ERROR: + on_error(lifecycle_state_); + lifecycle_state_ = rclcpp_lifecycle::State( + lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED, "finalized"); + break; + case LifecycleNodeInterface::CallbackReturn::FAILURE: + break; + } + return lifecycle_state_; +} - return return_type::SUCCESS; +const rclcpp_lifecycle::State & ControllerInterface::get_current_state() const +{ + return lifecycle_state_; } void ControllerInterface::assign_interfaces( @@ -65,10 +141,10 @@ void ControllerInterface::release_interfaces() state_interfaces_.clear(); } -std::shared_ptr -ControllerInterface::get_lifecycle_node() +std::shared_ptr +ControllerInterface::get_node() { - return lifecycle_node_; + return node_; } } // namespace controller_interface diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 3d24f99ddb..b99629db5b 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -36,7 +36,7 @@ static constexpr const char * kControllerInterface = "controller_interface::Cont inline bool is_controller_running(controller_interface::ControllerInterface & controller) { - return controller.get_lifecycle_node()->get_current_state().id() == + return controller.get_current_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE; } @@ -220,8 +220,8 @@ controller_interface::return_type ControllerManager::unload_controller( } RCLCPP_DEBUG(get_logger(), "Cleanup controller"); - controller.c->get_lifecycle_node()->cleanup(); - executor_->remove_node(controller.c->get_lifecycle_node()->get_node_base_interface()); + controller.c->cleanup(); + executor_->remove_node(controller.c->get_node()); to.erase(found_it); // Destroys the old controllers list when the realtime thread is finished with it. @@ -494,13 +494,8 @@ ControllerManager::add_controller_impl( } controller.c->init(controller.info.name); - - // TODO(v-lopez) this should only be done if controller_manager is configured. - // Probably the whole load_controller part should fail if the controller_manager - // is not configured, should it implement a LifecycleNodeInterface - // https://github.com/ros-controls/ros2_control/issues/152 - controller.c->get_lifecycle_node()->configure(); - executor_->add_node(controller.c->get_lifecycle_node()->get_node_base_interface()); + controller.c->configure(); + executor_->add_node(controller.c->get_node()); to.emplace_back(controller); // Destroys the old controllers list when the realtime thread is finished with it. @@ -554,7 +549,7 @@ void ControllerManager::stop_controllers() } auto controller = found_it->c; if (is_controller_running(*controller)) { - const auto new_state = controller->get_lifecycle_node()->deactivate(); + const auto new_state = controller->deactivate(); if (new_state.id() != lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE) { RCLCPP_ERROR( get_logger(), @@ -656,12 +651,12 @@ void ControllerManager::start_controllers() } controller->assign_interfaces(std::move(command_loans), std::move(state_loans)); - const auto new_state = controller->get_lifecycle_node()->activate(); + const auto new_state = controller->activate(); if (new_state.id() != lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE) { RCLCPP_ERROR( get_logger(), "After activating, controller %s is in state %s, expected Active", - controller->get_lifecycle_node()->get_name(), + controller->get_node()->get_name(), new_state.label().c_str()); } } @@ -734,7 +729,7 @@ void ControllerManager::list_controllers_srv_cb( controller_manager_msgs::msg::ControllerState & cs = response->controller[i]; cs.name = controllers[i].info.name; cs.type = controllers[i].info.type; - cs.state = controllers[i].c->get_lifecycle_node()->get_current_state().label(); + cs.state = controllers[i].c->get_current_state().label(); #ifdef TODO_IMPLEMENT_RESOURCE_CHECKING cs.claimed_resources.clear(); diff --git a/controller_manager/test/test_controller/test_controller.cpp b/controller_manager/test/test_controller/test_controller.cpp index 22113d66ea..5930ecbdb5 100644 --- a/controller_manager/test/test_controller/test_controller.cpp +++ b/controller_manager/test/test_controller/test_controller.cpp @@ -34,9 +34,18 @@ TestController::update() } rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn -TestController::on_configure(const rclcpp_lifecycle::State & previous_state) +TestController::on_configure(const rclcpp_lifecycle::State & /*previous_state*/) { - (void) previous_state; + return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; +} + +rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn +TestController::on_cleanup( + const rclcpp_lifecycle::State & /*previous_state*/) +{ + if (cleanup_calls) { + (*cleanup_calls)++; + } return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; } diff --git a/controller_manager/test/test_controller/test_controller.hpp b/controller_manager/test/test_controller/test_controller.hpp index 697f45aae5..f5230c506f 100644 --- a/controller_manager/test/test_controller/test_controller.hpp +++ b/controller_manager/test/test_controller/test_controller.hpp @@ -59,7 +59,14 @@ class TestController : public controller_interface::ControllerInterface rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override; + CONTROLLER_MANAGER_PUBLIC + rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn + on_cleanup(const rclcpp_lifecycle::State & previous_state) override; + size_t internal_counter = 0; + // Variable where we store when cleanup was called, pointer because the controller + // is usually destroyed after cleanup + size_t * cleanup_calls = nullptr; }; } // namespace test_controller diff --git a/controller_manager/test/test_controller_manager.cpp b/controller_manager/test/test_controller_manager.cpp index cd247f01fd..ab027d7e5e 100644 --- a/controller_manager/test/test_controller_manager.cpp +++ b/controller_manager/test/test_controller_manager.cpp @@ -45,7 +45,7 @@ TEST_F(TestControllerManager, controller_lifecycle) { EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); EXPECT_EQ(controller_interface::return_type::SUCCESS, cm_->update()); EXPECT_EQ(0u, test_controller->internal_counter) << "Controller is not started"; @@ -72,7 +72,7 @@ TEST_F(TestControllerManager, controller_lifecycle) { ); EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); EXPECT_EQ(controller_interface::return_type::SUCCESS, cm_->update()); EXPECT_EQ(1u, test_controller->internal_counter); @@ -103,7 +103,7 @@ TEST_F(TestControllerManager, controller_lifecycle) { EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); auto unload_future = std::async( std::launch::async, &controller_manager::ControllerManager::unload_controller, cm_, @@ -121,6 +121,6 @@ TEST_F(TestControllerManager, controller_lifecycle) { EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); EXPECT_EQ(1, test_controller.use_count()); } diff --git a/controller_manager/test/test_controller_manager_srvs.cpp b/controller_manager/test/test_controller_manager_srvs.cpp index e9849bdb73..e86806ef71 100644 --- a/controller_manager/test/test_controller_manager_srvs.cpp +++ b/controller_manager/test/test_controller_manager_srvs.cpp @@ -189,25 +189,17 @@ TEST_F(TestControllerManagerSrvs, reload_controller_libraries_srv) { auto request = std::make_shared(); - // Create a lambda to store the cleanup state change - bool cleanup_called = false; - auto set_cleanup_called = - [&]( - const rclcpp_lifecycle::State &) - { - cleanup_called = true; - return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; - }; - // Reload with no controllers running request->force_kill = false; auto result = call_service_and_wait(*client, request, srv_executor); ASSERT_TRUE(result->ok); // Add a controller, but stopped - auto test_controller = cm_->load_controller( - test_controller::TEST_CONTROLLER_NAME, - test_controller::TEST_CONTROLLER_CLASS_NAME); + std::shared_ptr test_controller = + std::dynamic_pointer_cast( + cm_->load_controller( + test_controller::TEST_CONTROLLER_NAME, + test_controller::TEST_CONTROLLER_CLASS_NAME)); // weak_ptr so the only controller shared_ptr instance is owned by the controller_manager and // can be completely destroyed before reloading the library @@ -215,27 +207,29 @@ TEST_F(TestControllerManagerSrvs, reload_controller_libraries_srv) { ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); ASSERT_GT( test_controller.use_count(), 1) << "Controller manager should have have a copy of this shared ptr"; - cleanup_called = false; - test_controller->get_lifecycle_node()->register_on_cleanup(set_cleanup_called); + size_t cleanup_calls = 0; + test_controller->cleanup_calls = &cleanup_calls; test_controller.reset(); // destroy our copy of the controller request->force_kill = false; result = call_service_and_wait(*client, request, srv_executor, true); ASSERT_TRUE(result->ok); - ASSERT_TRUE(cleanup_called); + ASSERT_EQ(cleanup_calls, 1u); ASSERT_EQ( test_controller.use_count(), 0) << "No more references to the controller after reloading."; test_controller.reset(); - test_controller = cm_->load_controller( - test_controller::TEST_CONTROLLER_NAME, - test_controller::TEST_CONTROLLER_CLASS_NAME); + test_controller = + std::dynamic_pointer_cast( + cm_->load_controller( + test_controller::TEST_CONTROLLER_NAME, + test_controller::TEST_CONTROLLER_CLASS_NAME)); test_controller_weak = test_controller; // Start Controller cm_->switch_controller( @@ -244,7 +238,7 @@ TEST_F(TestControllerManagerSrvs, reload_controller_libraries_srv) { rclcpp::Duration(0, 0)); ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); // Failed reload due to active controller request->force_kill = false; @@ -252,15 +246,15 @@ TEST_F(TestControllerManagerSrvs, reload_controller_libraries_srv) { ASSERT_FALSE(result->ok) << "Cannot reload if controllers are running"; ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, - test_controller->get_lifecycle_node()->get_current_state().id()); + test_controller->get_current_state().id()); ASSERT_GT( test_controller.use_count(), 1) << "Controller manager should still have have a copy of " "this shared ptr, no unloading was performed"; - cleanup_called = false; - test_controller->get_lifecycle_node()->register_on_cleanup(set_cleanup_called); + cleanup_calls = 0; + test_controller->cleanup_calls = &cleanup_calls; test_controller.reset(); // destroy our copy of the controller // Force stop active controller @@ -271,7 +265,7 @@ TEST_F(TestControllerManagerSrvs, reload_controller_libraries_srv) { ASSERT_EQ( test_controller_weak.use_count(), 0) << "No more references to the controller after reloading."; - ASSERT_TRUE(cleanup_called) << + ASSERT_EQ(cleanup_calls, 1u) << "Controller should have been stopped and cleaned up with force_kill = true"; } diff --git a/controller_manager/test/test_load_controller.cpp b/controller_manager/test/test_load_controller.cpp index a5a3d1d486..cc7ff177b5 100644 --- a/controller_manager/test/test_load_controller.cpp +++ b/controller_manager/test/test_load_controller.cpp @@ -51,10 +51,10 @@ TEST_F(TestLoadController, load1_known_controller) controller_manager::ControllerSpec abstract_test_controller = cm_->get_loaded_controllers()[0]; - auto lifecycle_node = abstract_test_controller.c->get_lifecycle_node(); + auto node = abstract_test_controller.c->get_node(); EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller.c->get_current_state().id()); } TEST_F(TestLoadController, load2_known_controller) @@ -68,10 +68,10 @@ TEST_F(TestLoadController, load2_known_controller) controller_manager::ControllerSpec abstract_test_controller1 = cm_->get_loaded_controllers()[0]; EXPECT_STREQ( - controller_name1.c_str(), abstract_test_controller1.c->get_lifecycle_node()->get_name()); + controller_name1.c_str(), abstract_test_controller1.c->get_node()->get_name()); EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); // load the same controller again with a different name std::string controller_name2 = "test_controller2"; @@ -80,12 +80,12 @@ TEST_F(TestLoadController, load2_known_controller) controller_manager::ControllerSpec abstract_test_controller2 = cm_->get_loaded_controllers()[1]; EXPECT_STREQ( - controller_name2.c_str(), abstract_test_controller2.c->get_lifecycle_node()->get_name()); + controller_name2.c_str(), abstract_test_controller2.c->get_node()->get_name()); EXPECT_STREQ( controller_name2.c_str(), abstract_test_controller2.info.name.c_str()); EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller2.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller2.c->get_current_state().id()); } TEST_F(TestLoadController, update) @@ -98,10 +98,10 @@ TEST_F(TestLoadController, update) controller_manager::ControllerSpec abstract_test_controller = cm_->get_loaded_controllers()[0]; - auto lifecycle_node = abstract_test_controller.c->get_lifecycle_node(); + auto node = abstract_test_controller.c->get_node(); EXPECT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller.c->get_current_state().id()); } TEST_F(TestLoadController, switch_controller_empty) @@ -209,7 +209,7 @@ TEST_F(TestLoadController, switch_controller) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); { // Test stopping an stopped controller std::vector start_controllers = {}; @@ -275,7 +275,7 @@ TEST_F(TestLoadController, switch_controller) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); // Stop controller start_controllers = {}; @@ -301,7 +301,7 @@ TEST_F(TestLoadController, switch_controller) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); } } @@ -322,10 +322,10 @@ TEST_F(TestLoadController, switch_multiple_controllers) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller2.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller2.c->get_current_state().id()); // Only testing with STRICT now for simplicity { // Test starting an stopped controller, and stopping afterwards @@ -352,10 +352,10 @@ TEST_F(TestLoadController, switch_multiple_controllers) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller2.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller2.c->get_current_state().id()); // Stop controller 1, start controller 2 start_controllers = {controller_name2}; @@ -381,10 +381,10 @@ TEST_F(TestLoadController, switch_multiple_controllers) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller1.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller1.c->get_current_state().id()); ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE, - abstract_test_controller2.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller2.c->get_current_state().id()); start_controllers = {}; stop_controllers = {controller_name2}; @@ -409,6 +409,6 @@ TEST_F(TestLoadController, switch_multiple_controllers) ASSERT_EQ( lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, - abstract_test_controller2.c->get_lifecycle_node()->get_current_state().id()); + abstract_test_controller2.c->get_current_state().id()); } }