Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 import roslib
00014 roslib.load_manifest('iri_segway_rmp400_odom')
00015 import os
00016 import sys
00017 import rospy
00018 import math
00019 import numpy
00020 import time
00021 from sensor_msgs.msg import Imu
00022
00023 lst_imu = []
00024
00025 def callback_imu(data):
00026 global lst_imu
00027 lst_imu.append(-data.angular_velocity.z)
00028
00029
00030 def get_vector_statistics(name,v):
00031 return str(" "+name+": "+str("%.5f"%numpy.mean(v,dtype=numpy.float64))+" "+str("%.5f"%numpy.std(v,dtype=numpy.float64))+" "+\
00032 str("%.5f"%numpy.std(v, dtype=numpy.float64)**2)+" "+str("%.5f"%numpy.amin(v))+" "+str("%.5f"%numpy.amax(v))+" "+str(len(v)))
00033
00034 def sayonara():
00035 global lst_d_icp,lst_d_mp,nom
00036 f_name = "imu_stats_"+nom+"_"+str(int(time.time()))+".txt"
00037 output = open(f_name, 'w')
00038 print_imu = get_vector_statistics("IMU",lst_imu)
00039 output.write("Experiment: "+nom+"\n")
00040 output.write("Date: "+str(time.asctime(time.localtime(time.time())))+"\n")
00041 output.write("Results: \n")
00042 output.write(" Mean StdDev Cov min max samples\n")
00043 output.write(print_imu)
00044 output.write("\n")
00045 output.write(" -----------------------------------------------------------------------------------------------\n")
00046 output.write("\n")
00047 print ""
00048 print "Experiment: "+nom
00049 print "Date: "+str(time.asctime(time.localtime(time.time())))
00050 print "Results:"
00051 print " Mean StdDev Cov min max samples"
00052 print print_imu
00053 print " -----------------------------------------------------------------------------------------------"
00054 print ""
00055 output.close()
00056 print " Sayonara"
00057
00058
00059 if __name__ == '__main__':
00060 rospy.init_node('error_imu')
00061 print " > IMU Error estimator <"
00062 r = rospy.Rate(100)
00063 rospy.Subscriber('/teo/sensors/imu', Imu, callback_imu)
00064 rospy.on_shutdown(sayonara)
00065 print " Fetching data Yo"
00066 global nom
00067 nom="test"
00068 if len(sys.argv)>1:
00069 nom=sys.argv[1]
00070 rospy.spin()
00071
00072