In this exercise, do we need to create a subscriber that prints odometry message?
Because when I send “roslaunch read_odometry odom_subscriber.py” command on terminal. I don’t get odometry readings. Please advise
In this exercise, do we need to create a subscriber that prints odometry message?
Because when I send “roslaunch read_odometry odom_subscriber.py” command on terminal. I don’t get odometry readings. Please advise
Hi,
You need to fill in the callback and there put a print of the messages recieved.
I believe that’s what I did. Please see the code:
#! /usr/bin/env python
import rospy
from nav_msgs.msg import Odometry
def callback(msg):
print(msg) #This will print the whole Odometry message
rospy.init_node('odom_sub_node')
sub = rospy.Subscriber('/odom', Odometry, callback)
rospy.spin()
That’s what I have. Not sure what you are talking about, callback seems filled and it should print messages received but it doesn’t do it
Lines 12-14 shouldn’t be indented. Because they are, they are part of the callback(msg)
function definition.
The callback function gets called whenever the subscriber receives a message. As your code stands right now, the subscriber doesn’t get created until after it was already received a message, which is impossible.
Thank you! I appreciate the help