Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can't receive data in python node

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()

Can't receive data in python node

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() );