Rosanswers logo

Hello ! I want to know the pose of turtlebot (x,y,z, z rotation) respect to the point from which it started. What is the best way to do that in python?

Originally posted by sabruri1 on ROS Answers with karma: 1 on 2017-09-27

Post score: 0

Original comments

Comment by jayess on 2017-09-27:
What do you mean by

respect to the point from which it started

? Are you talking about in some reference frame like world or map? Or, are you comparing two poses (initial and final)?

Comment by sabruri1 on 2017-09-27:
My robot starts from a point in the room. I would fix a reference frame in this point. Robot reaches a new point. I want to know x,y coordinates of this point in the initial fixed reference frame and it's orientation. Maybe I can use odom topic


1 Answer 1


Rosanswers logo


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: https://www.youtube.com/watch?v=kPsrOQrzkaM

Originally posted by Alberto E. with karma: 356 on 2017-10-05

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by srnand on 2018-03-29:

this msg.pose.pose.orientation.w, return a value 1 in the initial configuration where everything should be zero.

Can you explain why?

Comment by tfoote on 2018-03-29:
(0,0,0,1) is the identity quaternion: I'd suggest reading more about quaternions. https://answers.ros.org/question/9981/what-are-quaternions-and-how-can-i-use-them/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.