Ask Your Question

[Python]How to know pose of turtlebot

asked 2017-09-27 09:54:01 -0500

sabruri1 gravatar image

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?

edit retag flag offensive close merge delete


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)?

jayess gravatar image jayess  ( 2017-09-27 12:11:44 -0500 )edit

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

sabruri1 gravatar image sabruri1  ( 2017-09-27 12:32:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-05 11:00:04 -0500

Alberto E. gravatar image


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:

edit flag offensive delete link more



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

Can you explain why?

srnand gravatar image srnand  ( 2018-03-29 12:43:30 -0500 )edit

(0,0,0,1) is the identity quaternion: I'd suggest reading more about quaternions.

tfoote gravatar image tfoote  ( 2018-03-29 17:53:04 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-09-27 09:54:01 -0500

Seen: 4,648 times

Last updated: Oct 05 '17