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

Revision history [back]

click to hide/show revision 1
initial version

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
rospy.init_node('reset_odom')

# set up the odometry reset publisher
self.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:
    self.reset_odom.publish(Empty())

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.

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
rospy.init_node('reset_odom')

# set up the odometry reset publisher
self.reset_odom 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:
    self.reset_odom.publish(Empty())
reset_odom.publish(Empty())

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.

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
rospy.init_node('reset_odom')

# 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:
    reset_odom.publish(Empty())

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.