9 #ifndef CROCODDYL_MULTIBODY_COSTS_CONTACT_COP_POSITION_HPP_ 10 #define CROCODDYL_MULTIBODY_COSTS_CONTACT_COP_POSITION_HPP_ 12 #include "crocoddyl/multibody/fwd.hpp" 13 #include "crocoddyl/multibody/cost-base.hpp" 14 #include "crocoddyl/multibody/contact-base.hpp" 15 #include "crocoddyl/multibody/contacts/contact-3d.hpp" 16 #include "crocoddyl/multibody/contacts/contact-6d.hpp" 17 #include "crocoddyl/multibody/data/contacts.hpp" 18 #include "crocoddyl/multibody/frames.hpp" 19 #include "crocoddyl/multibody/data/multibody.hpp" 20 #include "crocoddyl/core/activations/quadratic-barrier.hpp" 21 #include "crocoddyl/core/utils/exception.hpp" 45 template <
typename _Scalar>
48 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 typedef _Scalar Scalar;
61 typedef typename MathBase::Vector2s Vector2s;
62 typedef typename MathBase::Vector3s Vector3s;
63 typedef typename MathBase::VectorXs VectorXs;
64 typedef typename MathBase::MatrixXs MatrixXs;
65 typedef typename MathBase::MatrixX3s MatrixX3s;
66 typedef Eigen::Matrix<Scalar, 4, 6> Matrix46;
77 boost::shared_ptr<ActivationModelAbstract> activation,
78 const FrameCoPSupport& cop_support,
const std::size_t& nu);
90 boost::shared_ptr<ActivationModelAbstract> activation,
91 const FrameCoPSupport& cop_support);
104 const std::size_t& nu);
128 virtual void calc(
const boost::shared_ptr<CostDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
129 const Eigen::Ref<const VectorXs>& u);
141 virtual void calcDiff(
const boost::shared_ptr<CostDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
142 const Eigen::Ref<const VectorXs>& u);
153 virtual boost::shared_ptr<CostDataAbstract>
createData(DataCollectorAbstract*
const data);
166 using Base::activation_;
172 FrameCoPSupport cop_support_;
175 template <
typename _Scalar>
177 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
179 typedef _Scalar Scalar;
184 typedef typename MathBase::Vector3s Vector3s;
185 typedef typename MathBase::VectorXs VectorXs;
186 typedef typename MathBase::MatrixXs MatrixXs;
187 typedef typename MathBase::Matrix3s Matrix3s;
188 typedef typename MathBase::Matrix6xs Matrix6xs;
189 typedef typename MathBase::Matrix6s Matrix6s;
190 typedef typename MathBase::Vector6s Vector6s;
192 template <
template <
typename Scalar>
class Model>
194 : Base(model, data), Arr_Ru(model->get_activation()->get_nr(), model->get_state()->get_nv()) {
200 throw_pretty(
"Invalid argument: the shared data should be derived from DataCollectorContact");
204 FrameCoPSupport cop_support = model->template get_reference<FrameCoPSupport>();
205 std::string frame_name = model->get_state()->get_pinocchio()->frames[cop_support.get_frame()].name;
206 bool found_contact =
false;
207 for (
typename ContactModelMultiple::ContactDataContainer::iterator it = d->contacts->contacts.begin();
208 it != d->contacts->contacts.end(); ++it) {
209 if (it->second->frame == cop_support.get_frame()) {
212 throw_pretty(
"Domain error: a 6d contact model is required in " + frame_name +
213 "in order to compute the CoP");
218 found_contact =
true;
219 contact = it->second;
224 if (!found_contact) {
225 throw_pretty(
"Domain error: there isn't defined contact data for " + frame_name);
229 pinocchio::DataTpl<Scalar>* pinocchio;
231 boost::shared_ptr<ContactDataAbstractTpl<Scalar> >
contact;
232 using Base::activation;
250 #include "crocoddyl/multibody/costs/contact-cop-position.hxx" 252 #endif // CROCODDYL_MULTIBODY_COSTS_CONTACT_COP_POSITION_HPP_