CavWorld API¶
CavWorld serves as the global registry for CAVs and manages shared ML models. Prevents duplicate
model loading and enables efficient resource utilization.
| Attribute | Type | Purpose |
|---|---|---|
vehicle_id_set |
set |
CARLA vehicle ID tracking |
_vehicle_manager_dict |
dict |
VehicleManager registry |
_platooning_dict |
dict |
PlatooningManager registry |
ml_manager |
MLManager |
Shared YOLOv8/YOLOv5 models |
Core Methods¶
What it does: Manages vehicle registration and shared ML model access
ML Integration¶
What Changed: Automatic YOLOv8/YOLOv5 selection with shared instance
def _initialize_ml_models(self):
try:
# Prefer YOLOv8 (better performance)
from ultralytics import YOLO
detector = YOLO('yolov8m.pt')
use_v8 = True
except ImportError:
# Fallback to YOLOv5 (compatibility)
detector = torch.hub.load('ultralytics/yolov5', 'yolov5m')
use_v8 = False
return MLManager(detector, use_v8)
# Create CAV world with ML support
cav_world = CavWorld(apply_ml=True)
# Create scenario manager with shared world
scenario_manager = ScenarioManager(
scenario_params, apply_ml=True, cav_world=cav_world
)
# Vehicles automatically register during creation
vehicles = scenario_manager.create_vehicle_manager(['platooning'])
Related: