10 #ifndef CROCODDYL_MULTIBODY_IMPULSES_MULTIPLE_IMPULSES_HPP_
11 #define CROCODDYL_MULTIBODY_IMPULSES_MULTIPLE_IMPULSES_HPP_
18 #include "crocoddyl/core/utils/exception.hpp"
19 #include "crocoddyl/multibody/fwd.hpp"
20 #include "crocoddyl/multibody/impulse-base.hpp"
24 template <
typename _Scalar>
26 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
28 typedef _Scalar Scalar;
33 boost::shared_ptr<ImpulseModelAbstract> impulse,
34 const bool active =
true)
35 : name(name), impulse(impulse), active(active) {}
42 os <<
"{" << *model.impulse <<
"}";
47 boost::shared_ptr<ImpulseModelAbstract> impulse;
59 template <
typename _Scalar>
62 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
64 typedef _Scalar Scalar;
73 typedef typename MathBase::Vector2s Vector2s;
74 typedef typename MathBase::Vector3s Vector3s;
75 typedef typename MathBase::VectorXs VectorXs;
76 typedef typename MathBase::MatrixXs MatrixXs;
78 typedef std::map<std::string, boost::shared_ptr<ImpulseItem> >
79 ImpulseModelContainer;
80 typedef std::map<std::string, boost::shared_ptr<ImpulseDataAbstract> >
82 typedef typename pinocchio::container::aligned_vector<
83 pinocchio::ForceTpl<Scalar> >::iterator ForceIterator;
103 boost::shared_ptr<ImpulseModelAbstract> impulse,
104 const bool active =
true);
127 void calc(
const boost::shared_ptr<ImpulseDataMultiple>& data,
128 const Eigen::Ref<const VectorXs>& x);
136 void calcDiff(
const boost::shared_ptr<ImpulseDataMultiple>& data,
137 const Eigen::Ref<const VectorXs>& x);
147 const VectorXs& vnext)
const;
156 void updateForce(
const boost::shared_ptr<ImpulseDataMultiple>& data,
157 const VectorXs& impulse);
168 const MatrixXs& dvnext_dx)
const;
180 const MatrixXs& df_dx)
const;
192 pinocchio::DataTpl<Scalar>& pinocchio)
const;
201 pinocchio::DataTpl<Scalar>*
const data);
206 const boost::shared_ptr<StateMultibody>&
get_state()
const;
241 template <
class Scalar>
246 boost::shared_ptr<StateMultibody> state_;
247 ImpulseModelContainer impulses_;
249 std::size_t nc_total_;
250 std::set<std::string> active_set_;
251 std::set<std::string> inactive_set_;
259 template <
typename _Scalar>
261 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
263 typedef _Scalar Scalar;
267 typedef typename MathBase::VectorXs VectorXs;
268 typedef typename MathBase::MatrixXs MatrixXs;
276 template <
template <
typename Scalar>
class Model>
278 pinocchio::DataTpl<Scalar>*
const data)
279 :
Jc(model->get_nc_total(), model->get_state()->get_nv()),
280 dv0_dq(model->get_nc_total(), model->get_state()->get_nv()),
281 vnext(model->get_state()->get_nv()),
282 dvnext_dx(model->get_state()->get_nv(), model->get_state()->get_ndx()),
283 fext(model->get_state()->get_pinocchio()->njoints,
284 pinocchio::ForceTpl<Scalar>::Zero()) {
289 for (
typename ImpulseModelMultiple::ImpulseModelContainer::const_iterator
290 it = model->get_impulses().begin();
291 it != model->get_impulses().end(); ++it) {
292 const boost::shared_ptr<ImpulseItem>& item = it->second;
294 std::make_pair(item->name, item->impulse->createData(data)));
313 typename ImpulseModelMultiple::ImpulseDataContainer
315 pinocchio::container::aligned_vector<pinocchio::ForceTpl<Scalar> >
324 #include "crocoddyl/multibody/impulses/multiple-impulses.hxx"
Define a stack of impulse models.
void updateRneaDiff(const boost::shared_ptr< ImpulseDataMultiple > &data, pinocchio::DataTpl< Scalar > &pinocchio) const
Update the RNEA derivatives dtau_dq by adding the skew term (necessary for impulses expressed in LOCA...
void updateForceDiff(const boost::shared_ptr< ImpulseDataMultiple > &data, const MatrixXs &df_dx) const
Update the Jacobian of the spatial impulse defined in frame coordinate.
std::size_t get_nc() const
Return the dimension of active impulses.
const ImpulseModelContainer & get_impulses() const
Return the impulse models.
void addImpulse(const std::string &name, boost::shared_ptr< ImpulseModelAbstract > impulse, const bool active=true)
Add impulse item.
void calcDiff(const boost::shared_ptr< ImpulseDataMultiple > &data, const Eigen::Ref< const VectorXs > &x)
Compute the derivatives of the impulse holonomic constraint.
void updateVelocity(const boost::shared_ptr< ImpulseDataMultiple > &data, const VectorXs &vnext) const
Update the system velocity after impulse.
void updateForce(const boost::shared_ptr< ImpulseDataMultiple > &data, const VectorXs &impulse)
Update the spatial impulse defined in frame coordinate.
void calc(const boost::shared_ptr< ImpulseDataMultiple > &data, const Eigen::Ref< const VectorXs > &x)
Compute the total impulse Jacobian and impulse velocity.
const std::set< std::string > & get_inactive_set() const
Return the names of the set of inactive impulses.
void updateVelocityDiff(const boost::shared_ptr< ImpulseDataMultiple > &data, const MatrixXs &dvnext_dx) const
Update the Jacobian of the system velocity after impulse.
std::size_t get_nc_total() const
Return the dimension of all impulses.
const boost::shared_ptr< StateMultibody > & get_state() const
Return the multibody state.
const std::set< std::string > & get_active_set() const
Return the names of the set of active impulses.
friend std::ostream & operator<<(std::ostream &os, const ImpulseModelMultipleTpl< Scalar > &model)
Print information on the impulse models.
ImpulseModelMultipleTpl(boost::shared_ptr< StateMultibody > state)
Initialize the multi-impulse model.
bool getImpulseStatus(const std::string &name) const
Return the status of a given impulse name.
void changeImpulseStatus(const std::string &name, const bool active)
Change the impulse status.
boost::shared_ptr< ImpulseDataMultiple > createData(pinocchio::DataTpl< Scalar > *const data)
Create the multi-impulse data.
void removeImpulse(const std::string &name)
Remove impulse item.
State multibody representation.
Define the multi-impulse data.
ImpulseDataMultipleTpl(Model< Scalar > *const model, pinocchio::DataTpl< Scalar > *const data)
Initialized a multi-impulse data.
pinocchio::container::aligned_vector< pinocchio::ForceTpl< Scalar > > fext
External spatial forces in body coordinates.
ImpulseModelMultiple::ImpulseDataContainer impulses
Stack of impulse data.
friend std::ostream & operator<<(std::ostream &os, const ImpulseItemTpl< Scalar > &model)
Print information on the impulse item.