38 PKG =
'pr2_counterbalance_check' 39 from pr2_counterbalance_check
import *
42 from joint_qualification_controllers.msg
import CounterbalanceTestData
44 from optparse
import OptionParser
48 from ros
import rosrecord
52 CB_MSG_TYPE =
'joint_qualification_controllers/CounterbalanceTestData' 55 for topic, msg, t
in rosrecord.logplayer(bag):
56 return CounterbalanceAnalysisData(msg)
59 print "./counterbalance_training cb_bag1 cb_bag2 cb_bag3 ..." 60 print "Determines counterbalance adjustments necessary to tune CB" 61 print "Bags must have one message of type %s" % CB_MSG_TYPE
64 if __name__ ==
'__main__':
65 if len(sys.argv) < 2
or sys.argv[1] ==
'-h' or sys.argv[1] ==
'--help':
72 print 'Enter CB adjustments from "zero" in turns CW for each bag' 74 if not os.path.exists(b):
75 print >> sys.stderr,
"Bag %s does not exist. Check filename and retry" % b
80 adj_secondary = float(raw_input(
"Please enter secondary adjustment (turns CW) for bag %s: "%b))
81 adj_cb_bar = float(raw_input(
"Please enter CB bar adjustment (turns CW) for bag %s: "%b))
82 adjustments[b] = (adj_secondary, adj_cb_bar, 1)
84 print "Invalid input for adjustment. Floating point values expected." 90 B = numpy.array([efforts[b]
for b
in bags])
91 A = numpy.array([adjustments[b]
for b
in bags])
92 X = numpy.linalg.lstsq(A, B)
94 model.dump(
'counterbalance_model.dat')
95 print '\"counterbalance_model.dat\" contains CB adjustment values'
def get_efforts(data, lift_calc)
Get average efforts for CB test as a list.