Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('hrl_face_adls')
00003 import rospy
00004 from std_msgs.msg import Bool
00005 from pr2_msgs.msg import PowerBoardState
00006
00007 class RazorRunStop(object):
00008 def __init__(self):
00009 rospy.Subscriber('/power_board/state', PowerBoardState, self.powbd_cb)
00010 rospy.Subscriber('/ros_switch_state', Bool, self.tool_state_cb)
00011 self.tool_pub = rospy.Publisher('/ros_switch', Bool)
00012 self.tool_state = False
00013
00014 def powbd_cb(self, pbs_msg):
00015 """Check for run-stop activation"""
00016 if not pbs_msg.run_stop or not pbs_msg.wireless_stop:
00017 self.stop_razor()
00018
00019 def tool_state_cb(self, tool_msg):
00020 """Get current tool state"""
00021 self.tool_state = tool_msg.data
00022
00023 def stop_razor(self):
00024 """Toggle Tool State to False if True"""
00025
00026
00027
00028 if self.tool_state:
00029 self.tool_pub.publish(Bool(False))
00030 rospy.loginfo("RUN-STOP DETECTED: Turning off razor")
00031
00032 if __name__=='__main__':
00033 rospy.init_node('razor_runstop')
00034 rrs=RazorRunStop()
00035 rospy.spin()