0
$\begingroup$

Rosanswers logo

Hi,

I don't know how to debug this:
I took the python demo listener and changed it to subscribe to odometry.
But when I subscribe to my running cpp node which publishes odom, I don't receive any data ...
If I use a cmd publisher like ros2 topic pub /odom nav_msgs/msg/Odometry, listener receives data..
Also if I use my own cpp odom publisher and the cmd line publisher at the same time, I only receive data from cmd publisher...

But echo gives me data from both publishers...

Namespace is correct, topic is correct.

I am running on empty now ...

from std_msgs.msg import String
from nav_msgs.msg import Odometry

class Listener(Node):

    def __init__(self):
        super().__init__('odom_listener')
        self.sub = self.create_subscription(Odometry, 'odom', self.chatter_callback, 10)

    def chatter_callback(self, msg):
        self.get_logger().info('I heard odom')


def main(args=None):
    rclpy.init(args=args)

    node = Listener()
    rclpy.spin(node)

    node.destroy_node()
    rclpy.shutdown()


if __name__ == '__main__':
    main()

As requested cpp publisher:

   odomPub = this->create_publisher<Odom>( "odom", rclcpp::SensorDataQoS() );

Originally posted by madmax on ROS Answers with karma: 496 on 2019-09-03

Post score: 0


Original comments

Comment by PeteBlackerThe3rd on 2019-09-03:
My guess would be this has something to do with the namespace of the topic you're using. Have you tried using /odom in your code instead of odom?

Comment by SamsAutonomy on 2019-09-03:
@madmax What is the output of your CPP node? Add a code snippet of the CPP node publisher, it would be helpful.

Comment by SamsAutonomy on 2019-09-03:
@madmax More questions :) What does ros2 topic list return? With both publishers running.

Also, how do you know which publisher is reaching your callback when you: Also if I use my own cpp odom publisher and the cmd line publisher at the same time, I only receive data from cmd publisher...

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It looks like the QoS settings on the publisher and subscriber are incompatible. Change the QoS settings on either the publisher or the listener to match. See the page About Quality of Service Settings for more info.

The C++ publisher is using rclcpp::SensorDataQoS(), which uses the sensor data QoS profile. The Python subscriber is just specifying the queue size, which means it uses the default profile with the given queue size of 10. The incompatibility comes from the reliability setting. The sensor data profile specifies best effort while the default profile uses reliable. According to the QoS compatibilities table, a subscriber requiring reliable will not connect to a publisher providing only best effort reliability.


Originally posted by sloretz with karma: 3061 on 2019-09-03

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by madmax on 2019-09-03:
Good hint! Coming from ros 1 where its not that strict...

Comment by deb0ch on 2020-03-09:
This hint helped me find the answer with (somewhat) code that solved this for me: https://index.ros.org//doc/ros2/Concepts/About-Quality-of-Service-Settings/#qos-compatibilities

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.