the behemoth
This commit is contained in:
@@ -13,21 +13,34 @@ def normalize_telemetry(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
- tire_compound: Compound, TyreCompound, Tire
|
||||
- fuel_level: Fuel, FuelRel, FuelLevel
|
||||
- ers: ERS, ERSCharge
|
||||
- track_temp: TrackTemp
|
||||
- track_temp: TrackTemp, track_temperature
|
||||
- rain_probability: RainProb, PrecipProb
|
||||
- lap: Lap, LapNumber
|
||||
- lap: Lap, LapNumber, lap_number
|
||||
- total_laps: TotalLaps, total_laps
|
||||
- track_name: TrackName, track_name, Circuit
|
||||
- driver_name: DriverName, driver_name, Driver
|
||||
- current_position: Position, current_position
|
||||
- tire_life_laps: TireAge, tire_age, tire_life_laps
|
||||
- rainfall: Rainfall, rainfall, Rain
|
||||
|
||||
Values are clamped and defaulted if missing.
|
||||
"""
|
||||
aliases = {
|
||||
"lap": ["lap", "Lap", "LapNumber"],
|
||||
"lap": ["lap", "Lap", "LapNumber", "lap_number"],
|
||||
"speed": ["speed", "Speed"],
|
||||
"throttle": ["throttle", "Throttle"],
|
||||
"brake": ["brake", "Brake", "Brakes"],
|
||||
"tire_compound": ["tire_compound", "Compound", "TyreCompound", "Tire"],
|
||||
"fuel_level": ["fuel_level", "Fuel", "FuelRel", "FuelLevel"],
|
||||
"ers": ["ers", "ERS", "ERSCharge"],
|
||||
"track_temp": ["track_temp", "TrackTemp"],
|
||||
"track_temp": ["track_temp", "TrackTemp", "track_temperature"],
|
||||
"rain_probability": ["rain_probability", "RainProb", "PrecipProb"],
|
||||
"total_laps": ["total_laps", "TotalLaps"],
|
||||
"track_name": ["track_name", "TrackName", "Circuit"],
|
||||
"driver_name": ["driver_name", "DriverName", "Driver"],
|
||||
"current_position": ["current_position", "Position"],
|
||||
"tire_life_laps": ["tire_life_laps", "TireAge", "tire_age"],
|
||||
"rainfall": ["rainfall", "Rainfall", "Rain"],
|
||||
}
|
||||
|
||||
out: Dict[str, Any] = {}
|
||||
@@ -99,5 +112,39 @@ def normalize_telemetry(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
out["track_temp"] = track_temp
|
||||
if rain_prob is not None:
|
||||
out["rain_probability"] = rain_prob
|
||||
|
||||
# Add race context fields if present
|
||||
total_laps = pick("total_laps", None)
|
||||
if total_laps is not None:
|
||||
try:
|
||||
out["total_laps"] = int(total_laps)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
track_name = pick("track_name", None)
|
||||
if track_name:
|
||||
out["track_name"] = str(track_name)
|
||||
|
||||
driver_name = pick("driver_name", None)
|
||||
if driver_name:
|
||||
out["driver_name"] = str(driver_name)
|
||||
|
||||
current_position = pick("current_position", None)
|
||||
if current_position is not None:
|
||||
try:
|
||||
out["current_position"] = int(current_position)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
tire_life_laps = pick("tire_life_laps", None)
|
||||
if tire_life_laps is not None:
|
||||
try:
|
||||
out["tire_life_laps"] = int(tire_life_laps)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
rainfall = pick("rainfall", None)
|
||||
if rainfall is not None:
|
||||
out["rainfall"] = bool(rainfall)
|
||||
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user