-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
The following operators: publish_to_topic and send_transform should use subscribe_on rather than observe_on:
template<typename T>
auto publish_to_topic(const std::string &topic, const uint32_t queue_size = 10) {
return [=](auto&& source) {
ros::Publisher publisher(rxros::node::get_handle().advertise<T>(topic, queue_size));
source.**observe_on**(rxcpp::synchronize_new_thread()).subscribe(
[=](const T& msg) {publisher.publish(msg);});
return source;};}
The observe_on will cause the subscriber to execute in a new thread. However, the source will execute in the thread publish_to_topic was called on. If this is the main thread the publish_to_topic will block the main thread. The subscribe_on will ensure that both the source and the subscriber will execute in a new thread and thus not cause the publish_to_topic to block.
Metadata
Metadata
Assignees
Labels
No labels