38 PKG =
'pr2_counterbalance_check' 40 roslib.load_manifest(PKG)
46 from std_msgs.msg
import Bool
47 from joint_qualification_controllers.msg
import CounterbalanceTestData
66 return self.
_data is not None 71 rospy.wait_for_service(
'test_result', 10)
73 rospy.logerr(
'Wait for service \'test_result\' timed out! Unable to send results.')
76 self._result_service.call(r)
82 rospy.logerr(except_str)
83 r = TestResultRequest()
84 r.html_result = except_str
85 r.text_summary =
'Caught exception, automated test failure.' 86 r.result = TestResultRequest.RESULT_FAIL
113 adjust_result.result =
False 114 adjust_result.html =
'<p>CB model file is missing. File %s does not exist. This file is used for testing the CB adjustment.</p>\n' % self.
_model_file 115 adjust_result.summary =
'CB model file missing, unable to analyze' 118 adjust_result.result =
True 119 adjust_result.html =
'<p>Did not check counterbalance adjustment.</p>' 125 html.append(
'<H4>CB Adjustment Recommendations and Analysis</H4>')
126 html.append(adjust_result.html)
127 html.append(
'<p>Further information is for debugging and analysis information only.</p><br><hr size="2" />')
129 html.append(
'<H4>Lift Effort Contour Plot</H4>')
130 html.append(
'<img src=\"IMG_PATH/%s.png\" width=\"640\" height=\"480\" />' % (lift_effort_contour.title))
131 html.append(
'<H4>Flex Effort Contour Plot</H4>')
132 html.append(
'<img src=\"IMG_PATH/%s.png\" width=\"640\" height=\"480\" />' % (flex_effort_contour.title))
134 html.append(
'<H4>Flex Effort Analysis</H4>')
135 html.append(flex_effort_result.html)
137 html.append(
'<H4>Lift Effort Analysis</H4>')
138 html.append(lift_effort_result.html)
139 html.append(
'<img src=\"IMG_PATH/%s.png\" width=\"640\" height=\"480\" />' % (lift_effort_plot.title))
141 html.append(
'<p>Test Parameters</p>')
142 html.append(
'<table border="1" cellpadding="2" cellspacing="0">')
143 html.append(
'<tr><td><b>Joint</b></td><td><b>Dither Amplitude</b></td></tr>')
144 html.append(
'<tr><td>%s</td><td>%s</td></tr>' % (params.lift_joint, params.lift_dither))
146 html.append(
'<tr><td>%s</td><td>%s</td></tr>' % (params.flex_joint, params.flex_dither))
147 html.append(
'</table>')
148 html.append(
'<hr size=2>')
150 r = TestResultRequest()
151 r.html_result =
'\n'.join(html)
152 r.text_summary =
' '.join([lift_effort_result.summary])
154 r.text_summary =
' '.join([r.text_summary, flex_effort_result.summary])
156 r.result = TestResultRequest.RESULT_HUMAN_REQUIRED
159 if params.flex_test
and (lift_effort_result.result
and 160 flex_effort_result.result
and 161 adjust_result.result):
162 r.result = TestResultRequest.RESULT_PASS
163 elif not params.flex_test
and lift_effort_result.result:
164 r.result = TestResultRequest.RESULT_PASS
167 r.plots = [ lift_effort_plot ]
169 r.plots.append(lift_effort_contour)
170 r.plots.append(flex_effort_contour)
171 r.params = params.get_test_params()
172 r.values = lift_effort_result.values
174 r.values.extend(flex_effort_result.values)
175 r.values.extend(adjust_result.values)
178 if params.flex_test
and not adjust_result.result:
179 r.result = TestResultRequest.RESULT_HUMAN_REQUIRED
180 r.text_summary = adjust_result.summary
184 r.text_summary =
'Fail, motors halted. Check estop and power board.' 185 r.html_result =
'<H4>Motors Halted</H4>\n<p>Unable to analyze CB. Check estop and power board.</p>\n' + r.html_result
186 r.result = TestResultRequest.RESULT_FAIL
189 if params.timeout_hit:
190 r.text_summary =
'Fail, controller timeout hit. Timeout = %.ds. Test terminated early.' % (int(params.named_params[
"Timeout"]))
191 r.html_result =
'<H4>Timeout Hit</H4>\n<p>Unable to analyzer CB. Controller timeout hit.</p>\n' + r.html_result
192 r.result = TestResultRequest.RESULT_FAIL
201 if __name__ ==
'__main__':
202 rospy.init_node(
'cb_analyzer')
205 my_rate = rospy.Rate(5)
206 while not app.has_data()
and not rospy.is_shutdown():
209 if not rospy.is_shutdown():
210 app.process_results()
213 except KeyboardInterrupt, e:
216 print 'Caught Exception in CB application' 218 traceback.print_exc()
219 result_service = rospy.ServiceProxy(
'test_result', TestResult)
221 r = TestResultRequest()
222 r.html_result = traceback.format_exc()
223 r.text_summary =
'Caught exception, automated test failure.' 225 r.result = TestResultRequest.RESULT_HUMAN_REQUIRED
226 result_service.call(r)
def _motors_cb(self, msg)
def test_failed_service_call(self, except_str='')
def analyze_lift_efforts(params, data)
Checks shoulder lift efforts against params.
Stores parameters from CB analysis test.
def process_results(self)
def send_results(self, r)
def plot_efforts_by_lift_position(params, data, flex_index=-1, lift_calc=True)
Plots CB efforts against shoulder lift position.
def _data_callback(self, msg)
def check_cb_adjustment(params, data, model_file)
Return CB adjustments to minimize total torque.
def plot_effort_contour(params, data, lift_calc=True)
Gives effort contour plot of efforts by lift, flex position.
def analyze_flex_efforts(params, data)
Checks shoulder flex efforts against params.