Go to the documentation of this file.00001
00002
00003 import roslib
00004 import rospy
00005 import time
00006
00007 from subsumption_msgs.msg import Heading
00008 from subsumption_msgs.msg import Force
00009
00010 time_unit = 0.1
00011 time_unit_amount = 20
00012 time_start = 0.0
00013
00014 def avoid_headingCB(msg):
00015 global time_start
00016 time_start = time.time()
00017 pub_heading = rospy.Publisher('/suppressor/turn/heading', Heading, queue_size=10)
00018 pub_heading.publish(msg)
00019 print "The upper layer published successfully!"
00020
00021 def runaway_headingCB(msg):
00022 global time_unit
00023 global time_unit_amount
00024 global time_start
00025 time_end = time.time()
00026 pub_heading = rospy.Publisher('/suppressor/turn/heading', Heading, queue_size=10)
00027 if (time_end - time_start) > (time_unit * time_unit_amount):
00028 pub_heading.publish(msg)
00029 print "The upper layer didn't work, the lower layer instead!"
00030
00031 def avoid_runaway_suppressor():
00032 rospy.init_node('avoid_runaway_suppressor')
00033 rospy.Subscriber("/avoid/suppressor/heading", Heading, avoid_headingCB)
00034 rospy.Subscriber("/runaway/suppressor/heading", Heading, runaway_headingCB)
00035 rospy.spin()
00036
00037 if __name__ == '__main__':
00038 try:
00039 avoid_runaway_suppressor()
00040 except rospy.ROSInterruptException:
00041 print "Program interrupted before completion"
00042
00043