Created
July 11, 2016 02:16
-
-
Save contradict/a25ec564c18a4621d53fefd41b2064c0 to your computer and use it in GitHub Desktop.
Projecting to yaw only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <Eigen/Dense> | |
#include <Eigen/Geometry> | |
#include <sophus/so3.hpp> | |
#include <cmath> | |
// compile with | |
// g++ -I /usr/include/eigen3 test.cpp -lm -o test | |
int main(int argc, char **argv) | |
{ | |
(void)argc; | |
(void)argv; | |
Sophus::SO3d r; | |
Eigen::Vector3d dq1(0.1, 0.1, 0.0); | |
Eigen::Vector3d dq2(0.0, 0.0, 0.1); | |
r = r*Sophus::SO3d::exp(dq1); | |
r = r*Sophus::SO3d::exp(dq2); | |
r = r*Sophus::SO3d::exp(dq1); | |
r = r*Sophus::SO3d::exp(dq1); | |
r = r*Sophus::SO3d::exp(dq2); | |
Eigen::Vector3d t = Sophus::SO3d::log(r); | |
std::cout << "log " << t.transpose() << std::endl; | |
t.segment<2>(0).setZero(); | |
r = Sophus::SO3d::exp(t); | |
std::cout << "projected " << r.unit_quaternion().coeffs().transpose() << std::endl; | |
double yaw = 2*acos(r.unit_quaternion().coeffs()[3]); | |
std::cout << "projected yaw " << yaw << std::endl; | |
Eigen::Quaterniond q = r.unit_quaternion(); | |
q.x() = 0; | |
q.y() = 0; | |
q.normalize(); | |
yaw = 2*acos(q.coeffs()[3]); | |
std::cout << "zeroed yaw " << yaw << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment