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

Method __init__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

initVehMethod · 0.95
createDatabase2Method · 0.95
simDescriptionCommitMethod · 0.95
databaseMigrationMethod · 0.95
createTimerMethod · 0.95
drawMapBGMethod · 0.95
drawRadarBGMethod · 0.95
getAllvTypeMethod · 0.95
RebuildClass · 0.90
SceneReplayClass · 0.90
RealTimeEvaluationClass · 0.90
getDataMethod · 0.45

Tested by

no test coverage detected