razor_runstop.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
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         #TODO: TOOLSTATE VARIABLE HAS NO CONNECTION TO REAL ON/OFF STATE OF TOOL
00026         # THIS MAKES IT IMPOSSIBLE TO SET THE TOOL TO OFF, WE CAN ONLY TOGGLE
00027         # THIS MAKES THE CURRENT NODE USELESS, NEED TO FIX @ Arduino level first
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()


hrl_face_adls
Author(s): Kelsey Hawkins, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab
autogenerated on Wed Nov 27 2013 11:47:39