Realtime Optimal Control