9 #ifndef CROCODDYL_MULTIBODY_COSTS_CONTACT_IMPULSE_HPP_ 10 #define CROCODDYL_MULTIBODY_COSTS_CONTACT_IMPULSE_HPP_ 12 #include "crocoddyl/multibody/fwd.hpp" 13 #include "crocoddyl/multibody/cost-base.hpp" 14 #include "crocoddyl/multibody/impulse-base.hpp" 15 #include "crocoddyl/multibody/impulses/impulse-3d.hpp" 16 #include "crocoddyl/multibody/impulses/impulse-6d.hpp" 17 #include "crocoddyl/multibody/data/impulses.hpp" 18 #include "crocoddyl/multibody/frames.hpp" 19 #include "crocoddyl/core/utils/exception.hpp" 20 #include "crocoddyl/core/utils/deprecate.hpp" 44 template <
typename _Scalar>
47 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
49 typedef _Scalar Scalar;
59 typedef typename MathBase::Vector6s Vector6s;
60 typedef typename MathBase::VectorXs VectorXs;
61 typedef typename MathBase::MatrixXs MatrixXs;
73 boost::shared_ptr<ActivationModelAbstract> activation,
const FrameForce& fref);
110 virtual void calc(
const boost::shared_ptr<CostDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
111 const Eigen::Ref<const VectorXs>& u);
122 virtual void calcDiff(
const boost::shared_ptr<CostDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
123 const Eigen::Ref<const VectorXs>& u);
134 virtual boost::shared_ptr<CostDataAbstract>
createData(DataCollectorAbstract*
const data);
136 DEPRECATED(
"Used set_reference<FrameForceTpl<Scalar> >()",
void set_fref(
const FrameForce& fref));
137 DEPRECATED(
"Used get_reference<FrameForceTpl<Scalar> >()",
const FrameForce& get_fref()
const);
152 using Base::activation_;
162 template <
typename _Scalar>
164 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
166 typedef _Scalar Scalar;
172 typedef typename MathBase::VectorXs VectorXs;
173 typedef typename MathBase::MatrixXs MatrixXs;
174 typedef typename MathBase::Matrix6xs Matrix6xs;
176 template <
template <
typename Scalar>
class Model>
178 impulse_type = ImpulseUndefined;
183 throw_pretty(
"Invalid argument: the shared data should be derived from DataCollectorImpulse");
187 FrameForce fref = model->template get_reference<FrameForce>();
188 std::string frame_name = model->get_state()->get_pinocchio()->frames[fref.id].name;
189 bool found_impulse =
false;
190 for (
typename ImpulseModelMultiple::ImpulseDataContainer::iterator it = d->impulses->impulses.begin();
191 it != d->impulses->impulses.end(); ++it) {
192 if (it->second->frame == fref.id) {
195 impulse_type = Impulse3D;
196 if (model->get_activation()->get_nr() != 3) {
197 throw_pretty(
"Domain error: nr isn't defined as 3 in the activation model for the 3d impulse in " +
200 found_impulse =
true;
201 impulse = it->second;
206 impulse_type = Impulse6D;
207 if (model->get_activation()->get_nr() != 6) {
208 throw_pretty(
"Domain error: nr isn't defined as 6 in the activation model for the 3d impulse in " +
211 found_impulse =
true;
212 impulse = it->second;
215 throw_pretty(
"Domain error: there isn't defined at least a 3d impulse for " + frame_name);
219 if (!found_impulse) {
220 throw_pretty(
"Domain error: there isn't defined impulse data for " + frame_name);
224 boost::shared_ptr<ImpulseDataAbstractTpl<Scalar> > impulse;
225 ImpulseType impulse_type;
226 using Base::activation;
244 #include "crocoddyl/multibody/costs/contact-impulse.hxx" 246 #endif // CROCODDYL_MULTIBODY_COSTS_CONTACT_IMPULSE_HPP_
Define a stack of impulse models.