  This paper presents a novel algorithm to plan energy-efficient trajectories
for autonomous ornithopters. In general, trajectory optimization is quite a
relevant problem for practical applications with \emph{Unmanned Aerial
Vehicles} (UAVs). Even though the problem has been well studied for fixed and
rotatory-wing vehicles, there are far fewer works exploring it for
flapping-wing UAVs like ornithopters. These are of interest for many
applications where long flight endurance, but also hovering capabilities are
required. We propose an efficient approach to plan ornithopter trajectories
that minimize energy consumption by combining gliding and flapping maneuvers.
Our algorithm builds a tree of dynamically feasible trajectories and applies
heuristic search for efficient online planning, using reference curves to guide
the search and prune states. We present computational experiments to analyze
and tune key parameters, as well as a comparison against a recent alternative
probabilistic planning, showing best performance. Finally, we demonstrate how
our algorithm can be used for planning perching maneuvers online.
