def myhook(): print "shutdown time!" rospy.on_shutdown(myhook)
或
rospy.signal_shutdown(reason)
- 初始化节点关闭
- reason 为关闭理由,字符串内容。
例子:
#!/usr/bin/env python import rospy import math import sys from tf import transformations from geometry_msgs.msg import PoseWithCovarianceStamped class