changeset 1209:2064e52019db

work on TTC for BEV
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 26 Apr 2023 23:36:32 -0400
parents a07e455baaa6
children 1bad5f9b60de
files trafficintelligence/moving.py trafficintelligence/prediction.py
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/trafficintelligence/moving.py	Wed Apr 26 18:33:46 2023 -0400
+++ b/trafficintelligence/moving.py	Wed Apr 26 23:36:32 2023 -0400
@@ -720,7 +720,7 @@
         return self.__len__() == 0
 
     def __getitem__(self, i):
-        if isinstance(i, int) or issubdtype(i, npinteger):
+        if isinstance(i, int):# or issubdtype(i, npinteger):
             return Point(self.positions[0][i], self.positions[1][i])
         elif isinstance(i, slice):
             return Trajectory([self.positions[0][i],self.positions[1][i]])
--- a/trafficintelligence/prediction.py	Wed Apr 26 18:33:46 2023 -0400
+++ b/trafficintelligence/prediction.py	Wed Apr 26 23:36:32 2023 -0400
@@ -553,8 +553,26 @@
                     collisionPoints = [SafetyPoint((p1+(v1*ttc)+p2+(v2*ttc))*0.5, 1., ttc)]
                 else:
                     pass # compute pPET
+        return collisionPoints, crossingZones
 
-        return collisionPoints, crossingZones
+class CVRectPredictionParameters(PredictionParameters):
+    '''Prediction parameters of prediction at constant velocity
+    for objects represented by boxes (bird eye view boxes)
+    Warning: the computed time to collision may be higher than timeHorizon (not used)'''
+    
+    def __init__(self):
+        PredictionParameters.__init__(self, 'constant velocity for rectangles', None)
+
+    def computeCrossingsCollisionsAtInstant(self, currentInstant, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, *kwargs):
+        'TODO compute pPET'
+        collisionPoints = []
+        crossingZones = []
+
+        # first test if there is a collision (test if movement is parallel to sides of vehicle)
+        # test if vehicle aligned with y axis, otherwise, compute slope
+        
+
+        # compute approximate time of arrival
 
 class PrototypePredictionParameters(PredictionParameters):
     def __init__(self, prototypes, nPredictedTrajectories, pointSimilarityDistance, minSimilarity, lcssMetric = 'cityblock', minFeatureTime = 10, constantSpeed = False, useFeatures = True):