  We present an efficient optimization framework that solves trajectory
optimization problems by decoupling state variables from timing variables,
thereby decomposing a challenging nonlinear programming (NLP) problem into two
easier subproblems. With timing fixed, the state variables can be optimized
efficiently using convex optimization, and the timing variables can be
optimized in a separate NLP, which forms a bilevel optimization problem. The
challenge of obtaining the gradient of the timing variables is solved by
sensitivity analysis of parametric NLPs. The exact analytic gradient is
computed from the dual solution as a by-product, whereas existing
finite-difference techniques require additional optimization. The bilevel
optimization framework efficiently optimizes both timing and state variables
which is demonstrated on generating trajectories for an unmanned aerial
vehicle. Numerical experiments demonstrate that bilevel optimization converges
significantly more reliably than a standard NLP solver, and analytical
gradients outperform finite differences in terms of computation speed and
accuracy. Physical experiments demonstrate its real-time applicability for
reactive target tracking tasks.
