test_func.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 ##
00004 # observers_generator.py is a node that finds the nodes and topics and their related information in the running system.
00005 # After finding necessary information it creates launch files in tug_ist_diagnosis_launch package and executes them automatically. 
00006 # Copyright (c).2012. OWNER: Institute for Software Technology, TU Graz Austria.
00007 # Authors: Safdar Zaman, Gerald Steinbauer. (szaman@ist.tugraz.at, steinbauer@ist.tugraz.at)
00008 # All rights reserved.
00009 #    This program is free software: you can redistribute it and/or modify
00010 #    it under the terms of the GNU General Public License as published by
00011 #    the Free Software Foundation, either version 3 of the License, or
00012 #    (at your option) any later version.
00013 #
00014 #    This program is distributed in the hope that it will be useful,
00015 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 #    GNU General Public License for more details.
00018 #
00019 #    You should have received a copy of the GNU General Public License
00020 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021 ##
00022 
00023 import roslib.message; roslib.load_manifest('tug_ist_diagnosis_generator')
00024 import rospy
00025 import sys
00026 import xmlrpclib
00027 import os
00028 import subprocess
00029 import time
00030 import shlex
00031 import thread
00032 from math import sqrt
00033 #import numpy
00034 import numpy
00035 import matplotlib.pyplot as plt
00036 
00037 
00038 
00039 def autocorr(x):
00040     result = numpy.correlate(x, x, mode='full')
00041     return result[result.size/2:]
00042 
00043 def make_func(value_to_print):
00044     def _function():
00045         print value_to_print
00046     return _function
00047 
00048 f1 = make_func(1)
00049 #f1()
00050 f2 = make_func(2)
00051 #f2()
00052 
00053 
00054 #print autocorr([1, 0, 1, 0, 1, 0, 1, 0])
00055 #print autocorr([1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0])
00056 x = [1, 0, 1, 0, 1, 0, 1, 0]
00057 s1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0]
00058 #s2 = [1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1]
00059 s2 = [0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1]
00060 m1 = numpy.mean(s1)
00061 m2 = numpy.mean(s2)
00062 s11 = s1-m1
00063 s22 = s2-m2
00064 r1 = numpy.correlate(s11, s11, mode='full')
00065 r2 = numpy.correlate(s22, s22, mode='full')
00066 r1 = r1 * len(s1)
00067 r2 = r2 * len(s2)
00068 
00069 
00070 #signal = NP.array([3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,7,7,7,7,7,4,4,1,1,1,1,1,1,1])
00071 #signal = NP.array([1,0,1,0,1,0,1,0,1,0,1,0,1])
00072 #px, = NP.where(NP.ediff1d(signal) != 0)
00073 #px = NP.r_[(0, px+1, [len(signal)])]
00074 # collect the run-lengths for each unique item in the signal
00075 #rx = [ (m, n, signal[m]) for (m, n) in zip(px[:-1], px[1:]) ]
00076 
00077 #print r1
00078 #print r2
00079 #plt.plot(r2)
00080 #plt.show()
00081 s1 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0]
00082 s2 = [1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0]
00083 s3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
00084 s1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
00085 print numpy.correlate(s1, s3)
00086 
00087 


tug_ist_diagnosis_generator
Author(s): Safdar Zaman, Gerald Steinbauer
autogenerated on Mon Jan 6 2014 11:51:14