def estimateSample(self, interpolationSample, time):
     estimatedSample = PredictionSample()
     estimatedSample.sample.time = time
     estimatedSample.sample.position = self.calculatePosition(
         interpolationSample, time)
     estimatedSample.velocity = deepcopy(interpolationSample.velocity)
     return estimatedSample
Example #2
0
    def calcExtrapolationSample(self, currentSample, targetSample):
        deltaPosition = targetSample.position - currentSample.position
        deltaTime = targetSample.time - currentSample.time
        invDeltaTimeVector = Vector(1 / float(deltaTime), 1 / float(deltaTime), 1 / float(deltaTime))
        velocity = deltaPosition * invDeltaTimeVector

        extrapolationSample = PredictionSample()
        extrapolationSample.sample = deepcopy(currentSample)
        extrapolationSample.velocity = velocity
        return extrapolationSample
Example #3
0
    def calcExtrapolationSample(self, snapSample, targetSample):
        deltaPosition = targetSample.position - snapSample.position
        deltaTime = targetSample.time - snapSample.time
        invDeltaTimeVector = Vector( 1 / float(deltaTime), \
                                     1 / float(deltaTime), \
                                     1 / float(deltaTime))
        velocity = deltaPosition * invDeltaTimeVector

        extrapolationSample = PredictionSample()
        extrapolationSample.sample = deepcopy(snapSample)
        extrapolationSample.velocity = velocity
        return extrapolationSample
Example #4
0
 def findInterpolationSample(self, currentSample, targetSample):
     deltaPosition = targetSample.position - \
                     currentSample.position
     deltaTime = targetSample.time - \
                 currentSample.time
     invDeltaTimeVector = Vector( 1 / float(deltaTime), \
                                  1 / float(deltaTime), \
                                  1 / float(deltaTime))
     velocity = deltaPosition * invDeltaTimeVector
     
     interpolationSample = PredictionSample()
     interpolationSample.sample = deepcopy(currentSample)
     interpolationSample.velocity = velocity
     return interpolationSample
    def findInterpolationSample(self, currentSample, targetSample):
        deltaPosition = targetSample.sample.position - \
                        currentSample.sample.position
        deltaTime = targetSample.sample.time - \
                    currentSample.sample.time
        invDeltaTimeVector = Vector( 1 / float(deltaTime), \
                                     1 / float(deltaTime), \
                                     1 / float(deltaTime))
        velocity = deltaPosition * invDeltaTimeVector

        interpolationSample = PredictionSample()
        interpolationSample.sample = deepcopy(currentSample.sample)
        interpolationSample.velocity = velocity
        return interpolationSample
Example #6
0
    def executeAlgorithm(self):
        self.predictedData = []

        for index, sample in enumerate(self.inputData):
            if sample.time < self.predictionInterval:
                # Set initial values
                predictionSample = PredictionSample()
                predictionSample.sample = copy(sample)
                predictionSample.velocity = Vector()
                self.predictedData.append(predictionSample)
            else:
                shift = index - self.predictionInterval / self.samplingInterval

                # Calculate velocity
                deltaPosition = self.inputData[index].position - \
                                self.inputData[shift].position
                deltaTime = self.inputData[index].time - \
                            self.inputData[shift].time
                invDeltaTimeVector = Vector( 1 / float(deltaTime), \
                                             1 / float(deltaTime), \
                                             1 / float(deltaTime))
                velocity = deltaPosition * invDeltaTimeVector

                # Populate data structures
                predictionSample = PredictionSample()
                predictionSample.sample = copy(sample)
                predictionSample.velocity = velocity
                self.predictedData.append(predictionSample)
    def executeAlgorithm(self):
        self.reconstructedSignal = []
        self.reconstructedSignal.append(deepcopy(self.rawSignal[0].sample))
        extrapolationSample = self.rawSignal[0]
        futureExtrapolationSample = None
        nextTimeToRecord = self.reconstructedSignal[0].time + 1

        tempRawSignal = self.rawSignal[1:]
        for index, predictionSample in enumerate(tempRawSignal):
            while predictionSample.sample.time > nextTimeToRecord:
                if futureExtrapolationSample != None and \
                   futureExtrapolationSample.sample.time == nextTimeToRecord:
                    extrapolationSample = futureExtrapolationSample
                    futureExtrapolationSample = None
                    self.reconstructedSignal.append(
                        deepcopy(extrapolationSample.sample))
                else:
                    estimatedSample = self.estSample(extrapolationSample,
                                                     nextTimeToRecord)
                    self.reconstructedSignal.append(deepcopy(estimatedSample))

                nextTimeToRecord += 1

            lastEstimatedSample = self.reconstructedSignal[-1]
            targetSample = self.calcTargetSample(predictionSample)
            snapSample = self.calcSnapSample(predictionSample.sample,
                                             lastEstimatedSample)
            extrapolationSample = self.calcExtrapolationSample(
                snapSample, targetSample)
            futureExtrapolationSample = PredictionSample(
                targetSample, predictionSample.velocity)
            self.reconstructedSignal.append(deepcopy(snapSample))
            nextTimeToRecord += 1
