Robotics StackExchange | Archived questions

Stopping ROS timer python

I want a timer to run for a short time to calculate something but then i want to be able to stop it. I see where it says to use shutdown() but it doesn't like that. Help would be appreciated. if shutdown() is correct could you please put an example of it working.

Asked by wcgmb on 2019-07-30 15:15:04 UTC

Comments

What does "doesn't like it" mean? Is there an error? Post your code so we can help.

Asked by billy on 2019-07-31 21:04:46 UTC

Answers

(late to this question but I came here looking for an example of shutdown() so adding an answer for future visitors)

The Timer class has a shutdown method which needs to be called, like you'd call the method of any class of which you've an object.

could you please put an example of it working.

timer_object = rospy.Timer(rospy.Duration(2), some_callback_function)
#
# do whatever you want to do before calling shutdown
#
timer_object.shutdown()

Asked by abhishek47 on 2021-05-31 22:58:46 UTC

Comments