diff --git a/nao_lola_client/CMakeLists.txt b/nao_lola_client/CMakeLists.txt
index 88de231..0aa921e 100644
--- a/nao_lola_client/CMakeLists.txt
+++ b/nao_lola_client/CMakeLists.txt
@@ -18,10 +18,17 @@ include_directories(
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
+find_package(rclcpp_components REQUIRED)
find_package(nao_lola_sensor_msgs REQUIRED)
find_package(nao_lola_command_msgs REQUIRED)
find_package(Boost COMPONENTS system program_options filesystem REQUIRED)
+set(THIS_PACKAGE_INCLUDE_DEPENDS
+ rclcpp
+ rclcpp_components
+ nao_lola_sensor_msgs
+ nao_lola_command_msgs)
+
# build msgpack_parser_lib
add_library(msgpack_parser_lib SHARED
src/msgpack_parser.cpp)
@@ -40,15 +47,21 @@ ament_target_dependencies(msgpack_packer_lib
nao_lola_command_msgs
Boost)
-# build nao_lola_client
-add_executable(nao_lola_client
- src/nao_lola_client_node.cpp
+# build nao_lola_client_node
+add_library(nao_lola_client_node SHARED
src/nao_lola_client.cpp
src/connection.cpp)
-target_link_libraries(nao_lola_client
+target_link_libraries(nao_lola_client_node
msgpack_parser_lib
msgpack_packer_lib)
+ament_target_dependencies(nao_lola_client_node rclcpp_components)
+
+rclcpp_components_register_node(nao_lola_client_node
+ PLUGIN "NaoLolaClient"
+ EXECUTABLE nao_lola_client)
+ament_export_targets(export_nao_lola_client HAS_LIBRARY_TARGET)
+ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
# Install
install(TARGETS
@@ -60,7 +73,7 @@ install(DIRECTORY include/
)
install(
- TARGETS msgpack_parser_lib msgpack_packer_lib
+ TARGETS msgpack_parser_lib msgpack_packer_lib nao_lola_client_node
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
diff --git a/nao_lola_client/include/nao_lola_client/nao_lola_client.hpp b/nao_lola_client/include/nao_lola_client/nao_lola_client.hpp
index b065189..b10773d 100644
--- a/nao_lola_client/include/nao_lola_client/nao_lola_client.hpp
+++ b/nao_lola_client/include/nao_lola_client/nao_lola_client.hpp
@@ -50,7 +50,7 @@
class NaoLolaClient : public rclcpp::Node
{
public:
- NaoLolaClient();
+ explicit NaoLolaClient(const rclcpp::NodeOptions & options = rclcpp::NodeOptions{});
virtual ~NaoLolaClient() {}
private:
diff --git a/nao_lola_client/package.xml b/nao_lola_client/package.xml
index 1e2887b..32f0d64 100644
--- a/nao_lola_client/package.xml
+++ b/nao_lola_client/package.xml
@@ -14,6 +14,7 @@
ament_cmake_gtest
rclcpp
+ rclcpp_components
nao_lola_command_msgs
nao_lola_sensor_msgs
boost
diff --git a/nao_lola_client/src/nao_lola_client.cpp b/nao_lola_client/src/nao_lola_client.cpp
index 33fe6f0..7276304 100644
--- a/nao_lola_client/src/nao_lola_client.cpp
+++ b/nao_lola_client/src/nao_lola_client.cpp
@@ -17,8 +17,8 @@
#include "nao_lola_client/nao_lola_client.hpp"
#include "nao_lola_client/msgpack_parser.hpp"
-NaoLolaClient::NaoLolaClient()
-: Node("NaoLolaClient")
+NaoLolaClient::NaoLolaClient(const rclcpp::NodeOptions & options)
+: Node("NaoLolaClient", options)
{
createPublishers();
createSubscriptions();
@@ -188,3 +188,6 @@ void NaoLolaClient::createSubscriptions()
);
RCLCPP_DEBUG(get_logger(), "Finished creating subscriptions");
}
+
+#include "rclcpp_components/register_node_macro.hpp"
+RCLCPP_COMPONENTS_REGISTER_NODE(NaoLolaClient)
diff --git a/nao_lola_client/src/nao_lola_client_node.cpp b/nao_lola_client/src/nao_lola_client_node.cpp
deleted file mode 100644
index e12e15d..0000000
--- a/nao_lola_client/src/nao_lola_client_node.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2021 Kenji Brameld
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include
-#include "rclcpp/rclcpp.hpp"
-#include "nao_lola_client/nao_lola_client.hpp"
-
-int main(int argc, char * argv[])
-{
- rclcpp::init(argc, argv);
- rclcpp::spin(std::make_shared());
- rclcpp::shutdown();
- return 0;
-}