AnySubscriptionCallback doesn't accept `std::bind` callbacks with bound arguments
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 805
- Forks
- 564
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 27
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 22.04
- Installation type:
- from source
- Version or commit hash:
- rolling
- DDS implementation:
- Fast-RTPS
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
- Build rclcpp on a version after https://github.com/ros2/rclcpp/pull/1928
- Try to build for example foxglove-bridge
Expected behavior
std::bind(&FoxgloveBridge::rosMessageHandler, this, channelId, clientHandle, _1), (source) is cast to std::function from any_subscription_callback.hpp
Actual behavior
Additional information
For example std::bind(&Class::method, this, std::placeholders::_1) (without bound arguments) will build fine
We also were able to fix the issue by casting the callback to std::function before passing it to the subscription
auto subscriber = this->create_generic_subscription(
topic, datatype, qos,
static_cast<std::function<void(std::shared_ptr<rclcpp::SerializedMessage>)>>(std::bind(&FoxgloveBridge::rosMessageHandler, this, channelId, clientHandle, _1)),
subscriptionOptions);
Is this how it is supposed to be done now, or is there a bug in casting std::bind from any_subscription_callback.hpp?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in rclcpp/include/rclcpp/any_subscription_callback.hpp at the callback conversion referenced in the report, then reproduce the build through create_generic_subscription using the foxglove-bridge example. Compare std::bind callbacks with and without bound arguments and verify the subscription accepts the reported callback without a caller-side std::function cast.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100