Some tests on Expmap/expmap chain rule
parent
37696b274e
commit
1c40b17fac
|
@ -1207,6 +1207,31 @@ TEST(Pose3, Print) {
|
|||
EXPECT(assert_print_equal(expected, pose));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Pose3, ExpmapChainRule) {
|
||||
// Muliply with an arbitrary matrix and exponentiate
|
||||
Matrix6 M;
|
||||
M << 1, 2, 3, 4, 5, 6, //
|
||||
7, 8, 9, 1, 2, 3, //
|
||||
4, 5, 6, 7, 8, 9, //
|
||||
1, 2, 3, 4, 5, 6, //
|
||||
7, 8, 9, 1, 2, 3, //
|
||||
4, 5, 6, 7, 8, 9;
|
||||
auto g = [&](const Vector6& omega) {
|
||||
return Pose3::Expmap(M*omega);
|
||||
};
|
||||
|
||||
// Test the derivatives at zero
|
||||
const Matrix6 expected = numericalDerivative11<Pose3, Vector6>(g, Z_6x1);
|
||||
EXPECT(assert_equal<Matrix6>(expected, M)); // Pose3::ExpmapDerivative(Z_6x1) is identity
|
||||
|
||||
// Test the derivatives at another value
|
||||
const Vector6 delta{0.1, 0.2, 0.3, 0.4, 0.5, 0.6};
|
||||
const Matrix6 expected2 = numericalDerivative11<Pose3, Vector6>(g, delta);
|
||||
const Matrix6 analytic = Pose3::ExpmapDerivative(M*delta) * M;
|
||||
EXPECT(assert_equal<Matrix6>(expected2, analytic, 1e-5)); // note tolerance
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() {
|
||||
TestResult tr;
|
||||
|
|
|
@ -956,6 +956,46 @@ TEST(Rot3, determinant) {
|
|||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Rot3, ExpmapChainRule) {
|
||||
// Muliply with an arbitrary matrix and exponentiate
|
||||
Matrix3 M;
|
||||
M << 1, 2, 3, 4, 5, 6, 7, 8, 9;
|
||||
auto g = [&](const Vector3& omega) {
|
||||
return Rot3::Expmap(M*omega);
|
||||
};
|
||||
|
||||
// Test the derivatives at zero
|
||||
const Matrix3 expected = numericalDerivative11<Rot3, Vector3>(g, Z_3x1);
|
||||
EXPECT(assert_equal<Matrix3>(expected, M)); // SO3::ExpmapDerivative(Z_3x1) is identity
|
||||
|
||||
// Test the derivatives at another value
|
||||
const Vector3 delta{0.1,0.2,0.3};
|
||||
const Matrix3 expected2 = numericalDerivative11<Rot3, Vector3>(g, delta);
|
||||
EXPECT(assert_equal<Matrix3>(expected2, SO3::ExpmapDerivative(M*delta) * M));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Rot3, expmapChainRule) {
|
||||
// Muliply an arbitrary rotation with exp(M*x)
|
||||
// Perhaps counter-intuitively, this has the same derivatives as above
|
||||
Matrix3 M;
|
||||
M << 1, 2, 3, 4, 5, 6, 7, 8, 9;
|
||||
const Rot3 R = Rot3::Expmap({1, 2, 3});
|
||||
auto g = [&](const Vector3& omega) {
|
||||
return R.expmap(M*omega);
|
||||
};
|
||||
|
||||
// Test the derivatives at zero
|
||||
const Matrix3 expected = numericalDerivative11<Rot3, Vector3>(g, Z_3x1);
|
||||
EXPECT(assert_equal<Matrix3>(expected, M));
|
||||
|
||||
// Test the derivatives at another value
|
||||
const Vector3 delta{0.1,0.2,0.3};
|
||||
const Matrix3 expected2 = numericalDerivative11<Rot3, Vector3>(g, delta);
|
||||
EXPECT(assert_equal<Matrix3>(expected2, SO3::ExpmapDerivative(M*delta) * M));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() {
|
||||
TestResult tr;
|
||||
|
|
Loading…
Reference in New Issue