3 PKG =
'pr2_power_board'
4 NAME =
'fake_powerboard'
6 import roslib; roslib.load_manifest(PKG)
14 from optparse
import OptionParser
21 threading.Thread.__init__(self)
26 self.
pb = PowerBoardState()
27 self.
pb.header.stamp = rospy.rostime.get_rostime()
28 self.
pb.serial_num = 9999
29 self.
pb.input_voltage = 80.123456
30 self.
pb.circuit_state = [3,3,3]
31 self.
pb.circuit_voltage = [70.123456,70.234567,70.345678]
32 if self.
options.run_stop: self.
pb.run_stop = 1
33 else: self.
pb.run_stop = 0
34 if self.
options.wireless_stop: self.
pb.wireless_stop = 1
35 else: self.
pb.wireless_stop = 0
37 self.
pub = rospy.Publisher(
"power_board/state", PowerBoardState)
40 if msg.command ==
"disable":
41 self.
pb.circuit_state[msg.breaker_number] = 0
42 self.
pb.circuit_voltage[msg.breaker_number] = 1
43 if msg.command ==
"stop":
44 if self.
pb.circuit_state[msg.breaker_number] != 0:
45 self.
pb.circuit_state[msg.breaker_number] = 1
46 self.
pb.circuit_voltage[msg.breaker_number] = 19
47 if msg.command ==
"reset":
48 if self.
pb.circuit_state[msg.breaker_number] == 0:
49 self.
pb.circuit_state[msg.breaker_number] = 1
50 if msg.command ==
"start":
51 if self.
pb.circuit_state[msg.breaker_number] != 0:
52 self.
pb.circuit_state[msg.breaker_number] = 3
53 self.
pb.circuit_voltage[msg.breaker_number] = 70
57 self.
pub.publish(self.
pb)
61 rospy.init_node(NAME, anonymous=
True)
63 s = rospy.Service(
'power_board/control', PowerBoardCommand, pb.power_board_control)
69 if __name__ ==
'__main__':
70 parser = OptionParser()
71 parser.add_option(
'-r',
'--run_stop', action=
'store_false', default=
True)
72 parser.add_option(
'-w',
'--wireless_stop', action=
'store_false', default=
True)
73 (options, args) = parser.parse_args()
77 except KeyboardInterrupt
as e: