-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimization.cpp
65 lines (42 loc) · 1.48 KB
/
optimization.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <cmath>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "sophos/se3.hpp"
using namespace std;
using namespace Eigen;
int main(int argc, char **argv)
{
Matrix3d R = AngleAxisd(M_PI / 2, Vector3d(0, 0, 1)).toRotationMatrix();
Quaterniond q(R);
Sophus::SO3d SO3_R(R);
Sophus::SO3d SO3_q(q);
cout << SO3_R.matrix() << endl;
cout << SO3_q.matrix() << endl;
Vector3d so3 = SO3_R.log();
cout << "so3: " << so3.transpose() << endl;
cout << Sophus::SO3d::hat(so3) << endl;
cout << Sophus::SO3d::vee(Sophus::SO3d::hat(so3)).transpose() << endl;
Vector3d update_so3(1e-4, 0, 0);
Sophus::SO3d SO3_R_update = Sophus::SO3d::exp(update_so3) * SO3_R;
cout << SO3_R_update.matrix() << endl;
// SE3
Vector3d t(1, 0, 0);
Sophus::SE3d SE3_R_t(R, t);
Sophus::SE3d SE3_q_t(q, t);
cout << "SE3_R_t: " << endl
<< SE3_R_t.matrix() << endl;
cout << "SE3_q_t: " << endl
typedef Eigen::Matrix<double, 6, 1>
Vector6d;
Vector6d se3 = SE3_R_t.log();
cout << "se3: " << se3.transpose() << endl;
cout << "se3 hat =" << endl
<< Sophus::SE3d::hat(se3) << endl;
cout << "se3 vee =" << endl
<< Sophus::SE3d::vee(Sophus::SE3d::hat(se3)) << endl;
Vector6d update_se3(1e-4, 0, 0, 0, 0, 0);
Sophus::SE3d SE3_R_t_update = Sophus::SE3d::exp(update_se3) * SE3_R_t;
cout << "SE3_R_t_update: " << endl
<< SE3_R_t_update.matrix() << endl;
}