subsumes https://github.com/control-toolbox/OptimalControlProblems.jl/issues/136
subsumes #136