Automatic differentiation of rigid body dynamics for optimal control and estimation. (17th November 2017)