Ask Your Question
0

why rospy time always prining zero?

asked 2016-06-16 12:04:47 -0600

anilmullapudi gravatar image

I need a time while running the simulation, but in my code returns zero time.

print rospy.get_time(); #output 0

print rospy.Time.now(); #output 0.0

but i see the time in terminal when i run rostopic echo /clock

Am i doing anything wrong while reading time?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2016-06-16 12:06:51 -0600

updated 2016-06-16 12:53:35 -0600

Did you initialize the ros node?

rospy.init_node("mynodename")

The typical approach to get the current time is:

now = rospy.Time.now()

If you are using some kind of simulation you also have to take into account how the use_sim_time parameter influence to the behavior of the rospy.Time. Have a look to: http://wiki.ros.org/Clock

edit flag offensive delete link more

Comments

yes, node was already initialized. still same issue

anilmullapudi gravatar imageanilmullapudi ( 2016-06-16 12:13:16 -0600 )edit

May be the use_sim_time param set to true? can you check what you get from the following command line: rosparam get /use_sim_time

Pablo Iñigo Blasco gravatar imagePablo Iñigo Blasco ( 2016-06-16 12:43:50 -0600 )edit

Yes, the simulation is running. And the command rosparam get /use_sim_time is giving output true.

anilmullapudi gravatar imageanilmullapudi ( 2016-06-16 13:29:05 -0600 )edit

rospy.Time.now() is working now after setting the use_sim_true param to false in launch file.

anilmullapudi gravatar imageanilmullapudi ( 2016-06-16 13:47:57 -0600 )edit

if this answer solved your question, please mark it as solved.

Pablo Iñigo Blasco gravatar imagePablo Iñigo Blasco ( 2016-06-16 14:54:10 -0600 )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

Stats

Asked: 2016-06-16 12:04:47 -0600

Seen: 1,021 times

Last updated: Jun 16 '16