emulator: add 800-6000 RPM sweep with 4s hold at max scale
This commit is contained in:
parent
a0624a0227
commit
ddc64a54dc
1 changed files with 28 additions and 13 deletions
|
|
@ -32,25 +32,40 @@ class VehicleState:
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
def update_simulation(self):
|
def update_simulation(self):
|
||||||
"""Simulates driving telemetry with smooth sinusoidal variation"""
|
"""Simulates driving telemetry with clear transitions through color zones and holds at max scale"""
|
||||||
t = time.time()
|
t = time.time()
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if self.auto_simulate:
|
if self.auto_simulate:
|
||||||
# RPM smoothly moves between 1000 and 3600
|
# 24-second cycle:
|
||||||
self.rpm = 2100.0 + 1200.0 * math.sin(t * 0.8) + 200.0 * math.cos(t * 1.7)
|
# 0 - 8s: Ramp up 800 -> 6000 RPM (Verde -> Amarillo -> Rojo)
|
||||||
if self.rpm < 800:
|
# 8 - 12s: Hold at MAX (6000 RPM, redline/escala máxima) for 4s
|
||||||
self.rpm = 800
|
# 12 - 20s: Ramp down 6000 -> 800 RPM (Rojo -> Amarillo -> Verde)
|
||||||
# MAP pressure fluctuates with RPM
|
# 20 - 24s: Hold at IDLE (800 RPM) for 4s
|
||||||
self.map_psi = 12.0 + 10.0 * ((self.rpm - 800.0) / 3000.0) + 1.5 * math.sin(t * 2.0)
|
cycle_period = 24.0
|
||||||
|
phase = t % cycle_period
|
||||||
|
|
||||||
|
if phase < 8.0:
|
||||||
|
p = phase / 8.0
|
||||||
|
self.rpm = 800.0 + p * (6000.0 - 800.0)
|
||||||
|
elif phase < 12.0:
|
||||||
|
self.rpm = 6000.0
|
||||||
|
elif phase < 20.0:
|
||||||
|
p = (phase - 12.0) / 8.0
|
||||||
|
self.rpm = 6000.0 - p * (6000.0 - 800.0)
|
||||||
|
else:
|
||||||
|
self.rpm = 800.0
|
||||||
|
|
||||||
|
# MAP pressure correlates with RPM
|
||||||
|
self.map_psi = 10.0 + 16.0 * ((self.rpm - 800.0) / 5200.0)
|
||||||
# Engine load correlates with RPM
|
# Engine load correlates with RPM
|
||||||
self.load = 20.0 + 45.0 * ((self.rpm - 800.0) / 3000.0)
|
self.load = 15.0 + 75.0 * ((self.rpm - 800.0) / 5200.0)
|
||||||
# Vehicle speed correlates with RPM/gear
|
# Vehicle speed correlates with RPM (up to 175 km/h, turning RED past 130 km/h)
|
||||||
self.speed = 25.0 + 65.0 * ((self.rpm - 800.0) / 2600.0) + 5.0 * math.sin(t * 0.7)
|
self.speed = 15.0 + 160.0 * ((self.rpm - 800.0) / 5200.0)
|
||||||
if self.speed < 0:
|
if self.speed < 0:
|
||||||
self.speed = 0.0
|
self.speed = 0.0
|
||||||
# Temperatures fluctuate slightly around operating values
|
# Coolant temp rises slightly with engine load (88°C -> 102°C, showing warn RED past 100°C)
|
||||||
self.coolant_temp = 92.0 + 3.0 * math.sin(t * 0.1)
|
self.coolant_temp = 88.0 + 14.0 * ((self.rpm - 800.0) / 5200.0)
|
||||||
self.oil_temp = 93.0 + 1.5 * math.sin(t * 0.12)
|
self.oil_temp = 90.0 + 12.0 * ((self.rpm - 800.0) / 5200.0)
|
||||||
self.trans_temp = 82.0 + 1.0 * math.cos(t * 0.09)
|
self.trans_temp = 82.0 + 1.0 * math.cos(t * 0.09)
|
||||||
self.pcm_volt = 14.2 + 0.15 * math.sin(t * 0.5)
|
self.pcm_volt = 14.2 + 0.15 * math.sin(t * 0.5)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue