rospy.get_time() returns 0 when using gazebo
Hi,
When I run my code, I run into two problems. First, when I call rospy.get_time()
, it returns 0. Secondly, in my while loop, perhaps due to the first issue, it only iterates once. Here is my code:
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
topicName = "cmd_vel_mux/teleop"
pub = rospy.Publisher("cmd_vel_mux/input/teleop", Twist, queue_size=10)
rospy.init_node('drive_time')
b_time = rospy.get_time()
print b_time
n = 0
while rospy.get_time() < b_time + 5:
n+=1
t = Twist()
t.linear.x = 0.1
pub.publish(t)
rospy.sleep(0.1)
print n
print "done"
t = Twist()
t.linear.x = 0.1
pub.publish(t)
I am running a turtlebot in gazebo using turtlebot_world.launch
. I tried changing the param use_sim_time
to false and to true and it didn't work either way. When I initialize a node by typing it into the interpreter, rospy.get_time()
works fine. Any ideas as to why this is happening?
I am having the exact same problem. Any ideas?
Same problem. Anyone can help?