Dynamic Safety Under Uncertainty: A Control Barrier Function Approach