From a2015e41ebcf21f76534904b53f88b77485e73d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Tue, 29 Oct 2024 06:23:39 +0100 Subject: [PATCH 1/5] Add name to CognitiveModule constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Martín Rico --- cs4home_core/include/cs4home_core/CognitiveModule.hpp | 5 ++++- cs4home_core/src/cs4home_core/CognitiveModule.cpp | 7 +++++-- cs4home_core/test/cognitive_module_test.cpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cs4home_core/include/cs4home_core/CognitiveModule.hpp b/cs4home_core/include/cs4home_core/CognitiveModule.hpp index c54173d..8d2efb4 100644 --- a/cs4home_core/include/cs4home_core/CognitiveModule.hpp +++ b/cs4home_core/include/cs4home_core/CognitiveModule.hpp @@ -41,7 +41,9 @@ class CognitiveModule : public rclcpp_lifecycle::LifecycleNode using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; - explicit CognitiveModule(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); + explicit CognitiveModule( + const std::string & name, + const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); CallbackReturnT on_configure(const rclcpp_lifecycle::State & state); CallbackReturnT on_activate(const rclcpp_lifecycle::State & state); @@ -57,6 +59,7 @@ class CognitiveModule : public rclcpp_lifecycle::LifecycleNode Meta::SharedPtr meta_; Coupling::SharedPtr coupling_; + std::string name_; std::string core_name_; std::string afferent_name_; std::string efferent_name_; diff --git a/cs4home_core/src/cs4home_core/CognitiveModule.cpp b/cs4home_core/src/cs4home_core/CognitiveModule.cpp index 21d7306..3288eda 100644 --- a/cs4home_core/src/cs4home_core/CognitiveModule.cpp +++ b/cs4home_core/src/cs4home_core/CognitiveModule.cpp @@ -17,8 +17,11 @@ namespace cs4home_core { -CognitiveModule::CognitiveModule(const rclcpp::NodeOptions & options) -: LifecycleNode("cognitive_module", options) +CognitiveModule::CognitiveModule( + const std::string & name, + const rclcpp::NodeOptions & options) +: LifecycleNode(name, options), + name_(name) { declare_parameter("core", core_name_); declare_parameter("afferent", afferent_name_); diff --git a/cs4home_core/test/cognitive_module_test.cpp b/cs4home_core/test/cognitive_module_test.cpp index 9c918f7..0fe27be 100644 --- a/cs4home_core/test/cognitive_module_test.cpp +++ b/cs4home_core/test/cognitive_module_test.cpp @@ -316,9 +316,9 @@ TEST(cognitive_module_test, startup_simple) rclcpp::NodeOptions options; options.arguments( - {"--ros-args", "-r", "__node:=cognitive_module_1", "--params-file", config_file}); + {"--ros-args", "--params-file", config_file}); - auto cm1 = cs4home_core::CognitiveModule::make_shared(options); + auto cm1 = cs4home_core::CognitiveModule::make_shared("cognitive_module_1", options); ASSERT_EQ(std::string(cm1->get_name()), "cognitive_module_1"); auto params = cm1->list_parameters({}, 0); From 98f4df0af0ea56ae3424ed972eba922d395f0ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Tue, 29 Oct 2024 06:36:56 +0100 Subject: [PATCH 2/5] Set CI to 24.04 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Martín Rico --- .github/workflows/rolling.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rolling.yaml b/.github/workflows/rolling.yaml index d7e7645..aab2716 100644 --- a/.github/workflows/rolling.yaml +++ b/.github/workflows/rolling.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] fail-fast: false steps: - uses: actions/checkout@v2 From 2e530edb1b3292e5b32204b30f95c1ab55dfd162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Tue, 29 Oct 2024 06:37:21 +0100 Subject: [PATCH 3/5] Linting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Martín Rico --- cs4home_core/src/cs4home_core/CognitiveModule.cpp | 12 ++++++------ cs4home_core/test/ImageFilter.cpp | 2 +- cs4home_core/test/ImageFilterCB.cpp | 2 +- cs4home_core/test/SimpleImageInput.cpp | 6 +++--- cs4home_core/test/cognitive_module_test.cpp | 11 ++++++----- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cs4home_core/src/cs4home_core/CognitiveModule.cpp b/cs4home_core/src/cs4home_core/CognitiveModule.cpp index 3288eda..703e188 100644 --- a/cs4home_core/src/cs4home_core/CognitiveModule.cpp +++ b/cs4home_core/src/cs4home_core/CognitiveModule.cpp @@ -48,8 +48,8 @@ CallbackReturnT CognitiveModule::on_configure(const rclcpp_lifecycle::State & st get_parameter("efferent", efferent_name_); std::string error_efferent; - std::tie(efferent_, error_efferent) = load_component(efferent_name_, - shared_from_this()); + std::tie(efferent_, error_efferent) = load_component( + efferent_name_, shared_from_this()); if (efferent_ == nullptr || !efferent_->configure()) { RCLCPP_ERROR( get_logger(), "Error configuring efferent at %s with name %s: %s", @@ -59,8 +59,8 @@ CallbackReturnT CognitiveModule::on_configure(const rclcpp_lifecycle::State & st get_parameter("afferent", afferent_name_); std::string error_afferent; - std::tie(afferent_, error_afferent) = load_component(afferent_name_, - shared_from_this()); + std::tie(afferent_, error_afferent) = load_component( + afferent_name_, shared_from_this()); if (afferent_ == nullptr || !afferent_->configure()) { RCLCPP_ERROR( get_logger(), "Error configuring afferent at %s with name %s: %s", @@ -83,8 +83,8 @@ CallbackReturnT CognitiveModule::on_configure(const rclcpp_lifecycle::State & st get_parameter("coupling", coupling_name_); std::string error_coupling; - std::tie(coupling_, error_coupling) = load_component(coupling_name_, - shared_from_this()); + std::tie(coupling_, error_coupling) = load_component( + coupling_name_, shared_from_this()); if (coupling_ == nullptr || !coupling_->configure()) { RCLCPP_ERROR( get_logger(), "Error configuring efferent at %s with name %s: %s", diff --git a/cs4home_core/test/ImageFilter.cpp b/cs4home_core/test/ImageFilter.cpp index 4d80ba9..6ed7e4d 100644 --- a/cs4home_core/test/ImageFilter.cpp +++ b/cs4home_core/test/ImageFilter.cpp @@ -29,7 +29,7 @@ class ImageFilter : public cs4home_core::Core public: RCLCPP_SMART_PTR_DEFINITIONS(ImageFilter) - explicit ImageFilter(rclcpp_lifecycle::LifecycleNode::SharedPtr parent) + explicit ImageFilter(rclcpp_lifecycle::LifecycleNode::SharedPtr parent) : Core(parent) { RCLCPP_DEBUG(parent_->get_logger(), "Core created: [ImageFilter]"); diff --git a/cs4home_core/test/ImageFilterCB.cpp b/cs4home_core/test/ImageFilterCB.cpp index 20f0451..0e0353f 100644 --- a/cs4home_core/test/ImageFilterCB.cpp +++ b/cs4home_core/test/ImageFilterCB.cpp @@ -29,7 +29,7 @@ class ImageFilterCB : public cs4home_core::Core public: RCLCPP_SMART_PTR_DEFINITIONS(ImageFilterCB) - explicit ImageFilterCB(rclcpp_lifecycle::LifecycleNode::SharedPtr parent) + explicit ImageFilterCB(rclcpp_lifecycle::LifecycleNode::SharedPtr parent) : Core(parent) { RCLCPP_DEBUG(parent_->get_logger(), "Core created: [ImageFilterCB]"); diff --git a/cs4home_core/test/SimpleImageInput.cpp b/cs4home_core/test/SimpleImageInput.cpp index 80bec94..f7107cc 100644 --- a/cs4home_core/test/SimpleImageInput.cpp +++ b/cs4home_core/test/SimpleImageInput.cpp @@ -39,9 +39,9 @@ class SimpleImageInput : public cs4home_core::Afferent std::string param_name = "simple_image_input.topics"; parent_->get_parameter(param_name, input_topic_names_); - RCLCPP_DEBUG(parent_->get_logger(), "[SimpleImageInput] Configuring %zu inputs [%s]", - input_topic_names_.size(), - param_name.c_str()); + RCLCPP_DEBUG( + parent_->get_logger(), "[SimpleImageInput] Configuring %zu inputs [%s]", + input_topic_names_.size(), param_name.c_str()); for (size_t i = 0; i < input_topic_names_.size(); i++) { if (create_subscriber(input_topic_names_[i], "sensor_msgs/msg/Image")) { diff --git a/cs4home_core/test/cognitive_module_test.cpp b/cs4home_core/test/cognitive_module_test.cpp index 0fe27be..5fc5e93 100644 --- a/cs4home_core/test/cognitive_module_test.cpp +++ b/cs4home_core/test/cognitive_module_test.cpp @@ -109,7 +109,8 @@ TEST(cognitive_module_test, afferent_on_subscription) afferent->set_mode(cs4home_core::Afferent::CALLBACK); ASSERT_EQ(afferent->get_mode(), cs4home_core::Afferent::ONDEMAND); - afferent->set_mode(cs4home_core::Afferent::CALLBACK, + afferent->set_mode( + cs4home_core::Afferent::CALLBACK, [&images](std::unique_ptr msg) { images.push_back(std::move(msg)); } @@ -150,7 +151,7 @@ TEST(cognitive_module_test, efferent) std::vector images; auto sub = sub_node->create_subscription( - "/image", 100, [&images] (sensor_msgs::msg::Image msg) { + "/image", 100, [&images](sensor_msgs::msg::Image msg) { images.push_back(msg); }); @@ -196,7 +197,7 @@ TEST(cognitive_module_test, core) std::vector images; auto sub = sub_node->create_subscription( - "/out_image", 100, [&images] (sensor_msgs::msg::Image msg) { + "/out_image", 100, [&images](sensor_msgs::msg::Image msg) { images.push_back(msg); }); @@ -257,7 +258,7 @@ TEST(cognitive_module_test, core_cb) std::vector images; auto sub = sub_node->create_subscription( - "/out_image", 100, [&images] (sensor_msgs::msg::Image msg) { + "/out_image", 100, [&images](sensor_msgs::msg::Image msg) { images.push_back(msg); }); @@ -331,7 +332,7 @@ TEST(cognitive_module_test, startup_simple) std::vector images; auto sub = sub_node->create_subscription( - "/detections", 100, [&images] (sensor_msgs::msg::Image msg) { + "/detections", 100, [&images](sensor_msgs::msg::Image msg) { images.push_back(msg); }); From edff90736a246f2957f28cbab2f47e9f3bffa719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Tue, 29 Oct 2024 06:41:09 +0100 Subject: [PATCH 4/5] Remove redundant name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Martín Rico --- cs4home_core/include/cs4home_core/CognitiveModule.hpp | 1 - cs4home_core/src/cs4home_core/CognitiveModule.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cs4home_core/include/cs4home_core/CognitiveModule.hpp b/cs4home_core/include/cs4home_core/CognitiveModule.hpp index 8d2efb4..236548c 100644 --- a/cs4home_core/include/cs4home_core/CognitiveModule.hpp +++ b/cs4home_core/include/cs4home_core/CognitiveModule.hpp @@ -59,7 +59,6 @@ class CognitiveModule : public rclcpp_lifecycle::LifecycleNode Meta::SharedPtr meta_; Coupling::SharedPtr coupling_; - std::string name_; std::string core_name_; std::string afferent_name_; std::string efferent_name_; diff --git a/cs4home_core/src/cs4home_core/CognitiveModule.cpp b/cs4home_core/src/cs4home_core/CognitiveModule.cpp index 703e188..99fd654 100644 --- a/cs4home_core/src/cs4home_core/CognitiveModule.cpp +++ b/cs4home_core/src/cs4home_core/CognitiveModule.cpp @@ -20,8 +20,7 @@ namespace cs4home_core CognitiveModule::CognitiveModule( const std::string & name, const rclcpp::NodeOptions & options) -: LifecycleNode(name, options), - name_(name) +: LifecycleNode(name, options) { declare_parameter("core", core_name_); declare_parameter("afferent", afferent_name_); From fa359e10aaee1ec3100c9a46d7837f817e1c3560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Tue, 29 Oct 2024 06:41:29 +0100 Subject: [PATCH 5/5] Upgrade CI versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francisco Martín Rico --- .github/workflows/rolling.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rolling.yaml b/.github/workflows/rolling.yaml index aab2716..2e99632 100644 --- a/.github/workflows/rolling.yaml +++ b/.github/workflows/rolling.yaml @@ -19,13 +19,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup ROS 2 - uses: ros-tooling/setup-ros@0.7.1 + uses: ros-tooling/setup-ros@0.7.9 with: required-ros-distributions: rolling - name: Install deps for testing run: sudo apt-get install ros-rolling-vision-msgs - name: build and test - uses: ros-tooling/action-ros-ci@0.3.6 + uses: ros-tooling/action-ros-ci@0.3.15 with: package-name: cs4home_core target-ros2-distro: rolling