2 import roslib; roslib.load_manifest(
"pr2_power_board")
12 current_state = PowerBoardState()
19 if __name__ ==
"__main__":
22 rospy.wait_for_service(
'power_board/control', 5)
24 rospy.init_node(
'test_power')
27 control = rospy.ServiceProxy(
'power_board/control', PowerBoardCommand)
28 state = rospy.Subscriber(
"/power_board/state", PowerBoardState, callback)
34 command_list = [
"start",
"stop"]
38 delay = rospy.Duration(3.0)
42 while (try_count > 0):
44 command = command_list[ try_count % len(command_list) ]
45 print "%d: Requesting %d to %s"%(try_count, breaker_number, command)
48 resp1 =
control(serial, breaker_number, command, flags)
49 print " Response: ", resp1
51 fail_count = fail_count + 1
52 print "Response to control is bad" 55 for x
in current_state.circuit_state:
56 print "Current State: %d" % ( x )
58 if (command ==
"start")
and ( current_state.circuit_state[breaker_number] != PowerBoardState.STATE_ON ):
59 fail_count = fail_count + 1
60 print "FAIL: Test circuit did not turn ON" 62 if (command ==
"stop")
and ( current_state.circuit_state[breaker_number] != PowerBoardState.STATE_STANDBY ):
63 fail_count = fail_count + 1
64 print "FAIL: Test circuit not in STANDBY" 66 if ( current_state.circuit_state[other_breaker1] != PowerBoardState.STATE_ON )
or ( current_state.circuit_state[other_breaker2] != PowerBoardState.STATE_ON ):
67 fail_count = fail_count + 1
68 print "FAIL: The other circuit is not ON" 70 except rospy.ServiceException, e:
71 print "Service call failed: %s"%e
74 try_count = try_count - 1
75 if pause_on_fail
and fail_count > last_fail_count:
77 line = sys.stdin.readline()
78 last_fail_count = fail_count
81 print "Test complete: " 82 print " Test breaker_number = %d" % (breaker_number)
83 print " Fail Count = %d " % (fail_count)