Comments (16)
Hi @roncapat , I found no documentation in this regard, but I verified it through tests (see the linked repo). It is also intuitive that, if a conversion needes to be applied, it is not possible to efficiently share a pointer between publisher and subscriber. However, I think some sort of warning or a fallback to the normal communication mechanism would be desirable in this scenario.
from rclcpp.
Thanks a lot @iuhilnehc-ynos, I can confirm that applying the patch on top of rclcpp 21.0.2 solved the problem, at least for this specific test.
[component_container-1] [INFO] [1693472229.766338070] [adapted_publisher]: Publishing to ADAPTED topic cloud with address: 0x5581E17A9020
[component_container-1] [INFO] [1693472229.766626558] [adapted_publisher]: Publishing to NOT ADAPTED topic cloud with address: 0x5581E159DC20
[component_container-1] [INFO] [1693472229.767263217] [adapted_subscriber]: Adapted sub received cloud with address: 0x5581E17A9020
[component_container-1] [INFO] [1693472229.767467450] [adapted_subscriber]: Normal sub received cloud with address: 0x5581E1AA1740
from rclcpp.
I imagine this could accidentally happen if the subscriber doesn't know which mechanism is being used by the publisher (for example if the programmer misses access to the pub source code). Yet this wouldn't really be a "use-case", since the subscriber can always disable the intra-process option in this scenario, so I suppose an exception would be fine.
from rclcpp.
The case of an intraprocess pub/sub, with one side being a ROSMsg and the other side being Custom, should be supported for the reasons @roncapat points out. It obviously involves a copy, so isn't as efficient as a ROSMsg<->ROSMsg or Custom<->Custom, but it should still work.
It's been a couple of years since I looked at this, but I believe we even tested that at the time we added in type adaptation. My opinion is that this should be treated as a bug and fixed.
from rclcpp.
Good point; I wasn't thinking of "composition" involving third-party code (that you may or may not have control over its source).
We should still add a warning when the pub and sub discover each others (even if there's a valid use-case for it, notifying the users via a log will help them identify possible undesired inefficiencies in their pipeline).
from rclcpp.
Let me share my two cents.
The
can not be deduced to use the https://github.com/nirwester/ros2_journey_examples/blob/91cc788badf36e8ebe0f2efc729ed3b72169c659/homeworks/chap4/type_adaptation/src/test_type_adaptation/include/test_type_adaptation/type_adapter.hpp#L34-L38, butrclcpp/rclcpp/include/rclcpp/type_adapter.hpp
Lines 97 to 100 in 43cf0be
I think something below might be correct.
diff --git a/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp b/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp
index a152632a..dfcda620 100644
--- a/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp
+++ b/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp
@@ -486,13 +486,13 @@ private:
"subscription use different allocator types, which is not supported");
}
- if constexpr (rclcpp::TypeAdapter<MessageT>::is_specialized::value) {
+ if constexpr (rclcpp::TypeAdapter<MessageT, ROSMessageType>::is_specialized::value) {
ROSMessageTypeAllocator ros_message_alloc(allocator);
auto ptr = ros_message_alloc.allocate(1);
ros_message_alloc.construct(ptr);
ROSMessageTypeDeleter deleter;
allocator::set_allocator_for_deleter(&deleter, &allocator);
- rclcpp::TypeAdapter<MessageT>::convert_to_ros_message(*message, *ptr);
+ rclcpp::TypeAdapter<MessageT, ROSMessageType>::convert_to_ros_message(*message, *ptr);
auto ros_msg = std::unique_ptr<ROSMessageType, ROSMessageTypeDeleter>(ptr, deleter);
ros_message_subscription->provide_intra_process_message(std::move(ros_msg));
} else {
from rclcpp.
@iuhilnehc-ynos please take care of opening the PR, i am happy to do review.
from rclcpp.
Hi @nirwester, may I ask you about this:
However, if the publisher uses a custom-type and the subscriber a ROS-msg type, the communication (as can be expected) fails if the intra-process communication is enabled.
Where you found evidence / documentation? If intra-process is enabled the adapter is not able to do conversion from/to message?
from rclcpp.
Exactly, I just thought a fallback would happen in that case... that's why now I'm interested in this thread :)
from rclcpp.
Are there use-cases to have a publisher and a subscriber in the same process where one uses a ROS-msg type and the other uses a custom type?
I can't think of any valid use-case, so I would throw an exception rather than a warning.
from rclcpp.
I have a library of components that use my private message adapters. If I want to compose them with 3rd party packages with intra-process on (because I need it for some topics that exchange data with other components of mine) I can't make the mix work (I may have to enable/disable intra process per-topic via param file). So yes, now that I recall, I already experienced this issue in the past.
from rclcpp.
Nice!
Next steps? PR with some warnings added?
from rclcpp.
Next steps? PR with some warnings added?
I'd say let's make a PR with that change and a new test. Adding a warning I think should be done in a separate PR, so we can discuss it separately.
from rclcpp.
@iuhilnehc-ynos as the patch is yours, would you like to open the PR?
from rclcpp.
Just FYI, backport to iron and humble are completed.
from rclcpp.
Thanks a lot @fujitatomoya and everybody!
from rclcpp.
Related Issues (20)
- TimersManager doesn't follow ROS time HOT 2
- rclcpp_action: Provide enum class return ClientGoalHandle::get_status
- Callback works on Galactic but fails on Rolling - handle_message is not implemented for GenericSubscription HOT 1
- Clang warning: ordered comparison of function pointers (Rolling) HOT 1
- `-fanalyzer` warning: possible null dereference when using TypeAdapters HOT 4
- leak due to std::shared_ptr circular reference between Context and GuardCondition HOT 3
- :farmer: `rclcpp.test_executors` failing in Rolling and Jazzy CycloneDDS HOT 2
- rclcpp::Time(int64_t nanoseconds, ...) should check for negative time
- Regression : Executor::spin_some_impl is active waiting HOT 5
- Parameter service behavior is inconsistent with the documentation of rcl_interfaces HOT 9
- Lifecycle destructor calls shutdown while in shuttingdown intermediate state HOT 45
- Backport PR2063 to Humble for Windows HOT 2
- Executor callbacks are no longer in a predictable order HOT 25
- '/clock' Topic cannot change each loop step time from simulation time HOT 10
- Program exits with code -11 when using async_send_request to set parameters in ROS 2 C++ client HOT 1
- Timer callbacks can be delayed when using simulation time HOT 4
- Possible regression in rcl preshutdown callbacks - context invalid? HOT 11
- Shutdown transition on base lifecycle node dtor may lead to segaults on subclass-registered shutdown callback HOT 6
- `on_shutdown` callback not called when `shutdown` transition is triggered on dtor HOT 2
- ABI/API Compliance Checker in github workflow HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rclcpp.