shaver_switch_pub.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import roslib
00004 roslib.load_manifest('rospy')
00005 roslib.load_manifest('std_msgs')
00006 import rospy, optparse, math, time
00007 import numpy as np
00008 import serial
00009 from std_msgs.msg import Bool
00010 
00011 
00012 class shaver_pub():
00013         def __init__(self):
00014                 self.pub = rospy.Publisher('/ros_switch', Bool)
00015                 rospy.init_node('shaver_pwr_pub', anonymous = True)
00016                 rospy.logout('shaver_pwr_pub node publishing..')
00017                 self.state = False
00018                 self.pwr_on = 'Power is on'
00019                 self.pwr_off = 'Power is off'
00020 
00021 
00022         def input_state(self):
00023                 raw_input("\nPress Enter to Toggle")
00024                 self.state = not self.state
00025                 self.pub.publish(Bool(self.state))
00026                 if self.state:
00027                         print self.pwr_on
00028                 else:
00029                         print self.pwr_off
00030 
00031 if __name__ == '__main__':
00032         pwr = shaver_pub()
00033         while not rospy.is_shutdown():
00034                 pwr.input_state()
00035 


adl_pr2_log
Author(s): Aaron King
autogenerated on Wed Nov 27 2013 12:19:09