-
Notifications
You must be signed in to change notification settings - Fork 789
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
fix: UnaryFactor Jacobian #724
Conversation
nmahabadi
commented
Mar 23, 2021
- Fix Unaryfactor jacobian in LocalizationExample.cpp.
- Update gtsam document.
@dellaert @varunagrawal this is a new PR with the latest from "develop". Let me know if this seems fine. |
doc/Code/LocalizationFactor.cpp
Outdated
@@ -8,7 +8,11 @@ class UnaryFactor: public NoiseModelFactor1<Pose2> { | |||
Vector evaluateError(const Pose2& q, | |||
boost::optional<Matrix&> H = boost::none) const | |||
{ | |||
if (H) (*H) = (Matrix(2,3)<< 1.0,0.0,0.0, 0.0,1.0,0.0).finished(); | |||
const double cosTheta = cos(q.theta()); |
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.
Add comment, now that you figured it out :-) Also, GTSAM actually stores a Rot2 as sin and cos, so no need to re-compute. You can just use:
const Rot2& R = q.rotation();
and then use R.s()
and R.c()
examples/LocalizationExample.cpp
Outdated
// Node's orientation reflects in the Jacobian, in tangent space this is equal to the right-hand rule rotation matrix | ||
// H = [ cos(q.theta) -sin(q.theta) 0 ] | ||
// [ sin(q.theta) cos(q.theta) 0 ] | ||
const double cosTheta = cos(q.theta()); |
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.
same comments as above of course :-)
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.
Right! it is smart to use the available feature, I will update the PR soon.
@dellaert I updated the code/doc as you suggested. |
Merging failed. Try merging in develop? |
@dellaert I merged the latest develop. The merge seems ok. |