Problem
Several important simulation constants appear as magic numbers inline in main.py and car.py rather than being declared in config.py. This makes tuning the simulation very difficult.
Examples found in main.py:
MPC_INTERVAL = 0.1 (10Hz) — should be MPC_RATE_HZ = 10 in config
TRAFFIC_UPDATE_INTERVAL = 1.0 (1Hz) — should be TRAFFIC_UPDATE_HZ = 1 in config
GLOBAL_OPT_INTERVAL = 30.0 — should be GLOBAL_OPT_INTERVAL_S = 30 in config
dt=1.0/60.0 hardcoded in KalmanFilter instantiation — should use SIMULATION_HZ = 60
1 / ZOOM_FACTOR inline in event handler — clean up zoom logic
Requested Changes
- Move all timing constants (
MPC_INTERVAL, TRAFFIC_UPDATE_INTERVAL, GLOBAL_OPT_INTERVAL, SIMULATION_HZ) to config.py
- Add a
SIMULATION_HZ constant and derive dt from it
- Replace all inline magic numbers in
main.py, car.py, and mpc_controller.py with named constants from config.py
- Group constants in
config.py into logical sections with comments:
- Display constants (WIDTH, HEIGHT, PADDING, etc.)
- Physics constants (SPEED_MS_EMPTY, SPEED_MS_LOADED, etc.)
- Simulation timing (SIMULATION_HZ, MPC_RATE_HZ, etc.)
- Algorithm tuning (POINTS_PER_SEGMENT, ZOOM_FACTOR, etc.)
Problem
Several important simulation constants appear as magic numbers inline in
main.pyandcar.pyrather than being declared inconfig.py. This makes tuning the simulation very difficult.Examples found in
main.py:MPC_INTERVAL = 0.1(10Hz) — should beMPC_RATE_HZ = 10in configTRAFFIC_UPDATE_INTERVAL = 1.0(1Hz) — should beTRAFFIC_UPDATE_HZ = 1in configGLOBAL_OPT_INTERVAL = 30.0— should beGLOBAL_OPT_INTERVAL_S = 30in configdt=1.0/60.0hardcoded in KalmanFilter instantiation — should useSIMULATION_HZ = 601 / ZOOM_FACTORinline in event handler — clean up zoom logicRequested Changes
MPC_INTERVAL,TRAFFIC_UPDATE_INTERVAL,GLOBAL_OPT_INTERVAL,SIMULATION_HZ) toconfig.pySIMULATION_HZconstant and derivedtfrom itmain.py,car.py, andmpc_controller.pywith named constants fromconfig.pyconfig.pyinto logical sections with comments: