23 using namespace std::placeholders;
25 using namespace gtsam;
47 const double angle = 2.5;
49 SO3 R = SO3::AxisAngle(axis, angle);
56 M << 0.79067393, 0.6051136, -0.0930814,
57 0.4155925, -0.64214347, -0.64324489,
58 -0.44948549, 0.47046326, -0.75917576;
61 expected << 0.790687, 0.605096, -0.0931312,
62 0.415746, -0.642355, -0.643844,
63 -0.449411, 0.47036, -0.759468;
65 auto actual = SO3::ClosestTo(3 *
M);
94 auto X1 = SOn::Hat(z_axis),
X2 = SOn::Hat(
v2),
X3 = SOn::Hat(
v3);
130 EXPECT(check_group_invariants(
id,
id));
131 EXPECT(check_group_invariants(
id,
R1));
132 EXPECT(check_group_invariants(
R2,
id));
135 EXPECT(check_manifold_invariants(
id,
id));
136 EXPECT(check_manifold_invariants(
id,
R1));
137 EXPECT(check_manifold_invariants(
R2,
id));
160 double angle = 3.14 / 4.0;
162 expected << 0.707388, 0, 0.706825, 0, 1, 0, -0.706825, 0, 0.707388;
165 so3::ExpmapFunctor
f1(axis, angle);
166 SO3 actual1(
f1.expmap());
170 so3::ExpmapFunctor
f2(axis, angle - 2*
M_PI);
171 SO3 actual2(
f2.expmap());
175 so3::ExpmapFunctor
f3(axis * angle);
176 SO3 actual3(
f3.expmap());
180 so3::ExpmapFunctor
f4(axis * (angle - 2*
M_PI));
181 SO3 actual4(
f4.expmap());
187 static const Vector3 w(0.1, 0.27, -0.2);
200 const Matrix actualDexpL = SO3::ExpmapDerivative(
w);
201 const Matrix expectedDexpL =
202 numericalDerivative11<Vector3, Vector3>(
testDexpL, Vector3::Zero(), 1
e-2);
205 const Matrix actualDexpInvL = SO3::LogmapDerivative(
w);
211 const Vector3 theta(0.1, 0, 0.1);
212 const Matrix Jexpected = numericalDerivative11<SO3, Vector3>(
213 std::bind(&
SO3::Expmap, std::placeholders::_1,
nullptr), theta);
217 SO3::ExpmapDerivative(-theta)));
222 const Vector3 theta(10, 20, 30);
223 const Matrix Jexpected = numericalDerivative11<SO3, Vector3>(
224 std::bind(&
SO3::Expmap, std::placeholders::_1,
nullptr), theta);
228 SO3::ExpmapDerivative(-theta)));
247 auto w_dot = [](
double t) {
return Vector3(2,
cos(
t), 8 *
t); };
252 for (
double t = -2.0;
t < 2.0;
t += 0.3) {
254 const Matrix actual = SO3::ExpmapDerivative(
w(
t)) * w_dot(
t);
262 auto w_dot = [](
double t) {
return Vector3(2,
cos(
t), 8 *
t); };
268 for (
double t = -2.0;
t < 2.0;
t += 0.3) {
270 const Matrix actual = SO3::ExpmapDerivative(
w(
t)) * w_dot(
t);
277 const Vector3 theta(0.1, 0, 0.1);
278 const Matrix expectedH = numericalDerivative11<SO3, Vector3>(
279 std::bind(&
SO3::Expmap, std::placeholders::_1,
nullptr), theta);
288 const Vector3 omega1(0.1, 0, 0.1);
290 const SO3 R2((Matrix3() <<
291 -0.750767, -0.0285082, -0.659952,
292 -0.0102558, -0.998445, 0.0547974,
293 -0.660487, 0.0479084, 0.749307).finished());
294 const SO3 R3((Matrix3() <<
295 -0.747473, -0.00190019, -0.664289,
296 -0.0385114, -0.99819, 0.0461892,
297 -0.663175, 0.060108, 0.746047).finished());
298 const SO3 R4((Matrix3() <<
299 0.324237, 0.902975, 0.281968,
300 -0.674322, 0.429668, -0.600562,
301 -0.663445, 0.00458662, 0.748211).finished());
304 const bool nearPi = (
i == 2 ||
i == 3);
312 so3::DexpFunctor local(
omega);
313 Matrix3 J_r_inv = local.rightJacobianInverse();
321 const Matrix expectedH = numericalDerivative11<Vector3, SO3>(
322 std::bind(&SO3::Logmap, std::placeholders::_1,
nullptr),
R, 1
e-7);
334 std::vector<Vector3>
small{ {0, 0, 0},
335 {1
e-5, 0, 0}, {0, 1
e-5, 0}, {0, 0, 1
e-5},
336 {1
e-4, 0, 0}, {0, 1
e-4, 0}, {0, 0, 1
e-4} };
337 std::vector<Vector3>
large{
338 {0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0.1, 0.2, 0.3},
339 {0.4, 0.5, 0.6}, {0.7, 0.8, 0.9}, {1.1, 1.2, 1.3}, {1.4, 1.5, 1.6},
340 {1.7, 1.8, 1.9}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, {5, 5, 5} };
342 std::vector<Vector3>
vs{ {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0.4, 0.3, 0.2} };
348 for (
bool nearZero : {
true,
false}) {
350 so3::DexpFunctor local(
omega, nearZero ? 1.0 : 0.0, 1
e-5);
351 EXPECT(assert_equal<Matrix3>(local.rightJacobian().inverse(),
352 local.rightJacobianInverse()));
353 EXPECT(assert_equal<Matrix3>(local.leftJacobian().inverse(),
354 local.leftJacobianInverse()));
362 for (
bool nearZero : {
true,
false}) {
365 return so3::DexpFunctor(
omega, nearZero ? 1.0 : 0.0, 1
e-5).applyRightJacobian(
v);
368 so3::DexpFunctor local(
omega, nearZero ? 1.0 : 0.0, 1
e-5);
371 local.applyRightJacobian(
v, aH1, aH2)));
383 for (
bool nearZero : {
true,
false}) {
386 return so3::DexpFunctor(
omega, nearZero ? 1.0 : 0.0, 1
e-5).applyRightJacobianInverse(
v);
389 so3::DexpFunctor local(
omega, nearZero ? 1.0 : 0.0, 1
e-5);
390 Matrix invJr = local.rightJacobianInverse();
405 for (
bool nearZero : {
true,
false}) {
408 return so3::DexpFunctor(
omega, nearZero ? 1.0 : 0.0, 1
e-5).applyLeftJacobian(
v);
411 so3::DexpFunctor local(
omega, nearZero ? 1.0 : 0.0, 1
e-5);
414 local.applyLeftJacobian(
v, aH1, aH2)));
426 for (
bool nearZero : {
true,
false}) {
429 return so3::DexpFunctor(
omega, nearZero ? 1.0 : 0.0, 1
e-5).applyLeftJacobianInverse(
v);
432 so3::DexpFunctor local(
omega, nearZero ? 1.0 : 0.0, 1
e-5);
433 Matrix invJl = local.leftJacobianInverse();
436 local.applyLeftJacobianInverse(
v, aH1, aH2)));
449 const Vector9 actual =
R2.
vec(actualH);
451 std::function<Vector9(
const SO3&)>
f = [](
const SO3&
Q) {
return Q.vec(); };
459 M << 1, 2, 3, 4, 5, 6, 7, 8, 9;
465 std::function<Matrix3(
const Matrix3&)>
f = [
R](
const Matrix3&
M) {