-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for autodiff #237
Conversation
Codecov Report
@@ Coverage Diff @@
## devel #237 +/- ##
=======================================
Coverage 98.17% 98.17%
=======================================
Files 55 55
Lines 1753 1754 +1
=======================================
+ Hits 1721 1722 +1
Misses 32 32 |
a01c838
to
b430a8c
Compare
b430a8c
to
c85ac91
Compare
@joansola, this is ready for review/approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me. I have not tested it, though.
What exactly is the autodiff
package?
It's a modern (C++17) library for automatic differentiation that provides a scalar type and a few neat functions. Think Here is a striped down example (yet nearly compilable): using dual = autodiff::dual;
// cost function
auto fun = [](const auto& measurement, const auto& state_i, const auto& state_j){
return measurement - (state_j - state_i);
};
SE3<dual> xi, xj;
SE3Tangent<dual> meas_ij, e;
// cost function Jacs wrt underlying vector
Eigen::MatrixXd J_e_xi = autodiff::jacobian(fun, autodiff::wrt(xi), autodiff::at(meas_ij, xi, xj), e);
Eigen::MatrixXd J_e_xj = autodiff::jacobian(fun, autodiff::wrt(xj), autodiff::at(meas_ij, xi, xj), e);
// Local param Jacs
Eigen::MatrixXd J_xi_xiw0 = manif::autodiffLocalParameterizationJacobian<dual>(xi);
Eigen::MatrixXd J_xj_xjw0 = manif::autodiffLocalParameterizationJacobian<dual>(xj);
// cost function Jacs wrt local perturbation on the tangent space
Eigen::MatrixXd J_e_xiw0 = J_e_xi * J_xi_xiw0;
Eigen::MatrixXd J_e_xjw0 = J_e_xj * J_xj_xjw0; Find more examples in the unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Add support for the autodiff library
autodiff automatic differentiation made easier for C++ (web - github).
This PR only adds support for the
autodiff::dual
type.Find a doc page here (mostly copied from the Ceres/Jet doc page).
The Jacobians produced by autodiff are compared against manif analytics ones in unit tests.
Also adds
operator[](i)
to both groups and tangents to access single elements of the underlying vectorsize()
to both groups and tangents which return the underlying vector size (== RepSize
)Closes #196.
Closes #143.