Vision-aided UAV navigation and dynamic obstacle avoidance using gradient-based B-spline trajectory optimization