Hello. How can i perform some actions after the program ends? I tried to use ROSInterruptException but it did not work.
!/usr/bin/env python
import rospy
from std_msgs.msg import String
def talker():
pub = rospy.Publisher('chatter', String, queue_size=10)
rospy.init_node('talker', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
hello_str = "hello world %s" % rospy.get_time()
rospy.loginfo(hello_str)
pub.publish(hello_str)
rate.sleep()
try:
talker()
except rospy.ROSInterruptException:
rospy.loginfo("TEST")
And when I do Ctrl+C the "TEST" line does not appear. What have I done wrong? Why the exception does not work?
Originally posted by kolyazoloto on ROS Answers with karma: 3 on 2018-11-27
Post score: 0