dump_depth_error.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from jsk_recognition_msgs.msg import DepthErrorResult, PlotData
5 import numpy as np
6 import csv
7 
8 grid = 0.1 # 10 cm
9 bins = {}
10 
11 data = PlotData()
12 
13 def callback(msg):
14  bin_index = int(msg.true_depth / grid)
15  if not bins.has_key(bin_index):
16  bins[bin_index] = []
17  err = msg.true_depth - msg.observed_depth
18  bins[bin_index].append((msg, err))
19  for bin_index, msg_and_errs in bins.items():
20  if len(msg_and_errs) < 5:
21  continue
22  print("Bin: {0}m ~ {1}m".format(grid * bin_index, grid * (bin_index + 1)))
23  print(" Sample:", len(msg_and_errs))
24  errs = [err for (msg, err) in msg_and_errs]
25  mean = np.mean(errs, axis=0)
26  stddev = np.std(errs, axis=0)
27  print(" Mean:", mean)
28  print(" Stddev:", stddev)
29  data.xs.append(msg.true_depth)
30  data.ys.append(msg.observed_depth)
31  pub.publish(data)
32  writer.writerow([msg.true_depth, msg.observed_depth])
33 
34 
35 if __name__ == "__main__":
36  rospy.init_node("plot_depth_error")
37  csv_path = rospy.get_param("~csv_path", "output.csv")
38  pub = rospy.Publisher("~scatter", PlotData, queue_size=1)
39  f = open(csv_path, "w")
40  writer = csv.writer(f)
41  sub = rospy.Subscriber("/depth_image_error/output", DepthErrorResult, callback)
42  rospy.spin()
43 


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:46