#!/usr/bin/env python import rospy from jsk_recognition_msgs.msg import DepthErrorResult, PlotData import numpy as np import csv grid = 0.1 # 10 cm bins = {} data = PlotData() def callback(msg): bin_index = int(msg.true_depth / grid) if not bins.has_key(bin_index): bins[bin_index] = [] err = msg.true_depth - msg.observed_depth bins[bin_index].append((msg, err)) for bin_index, msg_and_errs in bins.items(): if len(msg_and_errs) < 5: continue print "Bin: {0}m ~ {1}m".format(grid * bin_index, grid * (bin_index + 1)) print " Sample:", len(msg_and_errs) errs = [err for (msg, err) in msg_and_errs] mean = np.mean(errs, axis=0) stddev = np.std(errs, axis=0) print " Mean:", mean print " Stddev:", stddev data.xs.append(msg.true_depth)
#!/usr/bin/env python from jsk_recognition_msgs.msg import PlotData import numpy as np import rospy import math if __name__ == "__main__": rospy.init_node("sample_2d_plot") pub = rospy.Publisher("~output", PlotData) r = rospy.Rate(10) offset = 0 while not rospy.is_shutdown(): msg = PlotData() msg.xs = np.arange(0, 5, 0.1) msg.ys = [math.sin(x + offset) for x in msg.xs] pub.publish(msg) offset = offset + 0.1 r.sleep()
#!/usr/bin/env python from jsk_recognition_msgs.msg import PlotData import numpy as np import rospy from numpy.random import * import math if __name__ == "__main__": rospy.init_node("sample_2d_plot") pub = rospy.Publisher("~output", PlotData) r = rospy.Rate(10) offset = 0 while not rospy.is_shutdown(): msg = PlotData() msg.xs = randn(50) msg.ys = randn(50) pub.publish(msg) offset = offset + 0.1 r.sleep()
#!/usr/bin/env python from jsk_recognition_msgs.msg import PlotData import numpy as np import rospy import math from random import random if __name__ == "__main__": rospy.init_node("sample_2d_plot") pub = rospy.Publisher("~output", PlotData) r = rospy.Rate(10) offset = 0 while not rospy.is_shutdown(): msg = PlotData() msg.xs = np.arange(0, 5, 0.1) msg.ys = [math.sin(x + offset) for x in msg.xs] msg.label = "sample data" if random() < 0.5: msg.type = PlotData.LINE else: msg.type = PlotData.SCATTER msg.fit_line = random() < 0.5 msg.fit_line_ransac = random() < 0.5 pub.publish(msg) offset = offset + 0.1 r.sleep()