Stochastic control via chance constrained optimization and its application to unmanned aerial vehicles