Joris, thanks for providing a fixed example to this question. Allow me to hook on to this thread - I've been working on some OCP and have implemented multiple-shooting, trapezoidal collocation, and Hermite-Simpson collocation. The latter two suffer from an issue in the first and last state and input values. (To be exact; the inputs jump to half the value next to it, and the state follows suit given those inputs).
I had implemented the dynamics constraints akin to:
f1 = f(x[:,k+1],u[:,k+1])
f0 = f(x[:,k],u[:,k])
opti.subject_to(h/2*(f1+f0)==x[:,k+1]-x[:,k])
Notice the k+1 on the input for f1, which is k in your fixed example.
This implementation, in my view, was consistent with piecewise linear (as opposed to piecewise constant) inputs, and what I understand from Eq. (4.56) of Betts' book. Am I wrong here?