10 namespace newcontacts {
12 template <
typename Scalar>
14 boost::shared_ptr<StateMultibody> state,
const std::size_t nu)
17 template <
typename Scalar>
19 boost::shared_ptr<StateMultibody> state)
22 template <
typename Scalar>
25 template <
typename Scalar>
27 const boost::shared_ptr<ContactDataMultiple>& data,
28 const boost::shared_ptr<MatrixXs> df_dx,
29 const boost::shared_ptr<MatrixXs> df_du)
const {
30 const std::size_t ndx = this->get_state()->get_ndx();
31 if (
static_cast<std::size_t
>(df_dx->rows()) != this->get_nc() ||
32 static_cast<std::size_t
>(df_dx->cols()) != ndx) {
33 throw_pretty(
"Invalid argument: "
34 <<
"df_dx has wrong dimension (it should be " +
35 std::to_string(this->get_nc()) +
"," +
36 std::to_string(ndx) +
")");
38 if (
static_cast<std::size_t
>(df_du->rows()) != this->get_nc() ||
39 static_cast<std::size_t
>(df_du->cols()) != this->get_nu()) {
40 throw_pretty(
"Invalid argument: "
41 <<
"df_du has wrong dimension (it should be " +
42 std::to_string(this->get_nc()) +
"," +
43 std::to_string(this->get_nu()) +
")");
45 if (
static_cast<std::size_t
>(data->contacts.size()) !=
46 this->get_contacts().size()) {
47 throw_pretty(
"Invalid argument: "
48 <<
"it doesn't match the number of contact datas and models");
52 typename ContactModelContainer::const_iterator it_m, end_m;
53 typename ContactDataContainer::const_iterator it_d, end_d;
54 for (it_m = this->get_contacts().begin(), end_m = this->get_contacts().end(),
55 it_d = data->contacts.begin(), end_d = data->contacts.end();
56 it_m != end_m || it_d != end_d; ++it_m, ++it_d) {
57 const boost::shared_ptr<ContactItem>& m_i = it_m->second;
58 const boost::shared_ptr<ContactDataAbstract>& d_i = it_d->second;
59 assert_pretty(it_m->first == it_d->first,
60 "it doesn't match the contact name between data and model");
62 const std::size_t nc_i = m_i->contact->get_nc();
63 m_i->contact->updateForceDiff(d_i, df_dx->block(nc, 0, nc_i, ndx),
64 df_du->block(nc, 0, nc_i, this->get_nu()));
67 m_i->contact->setZeroForceDiff(d_i);
72 template <
typename Scalar>
74 const boost::shared_ptr<ContactDataMultiple>& data,
75 pinocchio::DataTpl<Scalar>& pinocchio)
const {
76 const std::size_t nv = this->get_state()->get_nv();
77 if (
static_cast<std::size_t
>(data->contacts.size()) !=
78 this->get_contacts().size()) {
79 throw_pretty(
"Invalid argument: "
80 <<
"it doesn't match the number of contact datas and models");
82 typename ContactModelContainer::const_iterator it_m, end_m;
83 typename ContactDataContainer::const_iterator it_d, end_d;
84 for (it_m = this->get_contacts().begin(), end_m = this->get_contacts().end(),
85 it_d = data->contacts.begin(), end_d = data->contacts.end();
86 it_m != end_m || it_d != end_d; ++it_m, ++it_d) {
87 const boost::shared_ptr<ContactItem>& m_i = it_m->second;
88 const boost::shared_ptr<ContactDataAbstract>& d_i = it_d->second;
89 assert_pretty(it_m->first == it_d->first,
90 "it doesn't match the contact name between data and model");
92 const std::size_t nc_i = m_i->contact->get_nc();
98 if (cm_i->
get_type() == pinocchio::WORLD ||
99 cm_i->
get_type() == pinocchio::LOCAL_WORLD_ALIGNED) {
100 pinocchio.dtau_dq.block(0, 0, nv, nv) += cd_i->drnea_skew_term_;
108 if (cm_i->
get_type() == pinocchio::WORLD ||
109 cm_i->
get_type() == pinocchio::LOCAL_WORLD_ALIGNED) {
110 pinocchio.dtau_dq.block(0, 0, nv, nv) += cd_i->drnea_skew_term_;
118 if (cm_i->
get_type() == pinocchio::WORLD ||
119 cm_i->
get_type() == pinocchio::LOCAL_WORLD_ALIGNED) {
120 pinocchio.dtau_dq.block(0, 0, nv, nv) += cd_i->drnea_skew_term_;