Mercurial > hg > nsaunier > traffic-intelligence
comparison python/event.py @ 283:dbe7e53334d7
added function to create interactions
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 21 Dec 2012 18:20:12 -0500 |
| parents | 857bcd41e9a2 |
| children | 9f81218e497a |
comparison
equal
deleted
inserted
replaced
| 282:abbd4bc13dac | 283:dbe7e53334d7 |
|---|---|
| 19 'side': 2, | 19 'side': 2, |
| 20 'parallel': 3} | 20 'parallel': 3} |
| 21 | 21 |
| 22 def __init__(self, num = None, timeInterval = None, roaduserNum1 = None, roaduserNum2 = None, movingObject1 = None, movingObject2 = None, categoryNum = None): | 22 def __init__(self, num = None, timeInterval = None, roaduserNum1 = None, roaduserNum2 = None, movingObject1 = None, movingObject2 = None, categoryNum = None): |
| 23 moving.STObject.__init__(self, num, timeInterval) | 23 moving.STObject.__init__(self, num, timeInterval) |
| 24 self.roaduserNum1 = roaduserNum1 | 24 self.roaduserNumbers = set([roaduserNum1, roaduserNum2]) |
| 25 self.roaduserNum2 = roaduserNum2 | |
| 26 self.movingObject1 = movingObject1 | 25 self.movingObject1 = movingObject1 |
| 27 self.movingObject2 = movingObject2 | 26 self.movingObject2 = movingObject2 |
| 28 self.categoryNum = categoryNum | 27 self.categoryNum = categoryNum |
| 29 | 28 |
| 30 def getIndicator(self, indicatorName): | 29 def getIndicator(self, indicatorName): |
| 49 collisionCourseCosine[instant] = collisionCourseDotProduct[i]/(distances[i]*deltav.norm2()) | 48 collisionCourseCosine[instant] = collisionCourseDotProduct[i]/(distances[i]*deltav.norm2()) |
| 50 self.indicators = [moving.SeverityIndicator('Collision Course Dot Product', collisionCourseDotProduct, self.timeInterval), | 49 self.indicators = [moving.SeverityIndicator('Collision Course Dot Product', collisionCourseDotProduct, self.timeInterval), |
| 51 moving.SeverityIndicator('Distances', distances, self.timeInterval), | 50 moving.SeverityIndicator('Distances', distances, self.timeInterval), |
| 52 moving.SeverityIndicator('Collision Course Cosine', collisionCourseCosine)] | 51 moving.SeverityIndicator('Collision Course Cosine', collisionCourseCosine)] |
| 53 | 52 |
| 53 def createInteractions(objects): | |
| 54 '''Create all interactions of two co-existing road users | |
| 55 | |
| 56 todo add test to compute categories?''' | |
| 57 interactions = [] | |
| 58 num = 0 | |
| 59 for i in xrange(len(objects)): | |
| 60 for j in xrange(i): | |
| 61 commonTimeInterval = objects[i].commonTimeInterval(objects[j]) | |
| 62 if not commonTimeInterval.empty(): | |
| 63 interactions.append(Interaction(num, commonTimeInterval, objects[i].num, objects[j].num, objects[i], objects[j])) | |
| 64 num += 1 | |
| 65 return interactions | |
| 66 | |
| 54 class Crossing(moving.STObject): | 67 class Crossing(moving.STObject): |
| 55 '''Class for the event of a street crossing | 68 '''Class for the event of a street crossing |
| 56 | 69 |
| 57 TODO: detecter passage sur la chaussee | 70 TODO: detecter passage sur la chaussee |
| 58 identifier origines et destination (ou uniquement chaussee dans FOV) | 71 identifier origines et destination (ou uniquement chaussee dans FOV) |
