10 #ifndef CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_FRICTION_CONE_HPP_
11 #define CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_FRICTION_CONE_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-2d.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/friction-cone.hpp"
23 #include "crocoddyl/multibody/fwd.hpp"
24 #include "crocoddyl/multibody/impulse-base.hpp"
25 #include "crocoddyl/multibody/impulses/impulse-3d.hpp"
26 #include "crocoddyl/multibody/impulses/impulse-6d.hpp"
27 #include "crocoddyl/multibody/impulses/multiple-impulses.hpp"
28 #include "crocoddyl/multibody/states/multibody.hpp"
59 template <
typename _Scalar>
63 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65 typedef _Scalar Scalar;
73 typedef typename MathBase::VectorXs VectorXs;
74 typedef typename MathBase::MatrixXs MatrixXs;
75 typedef typename MathBase::MatrixX3s MatrixX3s;
91 const pinocchio::FrameIndex
id,
94 const bool fwddyn =
true);
107 const pinocchio::FrameIndex
id,
118 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
119 const Eigen::Ref<const VectorXs>& x,
120 const Eigen::Ref<const VectorXs>& u);
132 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
133 const Eigen::Ref<const VectorXs>& x);
142 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
143 const Eigen::Ref<const VectorXs>& x,
144 const Eigen::Ref<const VectorXs>& u);
157 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
158 const Eigen::Ref<const VectorXs>& x);
193 void set_id(
const pinocchio::FrameIndex
id);)
205 virtual void print(std::ostream& os)
const;
214 bool update_jacobians_;
216 pinocchio::FrameIndex id_;
220 template <
typename _Scalar>
223 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
225 typedef _Scalar Scalar;
232 typedef typename MathBase::MatrixXs MatrixXs;
234 template <
template <
typename Scalar>
class Model>
237 :
Base(model, data) {
240 bool is_contact =
true;
245 if (d1 == NULL && d2 == NULL) {
247 "Invalid argument: the shared data should be derived from "
248 "DataCollectorContact or DataCollectorImpulse");
255 const pinocchio::FrameIndex
id = model->get_id();
256 const boost::shared_ptr<StateMultibody>& state =
257 boost::static_pointer_cast<StateMultibody>(model->get_state());
258 std::string frame_name = state->get_pinocchio()->frames[id].name;
259 bool found_contact =
false;
261 for (
typename ContactModelMultiple::ContactDataContainer::iterator it =
262 d1->contacts->contacts.begin();
263 it != d1->contacts->contacts.end(); ++it) {
264 if (it->second->frame ==
id) {
269 found_contact =
true;
277 found_contact =
true;
285 found_contact =
true;
290 "Domain error: there isn't defined at least a 2d contact for " +
296 for (
typename ImpulseModelMultiple::ImpulseDataContainer::iterator it =
297 d2->impulses->impulses.begin();
298 it != d2->impulses->impulses.end(); ++it) {
299 if (it->second->frame ==
id) {
304 found_contact =
true;
312 found_contact =
true;
317 "Domain error: there isn't defined at least a 3d contact for " +
323 if (!found_contact) {
324 throw_pretty(
"Domain error: there isn't defined contact data for " +
329 boost::shared_ptr<ForceDataAbstractTpl<Scalar> >
343 #include "crocoddyl/multibody/residuals/contact-friction-cone.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.
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.