9 #ifndef CROCODDYL_MULTIBODY_CONTACTS_MULTIPLE_CONTACTS_HPP_
10 #define CROCODDYL_MULTIBODY_CONTACTS_MULTIPLE_CONTACTS_HPP_
17 #include "crocoddyl/multibody/fwd.hpp"
18 #include "crocoddyl/core/utils/exception.hpp"
19 #include "crocoddyl/multibody/contact-base.hpp"
23 template <
typename _Scalar>
25 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 typedef _Scalar Scalar;
31 ContactItemTpl(
const std::string& name, boost::shared_ptr<ContactModelAbstract> contact,
const bool active =
true)
32 : name(name), contact(contact), active(active) {}
38 os <<
"{" << *model.contact <<
"}";
43 boost::shared_ptr<ContactModelAbstract> contact;
54 template <
typename _Scalar>
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
59 typedef _Scalar Scalar;
68 typedef typename MathBase::Vector2s Vector2s;
69 typedef typename MathBase::Vector3s Vector3s;
70 typedef typename MathBase::VectorXs VectorXs;
71 typedef typename MathBase::MatrixXs MatrixXs;
73 typedef std::map<std::string, boost::shared_ptr<ContactItem> > ContactModelContainer;
74 typedef std::map<std::string, boost::shared_ptr<ContactDataAbstract> > ContactDataContainer;
75 typedef typename pinocchio::container::aligned_vector<pinocchio::ForceTpl<Scalar> >::iterator ForceIterator;
102 void addContact(
const std::string& name, boost::shared_ptr<ContactModelAbstract> contact,
const bool active =
true);
125 void calc(
const boost::shared_ptr<ContactDataMultiple>& data,
const Eigen::Ref<const VectorXs>& x);
133 void calcDiff(
const boost::shared_ptr<ContactDataMultiple>& data,
const Eigen::Ref<const VectorXs>& x);
141 void updateAcceleration(
const boost::shared_ptr<ContactDataMultiple>& data,
const VectorXs& dv)
const;
150 void updateForce(
const boost::shared_ptr<ContactDataMultiple>& data,
const VectorXs& force);
159 void updateAccelerationDiff(
const boost::shared_ptr<ContactDataMultiple>& data,
const MatrixXs& ddv_dx)
const;
170 void updateForceDiff(
const boost::shared_ptr<ContactDataMultiple>& data,
const MatrixXs& df_dx,
171 const MatrixXs& df_du)
const;
179 boost::shared_ptr<ContactDataMultiple>
createData(pinocchio::DataTpl<Scalar>*
const data);
184 const boost::shared_ptr<StateMultibody>&
get_state()
const;
194 std::size_t
get_nc()
const;
204 std::size_t
get_nu()
const;
216 DEPRECATED(
"get_active() is deprecated and will be replaced with get_active_set()",
217 const std::vector<std::string>& get_active() {
219 active_.reserve(active_set_.size());
220 for (
const auto& contact : active_set_) {
221 active_.push_back(contact);
226 DEPRECATED(
"get_inactive() is deprecated and will be replaced with get_inactive_set()",
227 const std::vector<std::string>& get_inactive() {
229 inactive_.reserve(inactive_set_.size());
230 for (
const auto& contact : inactive_set_) {
231 inactive_.push_back(contact);
244 template <
class Scalar>
248 boost::shared_ptr<StateMultibody> state_;
249 ContactModelContainer contacts_;
251 std::size_t nc_total_;
253 std::set<std::string> active_set_;
254 std::set<std::string> inactive_set_;
258 std::vector<std::string> active_;
259 std::vector<std::string> inactive_;
267 template <
typename _Scalar>
269 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
271 typedef _Scalar Scalar;
275 typedef typename MathBase::VectorXs VectorXs;
276 typedef typename MathBase::MatrixXs MatrixXs;
284 template <
template <
typename Scalar>
class Model>
286 :
Jc(model->get_nc_total(), model->get_state()->get_nv()),
287 a0(model->get_nc_total()),
288 da0_dx(model->get_nc_total(), model->get_state()->get_ndx()),
289 dv(model->get_state()->get_nv()),
290 ddv_dx(model->get_state()->get_nv(), model->get_state()->get_ndx()),
291 fext(model->get_state()->get_pinocchio()->njoints, pinocchio::ForceTpl<Scalar>::Zero()) {
297 for (
typename ContactModelMultiple::ContactModelContainer::const_iterator it = model->get_contacts().begin();
298 it != model->get_contacts().end(); ++it) {
299 const boost::shared_ptr<ContactItem>& item = it->second;
300 contacts.insert(std::make_pair(item->name, item->contact->createData(data)));
316 typename ContactModelMultiple::ContactDataContainer
contacts;
318 pinocchio::container::aligned_vector<pinocchio::ForceTpl<Scalar> >
327 #include "crocoddyl/multibody/contacts/multiple-contacts.hxx"
329 #endif // CROCODDYL_MULTIBODY_CONTACTS_MULTIPLE_CONTACTS_HPP_