comparison python/event.py @ 59:f955e83da499

developed indicators in interactions
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 29 Oct 2010 01:55:00 -0400
parents 61fe73df2d36
children ded58c424783
comparison
equal deleted inserted replaced
58:40e1508380ed 59:f955e83da499
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 '''Libraries for events 2 '''Libraries for events
3 Interactions, pedestrian crossing...''' 3 Interactions, pedestrian crossing...'''
4 4
5 #import utils; 5 #import utils;
6 import moving
6 7
7 __metaclass__ = type 8 __metaclass__ = type
8 9
9 class Interaction(STObject): 10 class Interaction(moving.STObject):
10 '''Class for an interaction between two road users 11 '''Class for an interaction between two road users
11 or a road user and an obstacle 12 or a road user and an obstacle
12 13
13 link to the moving objects 14 link to the moving objects
14 ''' 15 '''
15 16
16 def __init__(self, num = None, timeInterval = None, roaduserNum1 = None, roaduserNum2 = None, movingObject1 = None, movingObject2 = None): 17 categories = {'headon': 0,
17 STObject.__init__(self, num, timeInterval) 18 'rearend': 1,
19 'side': 2,
20 'parallel': 3}
21
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)
18 self.roaduserNum1 = roaduserNum1 24 self.roaduserNum1 = roaduserNum1
19 self.roaduserNum2 = roaduserNum2 25 self.roaduserNum2 = roaduserNum2
20 self.movingObject1 = movingObject1 26 self.movingObject1 = movingObject1
21 self.movingObject2 = movingObject2 27 self.movingObject2 = movingObject2
28 self.categoryNum = categoryNum
22 29
23 class Crossing(STObject): 30 def getIndicator(self, indicatorName):
31 if hasattr(self, 'indicators'):
32 for i in self.indicators:
33 if i.name == indicatorName:
34 return i
35 else:
36 return None
37
38 class Crossing(moving.STObject):
24 '''Class for the event of a street crossing 39 '''Class for the event of a street crossing
25 40
26 TODO: detecter passage sur la chaussee 41 TODO: detecter passage sur la chaussee
27 identifier origines et destination (ou uniquement chaussee dans FOV) 42 identifier origines et destination (ou uniquement chaussee dans FOV)
28 carac traversee 43 carac traversee
29 detecter proximite veh (retirer si trop similaire simultanement 44 detecter proximite veh (retirer si trop similaire simultanement
30 carac interaction''' 45 carac interaction'''
31 46
32 def __init__(self, roaduserNum = None, num = None, timeInterval = None): 47 def __init__(self, roaduserNum = None, num = None, timeInterval = None):
48 moving.STObject.__init__(self, num, timeInterval)
33 self.roaduserNum = roaduserNum 49 self.roaduserNum = roaduserNum
34 self.num = num
35 self.timeInterval = timeInterval
36 50
37 51
38 52
39 if __name__ == "__main__": 53 if __name__ == "__main__":
40 import doctest 54 import doctest