dataBase: Replay database, please note that the database files for ego tracking and fixed scene are not common;
| 19 | |
| 20 | |
| 21 | class ReplayModel: |
| 22 | ''' |
| 23 | dataBase: Replay database, please note that the database files for ego tracking and fixed scene are not common; |
| 24 | ''' |
| 25 | |
| 26 | def __init__(self, dataBase: str, startFrame: int = None) -> None: |
| 27 | print( |
| 28 | '[green bold]Model initialized at {}.[/green bold]'.format( |
| 29 | datetime.now().strftime('%H:%M:%S.%f')[:-3] |
| 30 | ) |
| 31 | ) |
| 32 | self.dataBase = dataBase |
| 33 | conn = sqlite3.connect(self.dataBase) |
| 34 | cur = conn.cursor() |
| 35 | |
| 36 | # minTimeStep |
| 37 | cur.execute("""SELECT MAX(frame) FROM frameINFO;""") |
| 38 | maxTimeStep = cur.fetchone()[0] - 200 |
| 39 | if maxTimeStep < 0: |
| 40 | maxTimeStep = 0 |
| 41 | cur.execute("""SELECT MIN(frame) FROM frameINFO;""") |
| 42 | minTimeStep = cur.fetchone()[0] |
| 43 | if startFrame: |
| 44 | if startFrame > maxTimeStep: |
| 45 | print( |
| 46 | '[yellow]The start frame is too large, and is reassigned to[/yellow] %i.' |
| 47 | % maxTimeStep |
| 48 | ) |
| 49 | self.timeStep = maxTimeStep |
| 50 | elif startFrame < minTimeStep: |
| 51 | print( |
| 52 | '[yellow]The start frame is too small, and is reassigned to[/yellow] %i.' |
| 53 | % minTimeStep |
| 54 | ) |
| 55 | self.timeStep = minTimeStep |
| 56 | else: |
| 57 | self.timeStep = startFrame |
| 58 | else: |
| 59 | self.timeStep = minTimeStep |
| 60 | |
| 61 | self.rb = Rebuild(dataBase) |
| 62 | self.rb.getData() |
| 63 | self.rb.buildTopology() |
| 64 | |
| 65 | cur.execute("""SELECT * FROM simINFO;""") |
| 66 | simINFO = cur.fetchone() |
| 67 | _, localPosx, localPosy, radius, egoID, strBoundary, _, _ = simINFO |
| 68 | if egoID: |
| 69 | self.egoID = egoID |
| 70 | self.ego = self.initVeh(egoID, self.timeStep) |
| 71 | netBoundaryList = strBoundary.split(' ') |
| 72 | self.netBoundary: list[list[float]] = [ |
| 73 | list(map(float, p.split(','))) for p in netBoundaryList |
| 74 | ] |
| 75 | else: |
| 76 | raise TypeError('Please select the appropriate database file.') |
| 77 | |
| 78 | cur.close() |
nothing calls this directly
no outgoing calls
no test coverage detected