Ejemplo n.º 1
0
logDir = root + "code/log/"
outputDir = root + "code/output/"
movement = "Stacking"
inputFile = dataRoot + movement + "/Simulation" + str(1) + "/positionLog.txt"
samplingInterval = 10
upperBounds = 1
lowerBounds = 1

# Import data
print "Importing data..."
importer = Importer()
inputData = importer.getInputData(inputFile, samplingInterval)
t1, x1, y1, z1 = sim.splitData(inputData)

# Filter parameters
samplingFreq = 100
taps = 80
bands = [0.0, 10, 11, 50.0]
weights = [1, 0]
coefficients = scipy.signal.remez(taps, bands, weights, Hz=samplingFreq)
gain = 1.0 / sum(coefficients)

filteredData = sim.simulateFilterRecon(inputData, logDir, "cc", samplingInterval, coefficients)[0]
sim.amplifyData(filteredData, gain)
t2, x2, y2, z2 = sim.splitData(filteredData)

# Plot data
pylab.figure(1)
pylab.plot(t1, x1, "k-", t2, x2, "g-")
pylab.show()
Ejemplo n.º 2
0
		coefficients = scipy.signal.remez(taps, bands, weights, Hz=samplingFreq)
		# Window method
		#cutoff = --need to fill this in--
		#coefficients = scipy.signal.firwin(taps, cutoff, window='hamming')
		freqResponse = scipy.signal.freqz(coefficients)
		freq = freqResponse[0] * (samplingFreq/(2 * math.pi))
		magnitude = abs(freqResponse[1])
		phase = numpy.arctan2(freqResponse[1].imag, freqResponse[1].real) * (samplingFreq/(2 * math.pi))
		delay = 0.5 * taps * samplingInterval
		errors = []
		startTimeData = time.time()
		# Use mulitple differenet data sets
		for index, data in enumerate(testData):
			inputData = data[0]
			reconData = data[1]
			filteredData = sim.simulateFilterRecon(reconData, logDir, str(index+1), samplingInterval, coefficients)[0]
			error = sim.findDistanceError(inputData, filteredData)
			mean = numpy.array(error).mean()
			errors.append(mean)
	
		avgError = numpy.array(errors).mean()
		errorCurve.append(avgError)
		delayCurve.append(delay)
		print "\tTime working on the data sets: " + str(time.time() - startTimeData)
	errorCurves.append(errorCurve)
	delayCurves.append(delayCurve)
	print "\tTime working on the different taps: " + str(time.time() - startTimeTaps)
print "\tTotal time working on simulation: " + str(time.time() - startTimeTotal)


# Collect the final data and export
Ejemplo n.º 3
0
			  [ [], [], [] ],
			  [ [], [], [] ],
			  [ [], [], [] ] ]
	for i, data in enumerate(testData):
		simulation = str(i+1)
		inputData = data[0]
		rxPackets = data[1]
		snapReconstruction = data[2]
		snapLimitReconstruction = data[3]
		convergedCloseData = data[4]
		# Simulate convergence
		convergedFarData = sim.simulateLinearConvergence(rxPackets, logDir, simulation, samplingInterval,
		  							  			         interpolationType, farThreshold)[0]
		
		# Simulate filtering
		snapFilteredData = sim.simulateFilterRecon(snapReconstruction, logDir, simulation, samplingInterval, 
										           snapCoefficients)[0]
		sim.amplifyData(snapFilteredData, snapGain)
		
		if convergeTaps != 0:
			convergedFilteredData = sim.simulateFilterRecon(convergedCloseData, logDir, simulation, samplingInterval, 
										                	convergeCoefficients)[0]
			sim.amplifyData(convergedFilteredData, convergeGain)
		else:
			convergedFilteredData = convergedCloseData
			
		if convergeTaps != 0:
			snapLimitFilteredData = sim.simulateFilterRecon(snapLimitReconstruction, logDir, simulation, samplingInterval, 
										                	convergeCoefficients)[0]
			sim.amplifyData(snapLimitFilteredData, convergeGain)
		else:
			snapLimitFilteredData = snapLimitReconstruction
Ejemplo n.º 4
0
packetLoss = 0
varJitterResults = []

for jitter in jitters:
	for i, inputFile in enumerate(inputFiles):
		# Simulate the transmission
		simulationData = sim.simulateTransmission(inputFile, logDir, predictionInterval, 
												  samplingInterval, heartbeat, drThreshold, 
												  delay, jitter, packetLoss)
												
		# Simulate the reconstruction
		simNumber = inputFile.split('/')[-2][-1]
		reconstructionSnap = sim.simulateSnapRecon(simulationData[4], logDir, simNumber, samplingInterval)[0]
		reconstructionInt = sim.simulateLinearConvergence(simulationData[4], logDir, simNumber, samplingInterval,
		  							  				      interpolationType, reconThreshold)[0]
		reconstructionFilter = sim.simulateFilterRecon(reconstructionSnap, logDir, simNumber, samplingInterval, coefficients)[0]
		 sim.amplifyData(reconstructionFilter)
		s  =napError = 1
		intError = 1
		filterError = 1
		varJitterResults.append([snapError, intError, filterError])


# Second -> variable delay, fixed jitter, fixed packet loss
delays = range(10,401,10)
delays.insert(0,1)
jitter = 20
packetLoss = 0
varDelayResults = []

for delay in delays: