17 #include <boost/test/unit_test.hpp>
18 #include <boost/utility/binary.hpp>
20 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
22 using namespace Eigen;
28 using namespace Eigen;
35 model.lowerPositionLimit.head<3>().
fill(-1.);
36 model.upperPositionLimit.head<3>().
fill(1.);
39 VectorXd
v = VectorXd::Random(
model.nv);
45 const double mu0 = 0.;
54 const Eigen::VectorXd
dv =
data.dq_after -
v;
59 model.gravity.setZero();
62 BOOST_CHECK(data_ref.
dtau_dq.isApprox(
data.dtau_dq));
67 using namespace Eigen;
73 model.lowerPositionLimit.head<3>().
fill(-1.);
74 model.upperPositionLimit.head<3>().
fill(1.);
76 VectorXd
v = VectorXd::Random(
model.nv);
78 const std::string RF =
"rleg6_joint";
80 const std::string LF =
"lleg6_joint";
99 const double mu0 = 0.;
110 ForceVector iext((
size_t)
model.njoints);
111 for (ForceVector::iterator
it = iext.begin();
it != iext.end(); ++
it)
117 Eigen::VectorXd effective_v = (1 +
r_coeff) *
v +
data.ddq;
120 model, data_ref,
q, effective_v, Eigen::VectorXd::Zero(
model.nv));
122 for (
size_t i = 0;
i <
data.ov.size();
i++)
137 Jc.bottomRows<3>() = Jc_tmp.topRows<3>();
138 dv_dq.bottomRows<3>() = dv_dq_tmp.topRows<3>();
140 BOOST_CHECK(data_ref.
J.isApprox(
data.J));
143 model.gravity.setZero();
145 model.gravity = gravity_bk;
147 BOOST_CHECK(
data.dac_da.isApprox(Jc));
150 BOOST_CHECK((
data.dlambda_dv + (1 +
r_coeff) *
data.osim * Jc).isZero());
155 using namespace Eigen;
162 model.lowerPositionLimit.head<3>().
fill(-1.);
163 model.upperPositionLimit.head<3>().
fill(1.);
166 VectorXd
v = VectorXd::Random(
model.nv);
168 const std::string RF =
"rleg6_joint";
170 const std::string LF =
"lleg6_joint";
189 const double mu0 = 0.;
201 MatrixXd dqafter_partial_dq_fd(
model.nv,
model.nv);
202 dqafter_partial_dq_fd.setZero();
203 MatrixXd dqafter_partial_dv_fd(
model.nv,
model.nv);
204 dqafter_partial_dv_fd.setZero();
207 impulse_partial_dq_fd.setZero();
209 impulse_partial_dv_fd.setZero();
211 const VectorXd dqafter0 =
213 const VectorXd impulse0 = data_fd.
impulse_c;
214 VectorXd v_eps(VectorXd::Zero(
model.nv));
215 VectorXd q_plus(
model.nq);
216 VectorXd dqafter_plus(
model.nv);
219 const Eigen::VectorXd vel_jump = Jc * (dqafter0 +
r_coeff *
v);
225 const double alpha = 1e-8;
226 for (
int k = 0; k <
model.nv; ++k)
233 const Eigen::MatrixXd Jc_plus =
235 const Eigen::VectorXd vel_jump_plus = Jc_plus * (dqafter0 +
r_coeff *
v);
237 dqafter_partial_dq_fd.col(k) = (dqafter_plus - dqafter0) /
alpha;
238 impulse_partial_dq_fd.col(k) = (data_fd.
impulse_c - impulse0) /
alpha;
239 dvc_dq_fd.col(k) = (vel_jump_plus - vel_jump) /
alpha;
243 BOOST_CHECK(Jc.isApprox(
data.dac_da, sqrt(
alpha)));
244 BOOST_CHECK(dqafter_partial_dq_fd.isApprox(
data.ddq_dq, sqrt(
alpha)));
245 BOOST_CHECK(impulse_partial_dq_fd.isApprox(
data.dlambda_dq, sqrt(
alpha)));
248 for (
int k = 0; k <
model.nv; ++k)
254 dqafter_partial_dv_fd.col(k) = (dqafter_plus - dqafter0) /
alpha;
255 impulse_partial_dv_fd.col(k) = (data_fd.
impulse_c - impulse0) /
alpha;
259 BOOST_CHECK(dqafter_partial_dv_fd.isApprox(
261 BOOST_CHECK(impulse_partial_dv_fd.isApprox(
data.dlambda_dv, sqrt(
alpha)));
266 using namespace Eigen;
273 model.lowerPositionLimit.head<3>().
fill(-1.);
274 model.upperPositionLimit.head<3>().
fill(1.);
277 VectorXd
v = VectorXd::Random(
model.nv);
279 const std::string RF =
"rleg6_joint";
281 const std::string LF =
"lleg6_joint";
300 const double mu0 = 0.;
312 MatrixXd dqafter_partial_dq_fd(
model.nv,
model.nv);
313 dqafter_partial_dq_fd.setZero();
314 MatrixXd dqafter_partial_dv_fd(
model.nv,
model.nv);
315 dqafter_partial_dv_fd.setZero();
318 impulse_partial_dq_fd.setZero();
320 impulse_partial_dv_fd.setZero();
322 const VectorXd dqafter0 =
324 const VectorXd impulse0 = data_fd.
impulse_c;
325 VectorXd v_eps(VectorXd::Zero(
model.nv));
326 VectorXd q_plus(
model.nq);
327 VectorXd dqafter_plus(
model.nv);
330 const double alpha = 1e-8;
331 for (
int k = 0; k <
model.nv; ++k)
337 dqafter_partial_dq_fd.col(k) = (dqafter_plus - dqafter0) /
alpha;
338 impulse_partial_dq_fd.col(k) = (data_fd.
impulse_c - impulse0) /
alpha;
342 BOOST_CHECK(dqafter_partial_dq_fd.isApprox(
data.ddq_dq, sqrt(
alpha)));
343 BOOST_CHECK(impulse_partial_dq_fd.isApprox(
data.dlambda_dq, sqrt(
alpha)));
346 for (
int k = 0; k <
model.nv; ++k)
351 dqafter_partial_dv_fd.col(k) = (dqafter_plus - dqafter0) /
alpha;
352 impulse_partial_dv_fd.col(k) = (data_fd.
impulse_c - impulse0) /
alpha;
356 BOOST_CHECK(dqafter_partial_dv_fd.isApprox(
358 BOOST_CHECK(impulse_partial_dv_fd.isApprox(
data.dlambda_dv, sqrt(
alpha)));
361 BOOST_AUTO_TEST_SUITE_END()