Example #8
0
 def executeAlgorithm(self):
     self.reconstructedSignal = []
     nextTimeToRecord = 0
     timeDiff = self.rawSignal[0].sample.time % self.samplingInterval
     if timeDiff == 0:
         self.reconstructedSignal.append( deepcopy(self.rawSignal[0].sample) )
         nextTimeToRecord = self.rawSignal[0].sample.time + \
                            self.samplingInterval
     else:
         change = self.samplingInterval - timeDiff
         newSample = Sample()
         newSample.time = self.rawSignal[0].sample.time + change
         newSample.position = deepcopy(self.rawSignal[0].sample.position)
         self.reconstructedSignal.append(newSample)
         nextTimeToRecord = newSample.time + self.samplingInterval
         
     interpolationSample = PredictionSample()
     interpolationSample.sample = self.reconstructedSignal[0]
     interpolationSample.velocity = self.rawSignal[0].velocity
     for index, predictionSample in enumerate(self.rawSignal):
         if predictionSample.sample.time == nextTimeToRecord:
             estimatedSample = self.calculateEstSample(interpolationSample, \
                                                       nextTimeToRecord)
             self.reconstructedSignal.append(estimatedSample)
             targetSample = self.findTarget(predictionSample)
             interpolationSample = self.findInterpolationSample(estimatedSample, \
                                                                targetSample)
             nextTimeToRecord = nextTimeToRecord + self.samplingInterval
         elif predictionSample.sample.time > nextTimeToRecord:
             while predictionSample.sample.time > nextTimeToRecord:
                 estimatedSample = self.calculateEstSample(interpolationSample, \
                                                           nextTimeToRecord)
                 self.reconstructedSignal.append(estimatedSample)
                 nextTimeToRecord = nextTimeToRecord + self.samplingInterval
                 
             if predictionSample.sample.time == nextTimeToRecord:
                 estimatedSample = self.calculateEstSample(interpolationSample, \
                                                       nextTimeToRecord)
                 self.reconstructedSignal.append(estimatedSample)
                 targetSample = self.findTarget(predictionSample)
                 interpolationSample = self.findInterpolationSample(estimatedSample, \
                                                                    targetSample)
                 nextTimeToRecord = nextTimeToRecord + self.samplingInterval
             else:
                 targetSample = self.findTarget(predictionSample)
                 interpolationSample = self.findInterpolationSample(self.reconstructedSignal[-1], \
                                                                    targetSample)
    def findSnapSample(self, currentSample, estimatedSample, targetSample):
        deltaPosition = targetSample.sample.position - \
                        currentSample.sample.position
        deltaPosition.x *= self.snapLimit
        deltaPosition.y *= self.snapLimit
        deltaPosition.z *= self.snapLimit
        snapPosition = currentSample.sample.position + deltaPosition

        deltaPosition = targetSample.sample.position - snapPosition
        deltaTime = targetSample.sample.time - \
                    currentSample.sample.time
        invDeltaTimeVector = Vector( 1 / float(deltaTime), \
                                     1 / float(deltaTime), \
                                     1 / float(deltaTime))
        velocity = deltaPosition * invDeltaTimeVector

        snapSample = PredictionSample()
        snapSample.sample = Sample(currentSample.sample.time, snapPosition)
        snapSample.velocity = velocity
        return snapSample
    def findSnapSample(self, currentSample, estimatedSample, targetSample):
		deltaPosition = targetSample.sample.position - \
		                currentSample.sample.position
		deltaPosition.x *= self.snapLimit
		deltaPosition.y *= self.snapLimit
		deltaPosition.z *= self.snapLimit
		snapPosition = currentSample.sample.position + deltaPosition
		
		deltaPosition = targetSample.sample.position - snapPosition
		deltaTime = targetSample.sample.time - \
		            currentSample.sample.time
		invDeltaTimeVector = Vector( 1 / float(deltaTime), \
		                             1 / float(deltaTime), \
		                             1 / float(deltaTime))
		velocity = deltaPosition * invDeltaTimeVector
		
		snapSample = PredictionSample()
		snapSample.sample = Sample(currentSample.sample.time, snapPosition)
		snapSample.velocity = velocity
		return snapSample
Example #11
0
 def executeAlgorithm(self):
     self.predictedData = []
     
     for index, sample in enumerate(self.inputData):
         if sample.time < self.predictionInterval:
             # Set initial values
             predictionSample = PredictionSample()
             predictionSample.sample = copy(sample)
             predictionSample.velocity = Vector()
             self.predictedData.append( predictionSample )
         else:
             shift = index - self.predictionInterval / self.samplingInterval
             
             # Calculate velocity
             deltaPosition = self.inputData[index].position - \
                             self.inputData[shift].position
             deltaTime = self.inputData[index].time - \
                         self.inputData[shift].time
             invDeltaTimeVector = Vector( 1 / float(deltaTime), \
                                          1 / float(deltaTime), \
                                          1 / float(deltaTime))
             velocity = deltaPosition * invDeltaTimeVector
                            
             # Populate data structures  
             predictionSample = PredictionSample()            
             predictionSample.sample = copy(sample)
             predictionSample.velocity = velocity
             self.predictedData.append( predictionSample )
             
Example #12
0
    def executeAlgorithm(self):
		self.reconstructedSignal = []
		self.reconstructedSignal.append( self.findFirstSample() )
		reconstructionTime = self.reconstructedSignal[0].time + self.samplingInterval
		interpolationSample = PredictionSample(self.reconstructedSignal[0], 
		     								   self.rawSignal[0].velocity)
		targetSample = None
		
		for index, predictionSample in enumerate(self.rawSignal[1:]):
			currentTime = predictionSample.sample.time
			if currentTime < reconstructionTime:
				estimatedSample = self.estimateSample(interpolationSample,
													  currentTime)
				targetSample = self.findTarget(predictionSample)
				interpolationSample = self.findInterpolationSample(estimatedSample, targetSample)
			elif currentTime == reconstructionTime:
				previousEstimatedSample = self.estimateSample(interpolationSample,
													          reconstructionTime - self.samplingInterval)
				targetSample = self.findTarget(predictionSample)
				interpolationSample = self.findInterpolationSample(previousEstimatedSample, targetSample)
				estimatedSample = self.estimateSample(interpolationSample,
													  reconstructionTime)
				self.reconstructedSignal.append(deepcopy(estimatedSample.sample))
				reconstructionTime += self.samplingInterval
			elif currentTime > reconstructionTime:
				while currentTime > reconstructionTime:
					if targetSample != None and reconstructionTime >= targetSample.sample.time:
						interpolationSample = targetSample
						targetSample = None
					
					estimatedSample = self.estimateSample(interpolationSample, 
					     								  reconstructionTime)
					self.reconstructedSignal.append(deepcopy(estimatedSample.sample))
					reconstructionTime += self.samplingInterval
					
					
				
				if currentTime < reconstructionTime:
					estimatedSample = self.estimateSample(interpolationSample,
														  currentTime)
					targetSample = self.findTarget(predictionSample)
					interpolationSample = self.findInterpolationSample(estimatedSample, targetSample)
				elif currentTime == reconstructionTime:
					previousEstimatedSample = self.estimateSample(interpolationSample,
														          reconstructionTime - self.samplingInterval)
					targetSample = self.findTarget(predictionSample)
					interpolationSample = self.findInterpolationSample(previousEstimatedSample, targetSample)
					estimatedSample = self.estimateSample(interpolationSample,
														  reconstructionTime)
					self.reconstructedSignal.append(deepcopy(estimatedSample.sample))
					reconstructionTime += self.samplingInterval
Example #13
0
    def estimateSample(self, interpolationSample, time):
		estimatedSample = PredictionSample()
		estimatedSample.sample.time = time
		estimatedSample.sample.position = self.calculatePosition(interpolationSample, time)
		estimatedSample.velocity = deepcopy(interpolationSample.velocity)
		return estimatedSample