37 from __future__
import division
39 PKG =
'pr2_counterbalance_check' 46 import rostest, unittest
56 return minv + (maxv - minv) * i / num_pts
61 for i
in range(params.num_lifts):
63 lift_data.lift_position =
get_position(params.min_lift, params.max_lift, params.num_lifts, i)
64 lift_data.flex_data = []
66 for j
in range(params.num_flexes):
68 fd.flex_position =
get_position(params.min_flex, params.max_flex, params.num_flexes, j)
71 fd.lift_hold.position_avg = lift_data.lift_position
72 fd.lift_hold.position_sd = 0.0
73 fd.lift_hold.effort_avg = j / 100.0 - params.num_flexes/200.0
74 fd.lift_hold.effort_sd = 0.0
77 fd.flex_hold.position_avg = fd.flex_position
78 fd.flex_hold.position_sd = 0.0
79 fd.flex_hold.effort_avg = j / 100.0 - params.num_flexes/200.0
80 fd.flex_hold.effort_sd = 0.0
82 lift_data.flex_data.append(fd)
84 data.lift_data.append(lift_data)
92 self.params.lift_dither = 5.0
93 self.params.flex_dither = 5.0
94 self.params.lift_joint =
'lift_joint' 95 self.params.flex_joint =
'flex_joint' 96 self.params.timeout_hit =
False 97 self.params.flex_test =
True 98 self.params.lift_mse = 1.0
99 self.params.lift_avg_abs = 1.0
100 self.params.lift_avg_eff = 1.0
101 self.params.flex_mse = 1.0
102 self.params.flex_avg_abs = 1.0
103 self.params.flex_avg_eff = 1.0
105 self.params.screw_tol = 2.0
106 self.params.bar_tol = 0.8
108 self.params.num_lifts = 8
109 self.params.min_lift = -0.2
110 self.params.max_lift = 1.2
112 self.params.num_flexes = 9
113 self.params.min_flex = -1.8
114 self.params.max_flex = -0.2
120 self.
model_file = os.path.join(roslib.packages.get_pkg_dir(PKG),
'cb_data/counterbalance_model.dat')
125 self.assert_(result.result,
"Lift effort result wasn't OK. %s\n%s" % (result.summary, result.html))
129 self.assert_(result.result,
"Flex effort result wasn't OK. %s\n%s" % (result.summary, result.html))
136 Test that CB adjustment runs successfully 140 self.assert_(abs(secondary) < self.params.screw_tol
and abs(bar) < self.params.bar_tol,
141 "Calculated adjustment didn't match. Adjustment: %.2f, %.2f" % (secondary, bar))
144 self.assert_(adjust_result.result,
"Adjustment result was unsuccessful! %s\n%s" % (adjust_result.summary, adjust_result.html))
147 bad_params = copy.deepcopy(self.
params)
148 bad_params.num_lifts = 7
149 bad_params.max_lift = 1.0
155 self.assert_(abs(secondary) > 50
and abs(bar) > 50,
156 "Calculated adjustment successful on bad data. Adjustment: %.2f, %.2f" % (secondary, bar))
166 if __name__ ==
'__main__':
167 rostest.unitrun(PKG,
'test_cb_analysis', TestCounterbalanceAnalysis)
def analyze_lift_efforts(params, data)
Checks shoulder lift efforts against params.
def generate_data(params)
def test_lift_effort(self)
def get_position(minv, maxv, num_pts, i)
def plot_efforts_by_lift_position(params, data, flex_index=-1, lift_calc=True)
Plots CB efforts against shoulder lift position.
def test_flex_effort(self)
def test_adjustment(self)
def check_cb_adjustment(params, data, model_file)
Return CB adjustments to minimize total torque.
def calc_cb_adjust(data, model_file)
Calculates CB adjustment.
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.