# HG changeset patch # User Nicolas Saunier # Date 1435633798 14400 # Node ID 9a258687af4c165316b0bdbb24193437d5c5f97b # Parent fa9aa5f08210efd9c43d9421ccd4eaf336903763 corrected some errors for ttc diff -r fa9aa5f08210 -r 9a258687af4c python/events.py --- a/python/events.py Mon Jun 29 16:15:04 2015 -0400 +++ b/python/events.py Mon Jun 29 23:09:58 2015 -0400 @@ -217,7 +217,8 @@ self.collisionPoints, crossingZones = predictionParameters.computeCrossingsCollisions(self.roadUser1, self.roadUser2, collisionDistanceThreshold, timeHorizon, computeCZ, debug, commonTimeInterval, nProcesses,usePrototypes,route1,route2,prototypes,secondStepPrototypes,nMatching,objects,noiseEntryNums,noiseExitNums,minSimilarity,mostMatched,useDestination,useSpeedPrototype,acceptPartialLength, step) for i, cp in self.collisionPoints.iteritems(): TTCs[i] = prediction.SafetyPoint.computeExpectedIndicator(cp) - self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[7], TTCs, mostSevereIsMax=False)) + if len(TTCs) > 0: + self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[7], TTCs, mostSevereIsMax=False)) # crossing zones and pPET if computeCZ: diff -r fa9aa5f08210 -r 9a258687af4c python/indicators.py --- a/python/indicators.py Mon Jun 29 16:15:04 2015 -0400 +++ b/python/indicators.py Mon Jun 29 23:09:58 2015 -0400 @@ -152,6 +152,13 @@ else: return None + def getInstantOfMostSevereValue(self): + '''Returns the instant at which the indicator reaches its most severe value''' + if self.mostSevereIsMax: + return max(self.values, key=self.values.get) + else: + return min(self.values, key=self.values.get) + # functions to aggregate discretized maps of indicators # TODO add values in the cells between the positions (similar to discretizing vector graphics to bitmap) diff -r fa9aa5f08210 -r 9a258687af4c python/prediction.py --- a/python/prediction.py Mon Jun 29 16:15:04 2015 -0400 +++ b/python/prediction.py Mon Jun 29 23:09:58 2015 -0400 @@ -321,8 +321,8 @@ if nProcesses == 1: if usePrototypes: firstInstant= next( (x for x in xrange(commonTimeInterval.first,commonTimeInterval.last) if x-obj1.getFirstInstant() >= acceptPartialLength and x-obj2.getFirstInstant() >= acceptPartialLength), commonTimeInterval.last) - commonTimeIntervalList1= list(xrange(firstInstant,commonTimeInterval.last-1)) # do not look at the 1 last position/velocities, often with errors - commonTimeIntervalList2= list(xrange(firstInstant,commonTimeInterval.last-1,step)) # do not look at the 1 last position/velocities, often with errors + commonTimeIntervalList1= range(firstInstant,commonTimeInterval.last-1) # do not look at the 1 last position/velocities, often with errors + commonTimeIntervalList2= range(firstInstant,commonTimeInterval.last-1,step) # do not look at the 1 last position/velocities, often with errors for i in commonTimeIntervalList2: i, cp, cz = self.computeCrossingsCollisionsAtInstant(i, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ, debug,usePrototypes,route1,route2,prototypes,secondStepPrototypes,nMatching,objects,noiseEntryNums,noiseExitNums,minSimilarity,mostMatched,useDestination,useSpeedPrototype) if len(cp) != 0: @@ -533,19 +533,6 @@ crossingZones = [SafetyPoint(intersection, 1., timeInterval1.distance(timeInterval2))] else: collisionPoints = [SafetyPoint(intersection, 1., collisionTimeInterval.center())] - # elif computeCZ and (dot1 > 0 or dot2 > 0): - # if dot1 > 0: - # firstUser = obj2 # first through crossingzone - # secondUser = obj1 # second through crossingzone - # elif dot2 > 0: - # firstUser = obj1 - # secondUser = obj2 - # p2 = secondUser.getPositionAtInstant(currentInstant) - # v2 = secondUser.getVelocityAtInstant(currentInstant) - # indices, intersections = firstUser.getPositions().getLineIntersections(p2, p2+v2) - # if indices is not None: - # pass - # else: # one has to predict !!! if debug and intersection is not None: from matplotlib.pyplot import plot, figure, axis, title