@murokill, I've been fighting the same battle. I was just able to get the ROS2 examples_rclcpp_minimal_publisher
and examples_rclcpp_minimal_subscriber
working with a variant of the eProsima Fast-RTPS code generated by pretty much following the steps on the eProsima Fast-RTPS Getting Started page. I pulled the String.idl
IDL file from my ROS2 installation in place of the sample IDL snippet shown in the webpage. On my system, it was at /opt/ros/crystal/share/std_msgs/msg
. I'm running Ubuntu 18.04.2 LTS. There were two things I had to do to get it to work beyond the basic stuff you find fairly easily in tutorials. I used WireShark to dig into the RTPS UDP and Multicast packets to help clue me in on these updates.
1. In eProsima's code generated from your String.idl file, you'll need to prefix your topic in StringPublisher::init()
and StringSubscriber::init()
with rt
. This tells eProsima Fast-RTPS that you are trying to talk with ROS2 nodes. I found this tidbit here in ROS2 documentation. For example, my topic was /hailstate
for the ROS2 publisher/subscriber and I wanted it to be the same on the eProsima publisher/subscriber, but it wasn't showing up that way. Once I prefixed my topic with rt
, the topic names matched. Code below is the updated code that was generated using fastrtpsgen -example CMake String.idl
in generated file StringPublisher.cxx
. The same change on the last line would need to be made in the StringSubscriber.cxx
:
bool StringPublisher::init() {
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0;
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("epro_publisher");
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
{
return false;
}
Domain::registerType(mp_participant,
static_cast<TopicDataType*>(&myType));
// Create Publisher
PublisherAttributes Wparam;
Wparam.topic.topicKind = NO_KEY;
Wparam.topic.topicDataType = myType.getName();
Wparam.topic.topicName = "rt/hailstate";
2. My next problem was that my types didn't match. When running four nodes (ROS2 examples_rclcpp_minimal_publisher, ROS2 examples_rclcpp_minimal_subscriber, eProsima subscriber, and eProsima publisher), the ros2 topic list -t
command would show my topic with two different types. One type for the eProsima topic std_msgs::msg::String
and a different type for the ROS2 topic std_msgs/String
even though I used the ROS String.idl file to create the eProsima logic. Because of this type mismatch, the topics were still technically different. I changed the topic in the constructor, StringPubSubType::StringPubSybType()
, in the fastrtpsgen
generated file, StringPubSubTypes.cxx
, with the line setName("std_msgs::msg::dds_::String_");
line shown in the code snippet below. I just changed the type from the default specified by eProsima to what it shows now. After this, all four nodes started communicating with each other. The key is inserting the dds_::
and adding the _
at the end of the String base type.
namespace std_msgs {
namespace msg {
StringPubSubType::StringPubSubType()
{
setName("std_msgs::msg::dds_::String_");
If there is a way to do this without feeling like I had to hack it, I'd be very interested to know what it is. I ... (more)
Duplicate: https://github.com/ros2/rmw_fastrtps/...
Please don't ask multiple versions of questions that's poor etiquette as it potentially causes multiple people to try to help you. Also your other question has much more helpful details that might be able to help someone answer your question here. Please see our support guidelines: https://wiki.ros.org/Support
Since this is a question this is the right place so I'll close the other one. Please edit your question here to add more details. The easier it is for someone to reproduce your problem the easier it is for them to help you.
@murokill were you able to reach a solution for the issue or is it still pending?