Mercurial > hg > nsaunier > traffic-intelligence
comparison python/prediction.py @ 515:727e3c529519
renamed all draw functions to plot for consistency
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 06 Jun 2014 14:10:42 -0400 |
| parents | 000bddf84ad0 |
| children | dc58ad777a72 8ba4b8ad4c86 |
comparison
equal
deleted
inserted
replaced
| 514:1ba618fb0f70 | 515:727e3c529519 |
|---|---|
| 28 return moving.Trajectory.fromPointList(self.predictedPositions.values()) | 28 return moving.Trajectory.fromPointList(self.predictedPositions.values()) |
| 29 | 29 |
| 30 def getPredictedSpeeds(self): | 30 def getPredictedSpeeds(self): |
| 31 return [so.norm for so in self.predictedSpeedOrientations.values()] | 31 return [so.norm for so in self.predictedSpeedOrientations.values()] |
| 32 | 32 |
| 33 def draw(self, options = '', withOrigin = False, timeStep = 1, **kwargs): | 33 def plot(self, options = '', withOrigin = False, timeStep = 1, **kwargs): |
| 34 self.getPredictedTrajectory().draw(options, withOrigin, timeStep, **kwargs) | 34 self.getPredictedTrajectory().plot(options, withOrigin, timeStep, **kwargs) |
| 35 | 35 |
| 36 class PredictedTrajectoryConstant(PredictedTrajectory): | 36 class PredictedTrajectoryConstant(PredictedTrajectory): |
| 37 '''Predicted trajectory at constant speed or acceleration | 37 '''Predicted trajectory at constant speed or acceleration |
| 38 TODO generalize by passing a series of velocities/accelerations''' | 38 TODO generalize by passing a series of velocities/accelerations''' |
| 39 | 39 |
| 168 if debug: | 168 if debug: |
| 169 from matplotlib.pyplot import figure, axis, title | 169 from matplotlib.pyplot import figure, axis, title |
| 170 figure() | 170 figure() |
| 171 for et in predictedTrajectories1: | 171 for et in predictedTrajectories1: |
| 172 et.predictPosition(timeHorizon) | 172 et.predictPosition(timeHorizon) |
| 173 et.draw('rx') | 173 et.plot('rx') |
| 174 | 174 |
| 175 for et in predictedTrajectories2: | 175 for et in predictedTrajectories2: |
| 176 et.predictPosition(timeHorizon) | 176 et.predictPosition(timeHorizon) |
| 177 et.draw('bx') | 177 et.plot('bx') |
| 178 obj1.draw('r') | 178 obj1.plot('r') |
| 179 obj2.draw('b') | 179 obj2.plot('b') |
| 180 title('instant {0}'.format(currentInstant)) | 180 title('instant {0}'.format(currentInstant)) |
| 181 axis('equal') | 181 axis('equal') |
| 182 | 182 |
| 183 return collisionPoints, crossingZones | 183 return collisionPoints, crossingZones |
| 184 | 184 |
| 220 if debug: | 220 if debug: |
| 221 from matplotlib.pyplot import figure, axis, title | 221 from matplotlib.pyplot import figure, axis, title |
| 222 figure() | 222 figure() |
| 223 for et in predictedTrajectories1: | 223 for et in predictedTrajectories1: |
| 224 et.predictPosition(timeHorizon) | 224 et.predictPosition(timeHorizon) |
| 225 et.draw('rx') | 225 et.plot('rx') |
| 226 | 226 |
| 227 for et in predictedTrajectories2: | 227 for et in predictedTrajectories2: |
| 228 et.predictPosition(timeHorizon) | 228 et.predictPosition(timeHorizon) |
| 229 et.draw('bx') | 229 et.plot('bx') |
| 230 obj1.draw('r') | 230 obj1.plot('r') |
| 231 obj2.draw('b') | 231 obj2.plot('b') |
| 232 title('instant {0}'.format(i)) | 232 title('instant {0}'.format(i)) |
| 233 axis('equal') | 233 axis('equal') |
| 234 | 234 |
| 235 return collisionProbabilities | 235 return collisionProbabilities |
| 236 | 236 |
| 374 if debug and intersection!= None: | 374 if debug and intersection!= None: |
| 375 from matplotlib.pyplot import plot, figure, axis, title | 375 from matplotlib.pyplot import plot, figure, axis, title |
| 376 figure() | 376 figure() |
| 377 plot([p1.x, intersection.x], [p1.y, intersection.y], 'r') | 377 plot([p1.x, intersection.x], [p1.y, intersection.y], 'r') |
| 378 plot([p2.x, intersection.x], [p2.y, intersection.y], 'b') | 378 plot([p2.x, intersection.x], [p2.y, intersection.y], 'b') |
| 379 intersection.draw() | 379 intersection.plot() |
| 380 obj1.draw('r') | 380 obj1.plot('r') |
| 381 obj2.draw('b') | 381 obj2.plot('b') |
| 382 title('instant {0}'.format(currentInstant)) | 382 title('instant {0}'.format(currentInstant)) |
| 383 axis('equal') | 383 axis('equal') |
| 384 | 384 |
| 385 return collisionPoints, crossingZones | 385 return collisionPoints, crossingZones |
| 386 | 386 |
