  The Finite Elements with Switch Detection (FESD) method is a highly accurate
direct transcription method for optimal control of several classes of nonsmooth
dynamical systems. This paper extends the FESD method to Projected Dynamical
Systems (PDS) and first-order sweeping processes with time-independent sets.
This method discretizes an equivalent dynamic complementarity system and
exploits the particular structure of the discontinuities present in these
systems. In the FESD method, allowing integration step sizes to be degrees of
freedom, and introducing additional complementarity constraints, enables the
exact detection of nonsmooth events. In contrast to the standard fixed-step
Runge-Kutta methods, this approach allows for the recovery of full-order
integration accuracy and the correct computation of numerical sensitivities.
Numerical examples illustrate the effectiveness of the proposed method in an
optimal control context. This method and the examples are included in the
open-source software package nosnoc.
