From ac926c4686446e129d7fedfa974de1235e1f2fb8 Mon Sep 17 00:00:00 2001 From: parthc Date: Tue, 12 Jun 2018 13:17:25 -0400 Subject: [PATCH 1/5] rclcpp 0.4.0 changes --- .../include/controller_interface/controller_interface.hpp | 4 ++-- controller_interface/src/controller_interface.cpp | 2 +- .../include/controller_manager/controller_manager.hpp | 2 +- controller_manager/src/controller_manager.cpp | 2 +- controller_manager/test/test_controller_manager.cpp | 2 +- controller_manager/test/test_load_controller.cpp | 2 +- .../include/controller_parameter_server/parameter_server.hpp | 4 ++-- controller_parameter_server/src/parameter_server.cpp | 4 ++-- controller_parameter_server/test/test_parameter_server.cpp | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/controller_interface/include/controller_interface/controller_interface.hpp b/controller_interface/include/controller_interface/controller_interface.hpp index 93c342173f..0f115ecfe6 100644 --- a/controller_interface/include/controller_interface/controller_interface.hpp +++ b/controller_interface/include/controller_interface/controller_interface.hpp @@ -61,10 +61,10 @@ class ControllerInterface : public rclcpp_lifecycle::node_interfaces::LifecycleN protected: std::weak_ptr robot_hardware_; std::shared_ptr lifecycle_node_; - std::shared_ptr parameters_client_; + std::shared_ptr parameters_client_; private: - std::shared_ptr parameter_client_node_; + std::shared_ptr parameter_client_node_; }; } // namespace controller_interface diff --git a/controller_interface/src/controller_interface.cpp b/controller_interface/src/controller_interface.cpp index ab59c37bd6..99aed066db 100644 --- a/controller_interface/src/controller_interface.cpp +++ b/controller_interface/src/controller_interface.cpp @@ -47,7 +47,7 @@ ControllerInterface::init( std::bind(&ControllerInterface::on_error, this, std::placeholders::_1)); std::string remote_controller_parameter_server = "controller_parameter_server"; - parameters_client_ = std::make_shared( + parameters_client_ = std::make_shared( lifecycle_node_->get_node_base_interface(), lifecycle_node_->get_node_topics_interface(), lifecycle_node_->get_node_graph_interface(), diff --git a/controller_manager/include/controller_manager/controller_manager.hpp b/controller_manager/include/controller_manager/controller_manager.hpp index 420bfc6a94..247c6aca4d 100644 --- a/controller_manager/include/controller_manager/controller_manager.hpp +++ b/controller_manager/include/controller_manager/controller_manager.hpp @@ -37,7 +37,7 @@ class ClassLoader; namespace controller_manager { -class ControllerManager : public rclcpp::node::Node +class ControllerManager : public rclcpp::Node { public: CONTROLLER_MANAGER_PUBLIC diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index bf04d04df6..e01e274c49 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -130,7 +130,7 @@ ControllerManager::ControllerManager( std::shared_ptr hw, std::shared_ptr executor, const std::string & manager_node_name) -: rclcpp::node::Node(manager_node_name), +: rclcpp::Node(manager_node_name), hw_(hw), executor_(executor) {} diff --git a/controller_manager/test/test_controller_manager.cpp b/controller_manager/test/test_controller_manager.cpp index b4bd0c0bf0..eda7ef05e2 100644 --- a/controller_manager/test/test_controller_manager.cpp +++ b/controller_manager/test/test_controller_manager.cpp @@ -31,7 +31,7 @@ class TestControllerManager : public ::testing::Test public: static void SetUpTestCase() { - rclcpp::utilities::init(0, nullptr); + rclcpp::init(0, nullptr); } void SetUp() diff --git a/controller_manager/test/test_load_controller.cpp b/controller_manager/test/test_load_controller.cpp index b57f0a657b..80e3ce0ee2 100644 --- a/controller_manager/test/test_load_controller.cpp +++ b/controller_manager/test/test_load_controller.cpp @@ -31,7 +31,7 @@ class TestControllerManager : public ::testing::Test public: static void SetUpTestCase() { - rclcpp::utilities::init(0, nullptr); + rclcpp::init(0, nullptr); } void SetUp() diff --git a/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp b/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp index da8395a06e..3d0a8527bf 100644 --- a/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp +++ b/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp @@ -25,7 +25,7 @@ namespace controller_parameter_server { -class ParameterServer : public rclcpp::node::Node +class ParameterServer : public rclcpp::Node { public: CONTROLLER_PARAMETER_SERVER_PUBLIC @@ -48,7 +48,7 @@ class ParameterServer : public rclcpp::node::Node load_parameters(const std::string & key, const std::string & value); private: - std::shared_ptr parameter_service_; + std::shared_ptr parameter_service_; }; } // namespace controller_parameter_server diff --git a/controller_parameter_server/src/parameter_server.cpp b/controller_parameter_server/src/parameter_server.cpp index 529717f61f..ecd23cd287 100644 --- a/controller_parameter_server/src/parameter_server.cpp +++ b/controller_parameter_server/src/parameter_server.cpp @@ -22,14 +22,14 @@ namespace controller_parameter_server { ParameterServer::ParameterServer() -: rclcpp::node::Node("controller_parameter_server") +: rclcpp::Node("controller_parameter_server") {} void ParameterServer::init() { parameter_service_ = - std::make_shared(shared_from_this()); + std::make_shared(shared_from_this()); } void diff --git a/controller_parameter_server/test/test_parameter_server.cpp b/controller_parameter_server/test/test_parameter_server.cpp index 7d89f531fa..6aeb9656f8 100644 --- a/controller_parameter_server/test/test_parameter_server.cpp +++ b/controller_parameter_server/test/test_parameter_server.cpp @@ -84,9 +84,9 @@ TEST_F(TestControllerParameterServer, load_config_file) { ps->init(); ps->load_parameters(file_path); - auto client_node = std::make_shared("test_parameter_client_node"); + auto client_node = std::make_shared("test_parameter_client_node"); auto parameters_client = - std::make_shared(client_node, ps->get_name()); + std::make_shared(client_node, ps->get_name()); rclcpp::executors::MultiThreadedExecutor executor; executor.add_node(ps); From e90583046e8d5656078a25d211dd46817b95d558 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 18 Jun 2018 14:31:24 +0200 Subject: [PATCH 2/5] ParameterVariant -> Parameter --- controller_parameter_server/src/parameter_server.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/controller_parameter_server/src/parameter_server.cpp b/controller_parameter_server/src/parameter_server.cpp index ecd23cd287..c24c47cae0 100644 --- a/controller_parameter_server/src/parameter_server.cpp +++ b/controller_parameter_server/src/parameter_server.cpp @@ -48,18 +48,14 @@ ParameterServer::load_parameters(const std::string & yaml_config_file) auto key_values = parser.get_key_value_pairs(); for (auto pair : key_values) { - this->set_parameters({rclcpp::parameter::ParameterVariant(pair.first, pair.second)}); + this->set_parameters({rclcpp::Parameter(pair.first, pair.second)}); } } void ParameterServer::load_parameters(const std::string & key, const std::string & value) { - if (!parameter_service_) { - throw std::runtime_error("parameter server is not initialized"); - } - - this->set_parameters({rclcpp::parameter::ParameterVariant(key, value)}); + this->set_parameters({rclcpp::Parameter(key, value)}); } } // namespace controller_parameter_server From 308ba7e31ad681eb41238437c37bb1f49c5dc2dd Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 18 Jun 2018 14:35:18 +0200 Subject: [PATCH 3/5] remove explicit parameter service --- .../controller_parameter_server/parameter_server.hpp | 7 ------- .../src/controller_parameter_server.cpp | 1 - controller_parameter_server/src/parameter_server.cpp | 11 ----------- .../test/test_parameter_server.cpp | 10 ---------- 4 files changed, 29 deletions(-) diff --git a/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp b/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp index 3d0a8527bf..fddb769257 100644 --- a/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp +++ b/controller_parameter_server/include/controller_parameter_server/parameter_server.hpp @@ -35,10 +35,6 @@ class ParameterServer : public rclcpp::Node virtual ~ParameterServer() = default; - CONTROLLER_PARAMETER_SERVER_PUBLIC - void - init(); - CONTROLLER_PARAMETER_SERVER_PUBLIC void load_parameters(const std::string & yaml_config_file); @@ -46,9 +42,6 @@ class ParameterServer : public rclcpp::Node CONTROLLER_PARAMETER_SERVER_PUBLIC void load_parameters(const std::string & key, const std::string & value); - -private: - std::shared_ptr parameter_service_; }; } // namespace controller_parameter_server diff --git a/controller_parameter_server/src/controller_parameter_server.cpp b/controller_parameter_server/src/controller_parameter_server.cpp index 7c4fdc825d..0dfe1b1694 100644 --- a/controller_parameter_server/src/controller_parameter_server.cpp +++ b/controller_parameter_server/src/controller_parameter_server.cpp @@ -34,7 +34,6 @@ int main(int argc, char ** argv) } auto ps = std::make_shared(); - ps->init(); ps->load_parameters(argv[1]); rclcpp::spin(ps); diff --git a/controller_parameter_server/src/parameter_server.cpp b/controller_parameter_server/src/parameter_server.cpp index c24c47cae0..3cf7f9907c 100644 --- a/controller_parameter_server/src/parameter_server.cpp +++ b/controller_parameter_server/src/parameter_server.cpp @@ -25,20 +25,9 @@ ParameterServer::ParameterServer() : rclcpp::Node("controller_parameter_server") {} -void -ParameterServer::init() -{ - parameter_service_ = - std::make_shared(shared_from_this()); -} - void ParameterServer::load_parameters(const std::string & yaml_config_file) { - if (!parameter_service_) { - throw std::runtime_error("parameter server is not initialized"); - } - if (yaml_config_file.empty()) { throw std::runtime_error("yaml config file path is empty"); } diff --git a/controller_parameter_server/test/test_parameter_server.cpp b/controller_parameter_server/test/test_parameter_server.cpp index 6aeb9656f8..d7cac5b8f9 100644 --- a/controller_parameter_server/test/test_parameter_server.cpp +++ b/controller_parameter_server/test/test_parameter_server.cpp @@ -38,17 +38,8 @@ class TestControllerParameterServer : public ::testing::Test } }; -TEST_F(TestControllerParameterServer, init) { - auto ps = std::make_shared(); - EXPECT_THROW(ps->load_parameters("key", "value"), std::runtime_error); - - ps->init(); - EXPECT_NO_THROW(ps->load_parameters("key", "value")); -} - TEST_F(TestControllerParameterServer, init_key_value) { auto ps = std::make_shared(); - ps->init(); std::map parameters = {{ @@ -81,7 +72,6 @@ TEST_F(TestControllerParameterServer, load_config_file) { std::string file_path = std::string(yaml_file); auto ps = std::make_shared(); - ps->init(); ps->load_parameters(file_path); auto client_node = std::make_shared("test_parameter_client_node"); From 2ad25996813412ec6c7d804a07977f7df8c4e544 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 18 Jun 2018 14:52:11 +0200 Subject: [PATCH 4/5] comply with new uncrustify --- .../test/test_parameter_server.cpp | 40 +++++++++---------- .../test/test_yaml_parser.cpp | 32 +++++++-------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/controller_parameter_server/test/test_parameter_server.cpp b/controller_parameter_server/test/test_parameter_server.cpp index d7cac5b8f9..ec4f358951 100644 --- a/controller_parameter_server/test/test_parameter_server.cpp +++ b/controller_parameter_server/test/test_parameter_server.cpp @@ -43,10 +43,10 @@ TEST_F(TestControllerParameterServer, init_key_value) { std::map parameters = {{ - {"test_controller.joints.joint1", "joint1"}, - {"test_controller.joints.joint2", "joint2"}, - {"test_controller.joints.joint3", "joint3"} - }}; + {"test_controller.joints.joint1", "joint1"}, + {"test_controller.joints.joint2", "joint2"}, + {"test_controller.joints.joint3", "joint3"} + }}; for (auto param : parameters) { ps->load_parameters(param.first, param.second); @@ -95,25 +95,25 @@ TEST_F(TestControllerParameterServer, load_config_file) { std::vector expected_keys = {{ - ".controller_name", - ".controller_list.0", - ".controller_list.1", - ".test_joint_controller.joints", - ".test_trajectory_controller.joints.0.joint1.name", - ".test_trajectory_controller.joints.1", - ".test_trajectory_controller.joints.2" - }}; + ".controller_name", + ".controller_list.0", + ".controller_list.1", + ".test_joint_controller.joints", + ".test_trajectory_controller.joints.0.joint1.name", + ".test_trajectory_controller.joints.1", + ".test_trajectory_controller.joints.2" + }}; std::vector expected_values = {{ - "my_controller", - "my_controller1", - "my_controller2", - "my_joint1", - "my_joint1", - "my_joint2", - "my_joint3" - }}; + "my_controller", + "my_controller1", + "my_controller2", + "my_joint1", + "my_joint1", + "my_joint2", + "my_joint3" + }}; auto parameter_future = parameters_client->get_parameters(expected_keys); diff --git a/controller_parameter_server/test/test_yaml_parser.cpp b/controller_parameter_server/test/test_yaml_parser.cpp index cc3b69c735..c7300ed110 100644 --- a/controller_parameter_server/test/test_yaml_parser.cpp +++ b/controller_parameter_server/test/test_yaml_parser.cpp @@ -47,25 +47,25 @@ TEST_F(TestYamlParser, init) { std::vector expected_keys = {{ - ".controller_name", - ".controller_list.0", - ".controller_list.1", - ".test_joint_controller.joints", - ".test_trajectory_controller.joints.0.joint1.name", - ".test_trajectory_controller.joints.1", - ".test_trajectory_controller.joints.2" - }}; + ".controller_name", + ".controller_list.0", + ".controller_list.1", + ".test_joint_controller.joints", + ".test_trajectory_controller.joints.0.joint1.name", + ".test_trajectory_controller.joints.1", + ".test_trajectory_controller.joints.2" + }}; std::vector expected_values = {{ - "my_controller", - "my_controller1", - "my_controller2", - "my_joint1", - "my_joint1", - "my_joint2", - "my_joint3" - }}; + "my_controller", + "my_controller1", + "my_controller2", + "my_joint1", + "my_joint1", + "my_joint2", + "my_joint3" + }}; if (expected_keys.size() != expected_values.size()) { FAIL(); From cb2239f05471e0b1c0e367e13897c0ca41e94438 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 18 Jun 2018 19:40:11 +0200 Subject: [PATCH 5/5] use ros2 class loader macros --- controller_manager/src/controller_manager.cpp | 2 +- controller_manager/test/test_controller/test_controller.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index e01e274c49..b8ff5f78f9 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -21,7 +21,7 @@ #include "ament_index_cpp/get_resource.hpp" #include "ament_index_cpp/get_resources.hpp" -#include "class_loader/class_loader.h" +#include "class_loader/class_loader.hpp" #include "controller_interface/controller_interface.hpp" diff --git a/controller_manager/test/test_controller/test_controller.cpp b/controller_manager/test/test_controller/test_controller.cpp index 59fc35fe5f..9dd2f96f4c 100644 --- a/controller_manager/test/test_controller/test_controller.cpp +++ b/controller_manager/test/test_controller/test_controller.cpp @@ -42,7 +42,7 @@ TestController::on_configure(const rclcpp_lifecycle::State & previous_state) } // namespace test_controller -#include "class_loader/class_loader_register_macro.h" +#include "class_loader/register_macro.hpp" CLASS_LOADER_REGISTER_CLASS( test_controller::TestController, controller_interface::ControllerInterface)