A template-based robot dynamics library