Hi, I'm working with a humanoid model and using the iLQG method for trajectory optimization. In the forward pass of this method there is a linear control law for computing a new control trajectory: u_hat(i) = u(i) + alpha*k(i) + K(i)*(x_hat(i) - x(i)) x(i) is state of the dynamic system and in my case is generalized positions q and velocities v (qpos + qvel). My model is a humanoid with 27 DOF, so dimension of d->qvel is 27 but because there is a floating base body in my model, dimension of d->qpos is 28 . so dimension of state x(i) is 55. on the other hand the gain matrix K(i) is a 54*54 matrix ( its dimension obtain from size on DOF). so in the K(i) matrix, for the quaternions in the state vector x(i) that are related to the orientations of the floating base body, there are 3 coefficients. but quaternions have 4 elements. How should i handle this? should i compute error between quaternions by the quaternion product and then use the last 3 element of this error? best, Mohammad