From d7c8fae0dff92ec1a026a5182bc6e35607cb4cce Mon Sep 17 00:00:00 2001 From: Henry Moore Date: Tue, 26 Nov 2024 21:40:24 +0000 Subject: [PATCH 1/4] fix build with updated ros container, clangd fixes --- .pre-commit-config.yaml | 2 +- .../include/fuse_core/callback_wrapper.hpp | 23 ++++++++++++++++++- fuse_core/src/callback_wrapper.cpp | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e9d07d94..08a3ade73 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: files: \.(yml|yaml)$ - repo: https://github.com/tcort/markdown-link-check - rev: v3.12.2 + rev: v3.13.6 hooks: - id: markdown-link-check args: diff --git a/fuse_core/include/fuse_core/callback_wrapper.hpp b/fuse_core/include/fuse_core/callback_wrapper.hpp index 3180a8401..ff0437c15 100644 --- a/fuse_core/include/fuse_core/callback_wrapper.hpp +++ b/fuse_core/include/fuse_core/callback_wrapper.hpp @@ -99,6 +99,11 @@ namespace fuse_core class CallbackWrapperBase { public: + virtual ~CallbackWrapperBase() = default; + CallbackWrapperBase(CallbackWrapperBase const&) = default; + CallbackWrapperBase(CallbackWrapperBase&&) = default; + CallbackWrapperBase& operator=(CallbackWrapperBase const&) = default; + CallbackWrapperBase& operator=(CallbackWrapperBase&&) = default; /** * @brief Call this function. This is used by the callback queue. */ @@ -109,7 +114,12 @@ template class CallbackWrapper : public CallbackWrapperBase { public: + virtual ~CallbackWrapper() = default; using CallbackFunction = std::function; + CallbackWrapper(CallbackWrapper const&) = default; + CallbackWrapper(CallbackWrapper&&) = default; + CallbackWrapper& operator=(CallbackWrapper const&) = default; + CallbackWrapper& operator=(CallbackWrapper&&) = default; /** * @brief Constructor @@ -153,7 +163,7 @@ inline void CallbackWrapper::call() class CallbackAdapter : public rclcpp::Waitable { public: - explicit CallbackAdapter(std::shared_ptr context_ptr); + explicit CallbackAdapter(std::shared_ptr const& context_ptr); /** * @brief tell the CallbackGroup how many guard conditions are ready in this waitable @@ -183,6 +193,17 @@ class CallbackAdapter : public rclcpp::Waitable void removeAllCallbacks(); + void set_on_ready_callback(std::function /*callback*/) override + { + } + void clear_on_ready_callback() override + { + } + std::shared_ptr take_data_by_entity_id(size_t /*id*/) override + { + return nullptr; + } + private: rcl_guard_condition_t gc_; //!< guard condition to drive the waitable diff --git a/fuse_core/src/callback_wrapper.cpp b/fuse_core/src/callback_wrapper.cpp index 84dc2fba3..2adfd03ca 100644 --- a/fuse_core/src/callback_wrapper.cpp +++ b/fuse_core/src/callback_wrapper.cpp @@ -37,12 +37,12 @@ namespace fuse_core { -CallbackAdapter::CallbackAdapter(std::shared_ptr context_ptr) +CallbackAdapter::CallbackAdapter(std::shared_ptr const& context_ptr) + : gc_(rcl_get_zero_initialized_guard_condition()) { rcl_guard_condition_options_t guard_condition_options = rcl_guard_condition_get_default_options(); // Guard condition is used by the wait set to handle execute-or-not logic - gc_ = rcl_get_zero_initialized_guard_condition(); if (RCL_RET_OK != rcl_guard_condition_init(&gc_, context_ptr->get_rcl_context().get(), guard_condition_options)) { throw std::runtime_error("Could not init guard condition for callback waitable."); From 7fba6ceee6ca980d35b7f758807b953695f7535f Mon Sep 17 00:00:00 2001 From: Henry Moore Date: Tue, 26 Nov 2024 21:46:30 +0000 Subject: [PATCH 2/4] try fixing markdown link check --- .pre-commit-config.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 08a3ade73..fc12d3113 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,9 +58,6 @@ repos: rev: v3.13.6 hooks: - id: markdown-link-check - args: - - "-c" - - "markdown-link-check-config.json" - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.10 From 2f8f369feea9102c7c179ee6f5385b42bcc8f886 Mon Sep 17 00:00:00 2001 From: Henry Moore Date: Tue, 26 Nov 2024 21:59:58 +0000 Subject: [PATCH 3/4] further fix of constructor --- fuse_core/include/fuse_core/callback_wrapper.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fuse_core/include/fuse_core/callback_wrapper.hpp b/fuse_core/include/fuse_core/callback_wrapper.hpp index ff0437c15..7f920f6ba 100644 --- a/fuse_core/include/fuse_core/callback_wrapper.hpp +++ b/fuse_core/include/fuse_core/callback_wrapper.hpp @@ -100,6 +100,7 @@ class CallbackWrapperBase { public: virtual ~CallbackWrapperBase() = default; + CallbackWrapperBase() = default; CallbackWrapperBase(CallbackWrapperBase const&) = default; CallbackWrapperBase(CallbackWrapperBase&&) = default; CallbackWrapperBase& operator=(CallbackWrapperBase const&) = default; @@ -114,12 +115,7 @@ template class CallbackWrapper : public CallbackWrapperBase { public: - virtual ~CallbackWrapper() = default; using CallbackFunction = std::function; - CallbackWrapper(CallbackWrapper const&) = default; - CallbackWrapper(CallbackWrapper&&) = default; - CallbackWrapper& operator=(CallbackWrapper const&) = default; - CallbackWrapper& operator=(CallbackWrapper&&) = default; /** * @brief Constructor From 11f8b35fb6c7b1a0f225fe3d82e3c8b64d007dc8 Mon Sep 17 00:00:00 2001 From: Henry Moore Date: Tue, 26 Nov 2024 22:39:18 +0000 Subject: [PATCH 4/4] you best const correct --- fuse_core/src/callback_wrapper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fuse_core/src/callback_wrapper.cpp b/fuse_core/src/callback_wrapper.cpp index 2adfd03ca..fbbcdecbc 100644 --- a/fuse_core/src/callback_wrapper.cpp +++ b/fuse_core/src/callback_wrapper.cpp @@ -40,7 +40,7 @@ namespace fuse_core CallbackAdapter::CallbackAdapter(std::shared_ptr const& context_ptr) : gc_(rcl_get_zero_initialized_guard_condition()) { - rcl_guard_condition_options_t guard_condition_options = rcl_guard_condition_get_default_options(); + rcl_guard_condition_options_t const guard_condition_options = rcl_guard_condition_get_default_options(); // Guard condition is used by the wait set to handle execute-or-not logic if (RCL_RET_OK != rcl_guard_condition_init(&gc_, context_ptr->get_rcl_context().get(), guard_condition_options)) @@ -74,7 +74,7 @@ bool CallbackAdapter::is_ready(rcl_wait_set_t const& wait_set) */ void CallbackAdapter::add_to_wait_set(rcl_wait_set_t& wait_set) { - if (RCL_RET_OK != rcl_wait_set_add_guard_condition(&wait_set, &gc_, NULL)) + if (RCL_RET_OK != rcl_wait_set_add_guard_condition(&wait_set, &gc_, nullptr)) { RCLCPP_WARN(rclcpp::get_logger("fuse"), "Could not add callback waitable to wait set."); } @@ -89,7 +89,7 @@ std::shared_ptr CallbackAdapter::take_data() std::shared_ptr cb_wrapper = nullptr; // fetch the callback ptr and release the lock without spending time in the callback { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); if (!callback_queue_.empty()) { cb_wrapper = callback_queue_.front(); @@ -122,7 +122,7 @@ void CallbackAdapter::execute(std::shared_ptr const& data) void CallbackAdapter::addCallback(const std::shared_ptr& callback) { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); callback_queue_.push_back(callback); if (RCL_RET_OK != rcl_trigger_guard_condition(&gc_)) { @@ -134,7 +134,7 @@ void CallbackAdapter::addCallback(const std::shared_ptr& ca void CallbackAdapter::addCallback(std::shared_ptr&& callback) { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); callback_queue_.push_back(std::move(callback)); if (RCL_RET_OK != rcl_trigger_guard_condition(&gc_)) { @@ -146,7 +146,7 @@ void CallbackAdapter::addCallback(std::shared_ptr&& callbac void CallbackAdapter::removeAllCallbacks() { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); callback_queue_.clear(); }