Skip to content

Commit

Permalink
fix build with updated ros container, clangd fixes (#11)
Browse files Browse the repository at this point in the history
* fix build with updated ros container, clangd-tidy fixes, bump markdown pre-commit hook
  • Loading branch information
henrygerardmoore authored Nov 26, 2024
1 parent 5182ec0 commit ef94df5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ 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:
- "-c"
- "markdown-link-check-config.json"

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
Expand Down
19 changes: 18 additions & 1 deletion fuse_core/include/fuse_core/callback_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ namespace fuse_core
class CallbackWrapperBase
{
public:
virtual ~CallbackWrapperBase() = default;
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.
*/
Expand Down Expand Up @@ -153,7 +159,7 @@ inline void CallbackWrapper<void>::call()
class CallbackAdapter : public rclcpp::Waitable
{
public:
explicit CallbackAdapter(std::shared_ptr<rclcpp::Context> context_ptr);
explicit CallbackAdapter(std::shared_ptr<rclcpp::Context> const& context_ptr);

/**
* @brief tell the CallbackGroup how many guard conditions are ready in this waitable
Expand Down Expand Up @@ -183,6 +189,17 @@ class CallbackAdapter : public rclcpp::Waitable

void removeAllCallbacks();

void set_on_ready_callback(std::function<void(size_t, int)> /*callback*/) override
{
}
void clear_on_ready_callback() override
{
}
std::shared_ptr<void> take_data_by_entity_id(size_t /*id*/) override
{
return nullptr;
}

private:
rcl_guard_condition_t gc_; //!< guard condition to drive the waitable

Expand Down
16 changes: 8 additions & 8 deletions fuse_core/src/callback_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
namespace fuse_core
{

CallbackAdapter::CallbackAdapter(std::shared_ptr<rclcpp::Context> context_ptr)
CallbackAdapter::CallbackAdapter(std::shared_ptr<rclcpp::Context> 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
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.");
Expand Down Expand Up @@ -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.");
}
Expand All @@ -89,7 +89,7 @@ std::shared_ptr<void> CallbackAdapter::take_data()
std::shared_ptr<CallbackWrapperBase> cb_wrapper = nullptr;
// fetch the callback ptr and release the lock without spending time in the callback
{
std::lock_guard<std::mutex> lock(queue_mutex_);
std::lock_guard<std::mutex> const lock(queue_mutex_);
if (!callback_queue_.empty())
{
cb_wrapper = callback_queue_.front();
Expand Down Expand Up @@ -122,7 +122,7 @@ void CallbackAdapter::execute(std::shared_ptr<void> const& data)

void CallbackAdapter::addCallback(const std::shared_ptr<CallbackWrapperBase>& callback)
{
std::lock_guard<std::mutex> lock(queue_mutex_);
std::lock_guard<std::mutex> const lock(queue_mutex_);
callback_queue_.push_back(callback);
if (RCL_RET_OK != rcl_trigger_guard_condition(&gc_))
{
Expand All @@ -134,7 +134,7 @@ void CallbackAdapter::addCallback(const std::shared_ptr<CallbackWrapperBase>& ca

void CallbackAdapter::addCallback(std::shared_ptr<CallbackWrapperBase>&& callback)
{
std::lock_guard<std::mutex> lock(queue_mutex_);
std::lock_guard<std::mutex> const lock(queue_mutex_);
callback_queue_.push_back(std::move(callback));
if (RCL_RET_OK != rcl_trigger_guard_condition(&gc_))
{
Expand All @@ -146,7 +146,7 @@ void CallbackAdapter::addCallback(std::shared_ptr<CallbackWrapperBase>&& callbac

void CallbackAdapter::removeAllCallbacks()
{
std::lock_guard<std::mutex> lock(queue_mutex_);
std::lock_guard<std::mutex> const lock(queue_mutex_);
callback_queue_.clear();
}

Expand Down

0 comments on commit ef94df5

Please sign in to comment.