For Option 2, Log(R_meas^-1*R) is the standard error function defined for rotation matrices. Your code measured_. LocalCoordinates (new); is implicitly computing that, you may read more in a blog post I wrote a time ago:
https://gtsam.org/2021/02/23/uncertainties-part2.html
For the Pose3AttitudeFactor question, I did not implement it. But from the comments in the code this is what I got:
- It considers a navigation frame n (world, fixed frame) and a body frame b
- The residual function is defined as error( nRef, nG), where "error" is an error metric for unit vectors, nRef is the "measured" attitude in the navigation frame, and nG is the attitude in the navigation frame.
- Also, nRef is defined as nRef= nRb * bF, where nRb is the relative orientation between the navigation and body frame (effectively being the orientation of your robot's body) and bF is an unit vector indicating the direction of gravity as seen in the body frame.
- So the idea is that if you want bF == nG, forcing nRb (the robot's orientation) to align to gravity.
- The Jacobians you asked me about are due to the definition of the error function: e = error(nRef, nG)
- Then, the derivative with respect to the robot's orientation/attitude nRef will be De/DnRef * DnRef/DnRb
* De/DnRef corresponds to D_e_nRef in the code: it's the Jacobian of the error function w.r.t the rotated unit vector nRef we define before. The Jacobian is obtained directly from the error defined for unit vector that GTSAM implements.
* DnRef/DnRb is D_nRef_R : the Jacobian of nRef w.r.t the robot's attitude nRb used to define it nRef = nRb * bF