How hyzhou404/hugsim works
Project Type & Purpose
• HUGSIM is a full-stack, closed-loop simulator for autonomous driving.
• It provides pipelines for scene reconstruction (train), export (eval_render), interactive scenario configuration (GUI), and real-time simulation loops (closed_loop.py).
• It integrates ML-based reconstruction, photorealistic rendering, and external AD algorithm clients (UniAD_SIM, VAD_SIM, NAVSIM).
File Structure Analysis
• Top‐level directories:
• configs: YAMLs for data preparation, benchmarks, simulation settings.
• data: raw datasets (kitti360, nusc, waymo, pandaset), InverseForm model, colmap utilities.
• sim: HUGSIM gym environment (hugsim_env), ILQR planner, utility scripts.
• eval_render: scene/vehicle conversion & rendering scripts.
• gui: Flask-based GUI for scenario config (app.py + static/ templates).
• scene, gaussian_renderer: core scene‐representation and Gaussian splatting modules.
• train.py / train_ground.py: reconstruction model training entry points.
• closed_loop.py: simulation orchestrator invoking external AD clients and the gym environment.
• submodules: Pplan (sampling planners), simple-knn (CUDA‐accelerated KNN).
README Insights
• Two-phase installation via pixi (Python, PyTorch, CUDA).
• Data preparation & download documented under data/README.md.
• Reconstruction → Export → GUI configuration → Closed-loop simulation.
• External dependencies: UniAD_SIM, VAD_SIM, NAVSIM clients.
a. Main Components
• Data Preparation Module
– Input raw sequences → dataset readers (data/* + scene/dataset_readers.py).
• Reconstruction Pipeline
– train_ground.py (ground surfaces) → train.py (semantic scene + objects)
– Uses InverseForm submodule, PyTorch models (data/InverseForm/models).
• Scene Export & Conversion
– eval_render (export_scene.py, convert_vehicles.py, convert_scene.py)
– Outputs minimized scene & vehicle splat/semantic formats.
• GUI Scenario Configurator
– gui/app.py: web server, user edits YAML templates → scenario definitions.
• Closed-Loop Simulator
– closed_loop.py: loads scenario, base & camera configs, kinematic model;
– Creates HUGSIM gym env (sim/hugsim_env), launches external AD client, loops sensor→action→render.
• Planning & Control
– sim/ilqr (LQR solver), submodules/Pplan (sampling planners), sim/utils (agent_controller).
• Rendering Engine
– gaussian_renderer: real-time Gaussian splatting.
• External AD Clients
– UniAD_SIM, VAD_SIM, NAVSIM (installed separately).
b. Relationships & Interactions
– Data Preparation feeds Reconstruction.
– Reconstruction outputs models/scene data → Export converts to simulation format.
– GUI reads exported scene & vehicle data → writes scenario YAML.
– closed_loop.py consumes scenario & configs → instantiates HUGSIM env + Gaussian renderer + planning modules → calls external AD client → loops.
– Planning & control modules interface with gym environment.
– Rendering engine provides observations to both GUI and closed-loop.
c. Architectural Patterns
– Modular pipeline: clear separation of stages (prep → train → export → config → simulate).
– Plugin/integration: external AD clients plugged into simulation loop.
– Gym-style environment abstraction for sim.
– Component-based scene modeling (ground_model, obj_model, gaussian_model).
d. Key Technologies
– Python, PyTorch, CUDA for ML & rendering.
– pixi for environment & dependency management.
– Flask (or FastAPI) for GUI.
– Open3D/colmap scripts for reconstruction preprocessing.
– YAML-based config files.
– Gym API abstraction in sim/hugsim_env.
Key Details to Capture
• Config files driving each stage (configs/benchmark, configs/sim).
• Interaction points: eval_render ↔ gui, gui → closed_loop.
• The gym environment wrapper (sim/hugsim_env).
• Planning modules (ILQR & Pplan) plugged into env.
• Rendering engine (gaussian_renderer) providing observations.