16 #include <casadi/casadi.hpp>
19 #include <boost/test/unit_test.hpp>
20 #include <boost/utility/binary.hpp>
22 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
27 typedef casadi::SX ADScalar;
37 model.lowerPositionLimit.head<3>().
fill(-1.);
38 model.upperPositionLimit.head<3>().
fill(1.);
41 typedef Model::ConfigVectorType ConfigVector;
42 typedef Model::TangentVectorType TangentVector;
45 TangentVector
v(TangentVector::Random(
model.nv));
46 TangentVector
a(TangentVector::Random(
model.nv));
48 typedef ADModel::ConfigVectorType ConfigVectorAD;
49 ADModel ad_model =
model.cast<ADScalar>();
50 ADData ad_data(ad_model);
58 q_ad = Eigen::Map<ConfigVectorAD>(
static_cast<std::vector<ADScalar>
>(cs_q).
data(),
model.nq, 1);
60 Eigen::Map<ConfigVectorAD>(
static_cast<std::vector<ADScalar>
>(cs_v_int).
data(),
model.nv, 1);
63 casadi::SX cs_q_int(
model.nq, 1);
66 casadi::Function eval_integrate(
67 "eval_integrate", casadi::SXVector{cs_q, cs_v_int}, casadi::SXVector{cs_q_int});
68 std::vector<double> q_vec((
size_t)
model.nq);
69 Eigen::Map<ConfigVector>(q_vec.data(),
model.nq, 1) =
q;
71 std::vector<double> v_int_vec((
size_t)
model.nv);
72 Eigen::Map<TangentVector>(v_int_vec.data(),
model.nv, 1).setZero();
73 casadi::DM q_int_res = eval_integrate(casadi::DMVector{q_vec, v_int_vec})[0];
75 Data::ConfigVectorType q_int_vec = Eigen::Map<Data::TangentVectorType>(
76 static_cast<std::vector<double>
>(q_int_res).
data(),
model.nq, 1);
78 ConfigVector q_plus(
model.nq);
81 BOOST_CHECK(q_plus.isApprox(q_int_vec));
84 BOOST_AUTO_TEST_SUITE_END()