10 #ifndef CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_FORCE_HPP_
11 #define CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_FORCE_HPP_
13 #include "crocoddyl/core/residual-base.hpp"
14 #include "crocoddyl/core/utils/exception.hpp"
15 #include "crocoddyl/multibody/contact-base.hpp"
16 #include "crocoddyl/multibody/contacts/contact-1d.hpp"
17 #include "crocoddyl/multibody/contacts/contact-3d.hpp"
18 #include "crocoddyl/multibody/contacts/contact-6d.hpp"
19 #include "crocoddyl/multibody/contacts/multiple-contacts.hpp"
20 #include "crocoddyl/multibody/data/contacts.hpp"
21 #include "crocoddyl/multibody/data/impulses.hpp"
22 #include "crocoddyl/multibody/fwd.hpp"
23 #include "crocoddyl/multibody/impulse-base.hpp"
24 #include "crocoddyl/multibody/impulses/impulse-3d.hpp"
25 #include "crocoddyl/multibody/impulses/impulse-6d.hpp"
26 #include "crocoddyl/multibody/impulses/multiple-impulses.hpp"
27 #include "crocoddyl/multibody/states/multibody.hpp"
56 template <
typename _Scalar>
59 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
61 typedef _Scalar Scalar;
68 typedef pinocchio::ForceTpl<Scalar> Force;
69 typedef typename MathBase::VectorXs VectorXs;
70 typedef typename MathBase::MatrixXs MatrixXs;
88 const pinocchio::FrameIndex
id,
89 const Force& fref,
const std::size_t nc,
90 const std::size_t nu,
const bool fwddyn =
true);
105 const pinocchio::FrameIndex
id,
106 const Force& fref,
const std::size_t nc);
121 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
122 const Eigen::Ref<const VectorXs>& x,
123 const Eigen::Ref<const VectorXs>& u);
135 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
136 const Eigen::Ref<const VectorXs>& x);
150 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
151 const Eigen::Ref<const VectorXs>& x,
152 const Eigen::Ref<const VectorXs>& u);
165 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
166 const Eigen::Ref<const VectorXs>& x);
205 void set_id(
const pinocchio::FrameIndex
id);)
211 void set_reference(
const Force& reference);
218 virtual void print(std::ostream& os)
const;
228 bool update_jacobians_;
230 pinocchio::FrameIndex id_;
234 template <
typename _Scalar>
236 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
238 typedef _Scalar Scalar;
244 typedef pinocchio::ForceTpl<Scalar> Force;
246 typedef typename MathBase::MatrixXs MatrixXs;
248 template <
template <
typename Scalar>
class Model>
251 :
Base(model, data) {
255 bool is_contact =
true;
260 if (d1 == NULL && d2 == NULL) {
262 "Invalid argument: the shared data should be derived from "
263 "DataCollectorContact or DataCollectorImpulse");
270 const pinocchio::FrameIndex
id = model->get_id();
271 const boost::shared_ptr<StateMultibody>& state =
272 boost::static_pointer_cast<StateMultibody>(model->get_state());
273 std::string frame_name = state->get_pinocchio()->frames[id].name;
274 bool found_contact =
false;
276 for (
typename ContactModelMultiple::ContactDataContainer::iterator it =
277 d1->contacts->contacts.begin();
278 it != d1->contacts->contacts.end(); ++it) {
279 if (it->second->frame ==
id) {
284 found_contact =
true;
292 found_contact =
true;
300 found_contact =
true;
305 "Domain error: there isn't defined at least a 3d contact for " +
311 for (
typename ImpulseModelMultiple::ImpulseDataContainer::iterator it =
312 d2->impulses->impulses.begin();
313 it != d2->impulses->impulses.end(); ++it) {
314 if (it->second->frame ==
id) {
319 found_contact =
true;
327 found_contact =
true;
332 "Domain error: there isn't defined at least a 3d impulse for " +
338 if (!found_contact) {
340 "Domain error: there isn't defined contact/impulse data for " +
345 boost::shared_ptr<ForceDataAbstractTpl<Scalar> >
359 #include "crocoddyl/multibody/residuals/contact-force.hxx"
Define a stack of impulse models.
Abstract class for residual models.
boost::shared_ptr< StateAbstract > state_
State description.
std::size_t nu_
Control dimension.
std::size_t nr_
Residual vector dimension.
State multibody representation.
MatrixXs Ru
Jacobian of the residual vector with respect the control.
MatrixXs Rx
Jacobian of the residual vector with respect the state.
DataCollectorAbstract * shared
Shared data allocated by the action model.
VectorXs r
Residual vector.