ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Reset Turtlebot odometry in a Python script

asked 2015-02-13 07:11:59 -0500

Elizaveta.Elagina gravatar image

I am using rostopic pub /mobile_base/commands/reset_odometry std_msgs/Empty to reset odometry on Turtlebot. It works fine but I want to do the same thing in a Python script. Here is my code:

import rospy
from std_msgs.msg import Empty


pub = rospy.Publisher('/mobile_base/commands/reset_odometry', Empty, queue_size=10)

It doesn't work. Could you point out what is wrong with it? Thanks!

edit retag flag offensive close merge delete


I have the same issue, did you get any response ??

AbdRenawi gravatar image AbdRenawi  ( 2016-10-04 08:17:05 -0500 )edit

In my initial explorations, if that command goes in the main control loop, it seems to work, but if it's only published a couple times, it fails to reset

haelannaleah gravatar image haelannaleah  ( 2017-02-10 16:14:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-10 17:19:59 -0500

haelannaleah gravatar image

updated 2017-02-10 17:32:58 -0500

For whatever reason, it looks publishing information to the reset topic takes a bit of time to get through. I'm using the reset command in the initialization of a navigation class, so I was able to get away with a quarter second busy loop for it:

import rospy

from std_msgs.msg import Empty
from time import time

# set up node

# set up the odometry reset publisher
reset_odom = rospy.Publisher('/mobile_base/commands/reset_odometry', Empty, queue_size=10)

# reset odometry (these messages take a few iterations to get through)
timer = time()
while time() - timer < 0.25:

It probably makes sense to reset odom as part of an initialization step, in which case, a busy loop shouldn't affect normal robot function. However, if you want to be able to do this on the fly, you're probably going to want to come up with a non-blocking way to loop the command.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-02-13 07:11:59 -0500

Seen: 3,353 times

Last updated: Feb 10 '17