Go to the documentation of this file.00001
00002
00003 import sys
00004 import numpy as np
00005 import scipy.io
00006 import scipy.stats
00007 import matplotlib.pyplot as plt
00008
00009 import roslib
00010 roslib.load_manifest('hrl_phri_2011')
00011 import rospy
00012
00013 import rosbag
00014
00015 def main():
00016 bag = rosbag.Bag(sys.argv[1], 'r')
00017 x_forces, cur_x_forces = [], []
00018 for topic, msg, t in bag.read_messages(topics=["/l_cart/sensor_ft"]):
00019 f = [msg.wrench.force.x, msg.wrench.force.y, msg.wrench.force.z]
00020 f_mag = np.linalg.norm(f)
00021 if f_mag > 0.5:
00022 cur_x_forces.append(msg.wrench.force.x)
00023 else:
00024 if len(cur_x_forces) >= 20:
00025 x_forces.extend(cur_x_forces)
00026 cur_x_forces = []
00027 if len(cur_x_forces) >= 20:
00028 x_forces.extend(cur_x_forces)
00029 bag.close()
00030 ptile_inds = [25, 50, 75, 95]
00031 ptiles = {}
00032 for ptile in ptile_inds:
00033 ptiles[ptile] = scipy.stats.scoreatpercentile(x_forces, ptile)
00034 print "Percentile %d: %f" % (ptile, ptiles[ptile])
00035
00036
00037
00038 if __name__ == "__main__":
00039 main()