14 #include <boost/variant.hpp>
17 #include <boost/test/unit_test.hpp>
18 #include <boost/utility/binary.hpp>
20 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
25 SE3 M1 = SE3::Identity();
26 SE3 M2 = SE3::Random();
34 const Eigen::DenseIndex col = 0;
35 for (Eigen::DenseIndex k = 0; k < 3; ++k)
37 BOOST_CHECK(casadi::SX::is_equal(trans(k, col), M1.translation()[k]));
44 Motion v1 = Motion::Zero();
45 Motion v2 = Motion::Random();
56 SE3AD::Matrix3 & ad_rot = ad_M.
rotation();
64 casadi::SX cs_quat(4, 1);
67 casadi::Function eval_quat(
"eval_quat", casadi::SXVector{cs_rot}, casadi::SXVector{cs_quat});
69 for (
int k = 0; k < 1e4; ++k)
74 casadi::DM vec_rot(3, 3);
77 casadi::DM quat_res = eval_quat(casadi::DMVector{vec_rot})[0];
81 Eigen::Map<Eigen::Vector4d>(
static_cast<std::vector<double>
>(quat_res).
data());
94 typedef casadi::SX ADScalar;
98 typedef SE3::Matrix3 Matrix3;
102 typedef SE3AD::Matrix3 Matrix3AD;
104 SE3::Matrix3 RTarget;
108 Matrix3 R0 = quat0.toRotationMatrix();
113 Vector3AD nu_ad = Eigen::Map<Vector3AD>(
static_cast<std::vector<ADScalar>
>(cs_nu).
data());
114 auto log3_casadi_exp =
120 casadi::Function log3_casadi(
"log3_casadi", casadi::SXVector{cs_nu}, casadi::SXVector{cs_res});
122 std::vector<double> log3_casadi_input(3);
123 Eigen::Map<Vector3>(log3_casadi_input.data()) = nu0;
124 casadi::DM log3_casadi_res = log3_casadi(casadi::DMVector{log3_casadi_input})[0];
125 Vector3 res0 = Eigen::Map<Vector3>(
static_cast<std::vector<double>
>(log3_casadi_res).
data());
130 BOOST_CHECK(res0 == res0);
131 BOOST_CHECK(res0_ref == res0_ref);
132 BOOST_CHECK(res0.isApprox(res0_ref));
134 ADScalar log3_casadi_jacobian_exp =
jacobian(cs_res, cs_nu);
135 casadi::Function log3_casadi_jacobian(
136 "log3_casadi_jacobian", casadi::SXVector{cs_nu}, casadi::SXVector{log3_casadi_jacobian_exp});
138 casadi::DM log3_casadi_jacobian_res =
139 log3_casadi_jacobian(casadi::DMVector{log3_casadi_input})[0];
141 Eigen::Map<Matrix3>(
static_cast<std::vector<double>
>(log3_casadi_jacobian_res).
data());
143 BOOST_CHECK(jac0 == jac0);
145 ADScalar log3_casadi_gradient_exp = gradient(log3_casadi_exp[0], cs_nu);
147 casadi::Function log3_casadi_gradient(
148 "log3_casadi_jacobian", casadi::SXVector{cs_nu}, casadi::SXVector{log3_casadi_gradient_exp});
150 casadi::DM log3_casadi_gradient_res =
151 log3_casadi_gradient(casadi::DMVector{log3_casadi_input})[0];
153 Eigen::Map<Vector3>(
static_cast<std::vector<double>
>(log3_casadi_gradient_res).
data());
155 BOOST_CHECK(grad0 == grad0);
158 BOOST_AUTO_TEST_SUITE_END()