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

Method __init__

limsim/simModel/fixedScene/interReplay.py:20–99  ·  view source on GitHub ↗
(self,
                 dataBase: str,
                 dataBase2: str = None,
                 startFrame: int = None,
                 simNote: str = ''
                 )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

createDatabase2Method · 0.95
simDescriptionCommitMethod · 0.95
databaseMigrationMethod · 0.95
createTimerMethod · 0.95
getAllvTypeMethod · 0.95
RebuildClass · 0.90
DummyVehicleClass · 0.90
LocalSceneReplayClass · 0.90
getDataMethod · 0.45
buildTopologyMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected