Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version


As you suggest in your last message, the best practice for doing that is to use the odom topic. For that, you can create a simple subscriber in Python that gets the data you need, which is, position and orientation respect to an starting point. The code for a simple subscriber could be like this:

#! /usr/bin/env python

import rospy
from nav_msgs.msg import Odometry

def callback(msg):
    print msg.pose.pose

odom_sub = rospy.Subscriber('/odom', Odometry, callback)

This code basically subscribes to the odom topic, and prints the pose component of the message, which contains the position and orientation values. I've also created a video with a quick demonstration, which may be helpful: