Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dnae adas/generic subscriber and publisher #1077

Open
wants to merge 25 commits into
base: rolling
Choose a base branch
from

Conversation

DensoADAS
Copy link
Contributor

using SerializedMessage and support in intraprocess manager to create a generic subscriber / publisher without previously known message type

@DensoADAS
Copy link
Contributor Author

DensoADAS commented Apr 21, 2020

@Karsten1987 I did not create a spezialzation of Publisher for SerializedMessages as I disklike copying so much redudant code. I redesigned it so the changes to the Publisher are reduced. I hope it does not break to much with the current api. (But I have also a version with a spezialized publisher in backup)

@DensoADAS
Copy link
Contributor Author

DensoADAS commented Apr 21, 2020

depends on #1076

@ivanpauno
Copy link
Member

ivanpauno commented Apr 21, 2020

A few questions before reviewing, I'm probably missing some context from #973 discussion:

  • what's the goal of the "generic" publisher/subscription?
  • how they differ from Publisher/Subscription?

Thanks!

create_generic_publisher(
NodeT & node,
const std::string & topic_name,
const rosidl_message_type_support_t & type_support,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why both MessageT template parameter and the type_support argument are needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming should also be more clear.
Maybe, just an override of create_publisher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MessageT is used for the allocator

rclcpp/include/rclcpp/create_subscription.hpp Outdated Show resolved Hide resolved
if (RCL_RET_OK != status) {
rclcpp::exceptions::throw_from_rcl_error(status, "failed to publish message");
}
generic_publisher::do_inter_process_publish(publisher_handle_, msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the two new free functions are needed, and why a "normal" Publisher is calling the functions in generic_publisher namespace.
@DensoADAS can you expain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the SerializedMessage the original "do_inter_process_publish" will fail as it's no ROS message

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just are an override for a serialized message in the Publisher class?

rclcpp/include/rclcpp/publisher_factory.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/subscription_factory.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that there is no generic publisher type, I would think it makes sense best to not mention this and keep the notation to publisher.

rclcpp/include/rclcpp/create_publisher.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/create_subscription.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/publisher.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/publisher.hpp Outdated Show resolved Hide resolved
@DensoADAS
Copy link
Contributor Author

A few questions before reviewing, I'm probably missing some context from #973 discussion:

* what's the goal of the "generic" publisher/subscription?

* how they differ from `Publisher`/`Subscription`?

Thanks!

The "generic" publisher/subscriber allows communication without knowing the message type to compile time. Therefore a serialized message can bei published or received and the endpoint has to handle the content itself. This is used for example in rosbag2.

This implementation supports now intraprocess communication when using the C++ version of serialized messages which make the memory handling more safe.

@DensoADAS DensoADAS force-pushed the dnae_adas/generic_subscriber_and_publisher branch from e0fb512 to b5bce53 Compare April 22, 2020 07:13
@ivanpauno
Copy link
Member

The "generic" publisher/subscriber allows communication without knowing the message type to compile time. Therefore a serialized message can bei published or received and the endpoint has to handle the content itself. This is used for example in rosbag2.

Ah ok. So in those cases, you use MessageT=SerializedMessageBase, and you don't need to know the message type at compile time, right?

Joshua Hampp and others added 18 commits April 22, 2020 17:03
* implemented interface to deserialize a given serialized message to ros message

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
 * serialized publisher uses correct method to forward content to subscriber
 * non-serialized publisher can serialize message for serialized subscriber

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
…cess_message

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
…y needed for the next PR)

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
* Reflect changes in rclcpp API

Signed-off-by: Prajakta Gokhale <prajaktg@amazon.com>

* Revert earlier fix made in rclcpp

Signed-off-by: Prajakta Gokhale <prajaktg@amazon.com>
 * added constructor with typesupport
 * added more generic do_inter_process_publish

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
…d subscribers

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
@DensoADAS DensoADAS force-pushed the dnae_adas/generic_subscriber_and_publisher branch from b5bce53 to aeb69bf Compare April 22, 2020 15:38
@Karsten1987
Copy link
Contributor

Karsten1987 commented Apr 22, 2020

CI (build everything, test rclcpp):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@DensoADAS
Copy link
Contributor Author

Switching back to create_generic_... would solve this. Do you have another suggestion?

@DensoADAS
Copy link
Contributor Author

@Karsten1987 I lost a little bit the track of the conversation. What's the current status?

@Karsten1987
Copy link
Contributor

In my opinion, #1076 (comment) this is where we stand. I think the intraprocess manager should be sorted out before pushing forward with this change.

Joshua Hampp added 7 commits April 29, 2020 18:40
* removed specialization to rclcpp::Serialization

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
 * allocate message
 * getter for serialization
 * provide untyped message

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
 * two extra subscription/publisher pairs (for serialized ones)
 * added methods for (de)serialization
 * added methods for messages without known allocator
 * splitted up publishing with same type and not matching message type

Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
Signed-off-by: Joshua Hampp <j.hampp@denso-adas.de>
@Karsten1987
Copy link
Contributor

Thanks @DensoADAS for iterating over this PR.

Unfortunately, we've passed API freeze for Foxy and after talking with @jacobperron (the Foxy lead), we've decided to table this for G-Turtle.

@nyxaria
Copy link

nyxaria commented Aug 17, 2020

Is a generic subscriber available in Foxy? I don't think I can use ROS2 until it is in. :/

@jacobperron
Copy link
Member

Is a generic subscriber available in Foxy?

Not in rclcpp. Unless something like this PR can be done in an ABI compatible way, I don't think we can expect it to land in Foxy.

As mentioned on ROS Answers, you can do this in Python and/or copy the C++ implementation from rosbag2 for your application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants