comparison python/prediction.py @ 928:063d1267585d

work in progress
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 12 Jul 2017 01:24:31 -0400
parents 40994bb43148
children b67a784beb69
comparison
equal deleted inserted replaced
927:c030f735c594 928:063d1267585d
49 self.predictedSpeedOrientations = {0: moving.NormAngle.fromPoint(initialVelocity)} 49 self.predictedSpeedOrientations = {0: moving.NormAngle.fromPoint(initialVelocity)}
50 50
51 def getControl(self): 51 def getControl(self):
52 return self.control 52 return self.control
53 53
54 def findNearestParams(initialPosition,prototypeTrajectory): 54 def findNearestParams(initialPosition, prototypeTrajectory):
55 ''' nearest parameters are the index of minDistance and the orientation ''' 55 ''' nearest parameters are the index of minDistance and the orientation '''
56 distances=[] 56 distances=[]
57 for position in prototypeTrajectory.positions: 57 for position in prototypeTrajectory.positions:
58 distances.append(moving.Point.distanceNorm2(initialPosition, position)) 58 distances.append(moving.Point.distanceNorm2(initialPosition, position))
59 minDistanceIndex= np.argmin(distances) 59 minDistanceIndex= np.argmin(distances)
69 1. at constant speed (the instantaneous user speed) 69 1. at constant speed (the instantaneous user speed)
70 2. following the trajectory path, at the speed of the user 70 2. following the trajectory path, at the speed of the user
71 (applying a constant ratio equal 71 (applying a constant ratio equal
72 to the ratio of the user instantaneous speed and the trajectory closest speed)''' 72 to the ratio of the user instantaneous speed and the trajectory closest speed)'''
73 73
74 def __init__(self, initialPosition, initialVelocity, prototypeTrajectory, constantSpeed = True, probability = 1.): 74 def __init__(self, initialPosition, initialVelocity, prototypeTrajectory, constantSpeed = False, probability = 1.):
75 self.prototypeTrajectory = prototypeTrajectory 75 self.prototypeTrajectory = prototypeTrajectory
76 self.constantSpeed = constantSpeed 76 self.constantSpeed = constantSpeed
77 self.probability = probability 77 self.probability = probability
78 self.predictedPositions = {0: initialPosition} 78 self.predictedPositions = {0: initialPosition}
79 self.predictedSpeedOrientations = {0: moving.NormAngle(moving.NormAngle.fromPoint(initialVelocity).norm, findNearestParams(initialPosition,prototypeTrajectory)[1])}#moving.NormAngle.fromPoint(initialVelocity)} 79 self.predictedSpeedOrientations = {0: moving.NormAngle(moving.NormAngle.fromPoint(initialVelocity).norm, findNearestParams(initialPosition,prototypeTrajectory)[1])}#moving.NormAngle.fromPoint(initialVelocity)}