Hydra: A Real-time Spatial Perception System for 3D Scene Graph Construction and Optimization