MCPcopy Create free account
hub / github.com/PJLab-ADG/OASim / __init__

Method __init__

limsim/simModel/fixedScene/replay.py:16–78  ·  view source on GitHub ↗
(self, dataBase: str, startFrame: int = None)

Source from the content-addressed store, hash-verified

14
15class ReplayModel:
16 def __init__(self, dataBase: str, startFrame: int = None) -> None:
17 print(
18 '[green bold]Model initialized at {}.[/green bold]'.format(
19 datetime.now().strftime('%H:%M:%S.%f')[:-3]
20 )
21 )
22 self.dataBase = dataBase
23 conn = sqlite3.connect(self.dataBase)
24 cur = conn.cursor()
25
26 # minTimeStep
27 cur.execute("""SELECT MAX(frame) FROM frameINFO;""")
28 maxTimeStep = cur.fetchone()[0] - 200
29 if maxTimeStep < 0:
30 maxTimeStep = 0
31 cur.execute("""SELECT MIN(frame) FROM frameINFO;""")
32 minTimeStep = cur.fetchone()[0]
33 if startFrame:
34 if startFrame > maxTimeStep:
35 print(
36 '[yellow]The start frame is too large, and is reassigned to[/yellow] %i.'
37 % maxTimeStep
38 )
39 self.timeStep = maxTimeStep
40 elif startFrame < minTimeStep:
41 print(
42 '[yellow]The start frame is too small, and is reassigned to[/yellow] %i.'
43 % minTimeStep
44 )
45 self.timeStep = minTimeStep
46 else:
47 self.timeStep = startFrame
48 else:
49 self.timeStep = minTimeStep
50
51 self.startFrame = self.timeStep
52
53 self.rb = Rebuild(dataBase)
54 self.rb.getData()
55 self.rb.buildTopology()
56
57 # get initialized ego car with origin position
58 cur.execute("""SELECT * FROM simINFO;""")
59 simINFO = cur.fetchone()
60 _, localPosx, localPosy, radius, egoID, _, _, _ = simINFO
61 if radius:
62 self.dv = DummyVehicle(localPosx, localPosy, radius)
63 else:
64 raise TypeError('Please select the appropriate database file.')
65
66 cur.close()
67 conn.close()
68
69 self.lsr = LocalSceneReplay(self.rb, self.dv)
70 self.gui = GUI('replay-local')
71 self.gui.start()
72 self.gui.drawMainWindowWhiteBG(
73 (self.dv.x-1000, self.dv.y-1000),

Callers

nothing calls this directly

Calls 6

RebuildClass · 0.90
DummyVehicleClass · 0.90
LocalSceneReplayClass · 0.90
getDataMethod · 0.45
buildTopologyMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected