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() );
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 ofodom
?@madmax What is the output of your CPP node? Add a code snippet of the CPP node publisher, it would be helpful.
@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...