How to subscribe to odom properly in python
Hello, all,
I recently wrote a simple subscriber that subscribes to the topic /odom coming from the irobot_create_2_1 driver for an iCreate. However, when I simply print the odometry data and rotate the wheels myself, the data doesn't change. At the same time, though, if I re-run the Python Script, the data will have changed to the amount I previously rotated it.
Have I made a simple mistake? Or does /odom not publish the current transformation and rotation information.
(I noticed also that the time stamp doesn't change)
Thanks so much in advance for any advice!
Here's my source code:
#!/usr/bin/env python
import roslib; roslib.load_manifest('Phoebe')
import rospy
import irobot_create_2_1
from nav_msgs.msg import Odometry
from geometry_msgs.msg import *
from tf.msg import *
counter = 0
def Position(odom_data):
global counter
rospy.sleep(1)
curr_time = odom_data.header.stamp
pose = odom_data.pose.pose # the x,y,z pose and quaternion orientation
counter= counter+1
print counter, curr_time
print
print pose
def transformation(tf_data):
global counter
rospy.sleep(1)
transform = tf_data.transform
print transform
def begin():
while not rospy.is_shutdown():
rospy.init_node('oodometry', anonymous=True) #make node
rospy.Subscriber('odom',Odometry,Position)
if __name__ == "__main__":
begin()
rospy.spin() # not really necessary because we have while not rospy.is_shutdown()