symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.41k stars 145 forks source link

Convert gtsam::Rot3 to sym::Rot3 #364

Closed MohammadrezaDindarloo closed 1 year ago

MohammadrezaDindarloo commented 1 year ago

Hi, I want to use some generated cpp code from symforce in my gtsam factors and in my evaluateError function I have a gtsam::Rot3, then in this function I use another function that generated but symforce that have this rotation matrix as input. now when I want to give this rotation matrix to my symforce generated function I should change the type from gtsam::Rot3 to sym::Rot3. I couldn't find any good solution for this. what can I do this for solving my problem? thanks for your reply.

ryan-brott-skydio commented 1 year ago

I think these functions should just work:

sym::Rot3d SymforceFromGtsam(const gtsam::Rot3& gtsam_rot3) {
  return sym::Rot3d(gtsam_rot3.toQuaternion());
}

gtsam::Rot3 GtsamFromSymforce(const sym::Rot3d& geo_rot3) {
  return gtsam::Rot3(geo_rot3.Quaternion());
}
MohammadrezaDindarloo commented 1 year ago

It's true. thank you