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" 24 enum ImpulseType { Impulse3D, Impulse6D, Undefined };
46 template <
typename _Scalar>
49 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51 typedef _Scalar Scalar;
61 typedef typename MathBase::Vector6s Vector6s;
62 typedef typename MathBase::VectorXs VectorXs;
63 typedef typename MathBase::MatrixXs MatrixXs;
75 boost::shared_ptr<ActivationModelAbstract> activation,
const FrameForce& fref);
112 virtual void calc(
const boost::shared_ptr<CostDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
113 const Eigen::Ref<const VectorXs>& u);
124 virtual void calcDiff(
const boost::shared_ptr<CostDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
125 const Eigen::Ref<const VectorXs>& u);
136 virtual boost::shared_ptr<CostDataAbstract>
createData(DataCollectorAbstract*
const data);
138 DEPRECATED(
"Used set_reference<FrameForceTpl<Scalar> >()",
void set_fref(
const FrameForce& fref));
139 DEPRECATED(
"Used get_reference<FrameForceTpl<Scalar> >()",
const FrameForce& get_fref()
const);
154 using Base::activation_;
164 template <
typename _Scalar>
166 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
168 typedef _Scalar Scalar;
174 typedef typename MathBase::VectorXs VectorXs;
175 typedef typename MathBase::MatrixXs MatrixXs;
176 typedef typename MathBase::Matrix6xs Matrix6xs;
178 template <
template <
typename Scalar>
class Model>
180 impulse_type = Undefined;
185 throw_pretty(
"Invalid argument: the shared data should be derived from DataCollectorImpulse");
189 FrameForce fref = model->template get_reference<FrameForce>();
190 std::string frame_name = model->get_state()->get_pinocchio()->frames[fref.frame].name;
191 bool found_impulse =
false;
192 for (
typename ImpulseModelMultiple::ImpulseDataContainer::iterator it = d->impulses->impulses.begin();
193 it != d->impulses->impulses.end(); ++it) {
194 if (it->second->frame == fref.frame) {
197 impulse_type = Impulse3D;
198 if (model->get_activation()->get_nr() != 3) {
199 throw_pretty(
"Domain error: nr isn't defined as 3 in the activation model for the 3d impulse in " +
202 found_impulse =
true;
203 impulse = it->second;
208 impulse_type = Impulse6D;
209 if (model->get_activation()->get_nr() != 6) {
210 throw_pretty(
"Domain error: nr isn't defined as 6 in the activation model for the 3d impulse in " +
213 found_impulse =
true;
214 impulse = it->second;
217 throw_pretty(
"Domain error: there isn't defined at least a 3d impulse for " + frame_name);
221 if (!found_impulse) {
222 throw_pretty(
"Domain error: there isn't defined impulse data for " + frame_name);
226 boost::shared_ptr<ImpulseDataAbstractTpl<Scalar> > impulse;
227 ImpulseType impulse_type;
228 using Base::activation;
246 #include "crocoddyl/multibody/costs/contact-impulse.hxx" 248 #endif // CROCODDYL_MULTIBODY_COSTS_CONTACT_IMPULSE_HPP_
Define a stack of impulse models.