9 #ifndef CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_WRENCH_CONE_HPP_
10 #define CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_WRENCH_CONE_HPP_
12 #include "crocoddyl/core/residual-base.hpp"
13 #include "crocoddyl/multibody/contact-base.hpp"
14 #include "crocoddyl/multibody/contacts/contact-3d.hpp"
15 #include "crocoddyl/multibody/contacts/contact-6d.hpp"
16 #include "crocoddyl/multibody/contacts/multiple-contacts.hpp"
17 #include "crocoddyl/multibody/data/contacts.hpp"
18 #include "crocoddyl/multibody/data/impulses.hpp"
19 #include "crocoddyl/multibody/fwd.hpp"
20 #include "crocoddyl/multibody/impulse-base.hpp"
21 #include "crocoddyl/multibody/impulses/impulse-3d.hpp"
22 #include "crocoddyl/multibody/impulses/impulse-6d.hpp"
23 #include "crocoddyl/multibody/impulses/multiple-impulses.hpp"
24 #include "crocoddyl/multibody/states/multibody.hpp"
25 #include "crocoddyl/multibody/wrench-cone.hpp"
53 template <
typename _Scalar>
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60 typedef _Scalar Scalar;
68 typedef typename MathBase::VectorXs VectorXs;
69 typedef typename MathBase::MatrixXs MatrixXs;
70 typedef typename MathBase::MatrixX6s MatrixX6s;
86 const pinocchio::FrameIndex
id,
89 const bool fwddyn =
true);
102 const pinocchio::FrameIndex
id,
118 virtual void calc(
const std::shared_ptr<ResidualDataAbstract>& data,
119 const Eigen::Ref<const VectorXs>& x,
120 const Eigen::Ref<const VectorXs>& u)
override;
132 virtual void calc(
const std::shared_ptr<ResidualDataAbstract>& data,
133 const Eigen::Ref<const VectorXs>& x)
override;
147 virtual void calcDiff(
const std::shared_ptr<ResidualDataAbstract>& data,
148 const Eigen::Ref<const VectorXs>& x,
149 const Eigen::Ref<const VectorXs>& u)
override;
162 virtual void calcDiff(
const std::shared_ptr<ResidualDataAbstract>& data,
163 const Eigen::Ref<const VectorXs>& x)
override;
191 template <
typename NewScalar>
214 void set_id(
const pinocchio::FrameIndex
id);)
219 void set_reference(
const WrenchCone& reference);
226 virtual void print(std::ostream& os)
const override;
235 bool update_jacobians_;
237 pinocchio::FrameIndex id_;
241 template <
typename _Scalar>
244 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
246 typedef _Scalar Scalar;
253 typedef typename MathBase::MatrixXs MatrixXs;
255 template <
template <
typename Scalar>
class Model>
258 :
Base(model, data) {
260 bool is_contact =
true;
265 if (d1 == NULL && d2 == NULL) {
267 "Invalid argument: the shared data should be derived from "
268 "DataCollectorContact or DataCollectorImpulse");
275 const pinocchio::FrameIndex
id = model->get_id();
276 const std::shared_ptr<StateMultibody>& state =
277 std::static_pointer_cast<StateMultibody>(model->get_state());
278 std::string frame_name = state->get_pinocchio()->frames[id].name;
279 bool found_contact =
false;
281 for (
typename ContactModelMultiple::ContactDataContainer::iterator it =
282 d1->contacts->contacts.begin();
283 it != d1->contacts->contacts.end(); ++it) {
284 if (it->second->frame ==
id) {
288 found_contact =
true;
291 "Domain error: there isn't defined at least a 6d contact for " +
298 found_contact =
true;
303 "Domain error: there isn't defined at least a 6d contact for " +
309 for (
typename ImpulseModelMultiple::ImpulseDataContainer::iterator it =
310 d2->impulses->impulses.begin();
311 it != d2->impulses->impulses.end(); ++it) {
312 if (it->second->frame ==
id) {
316 found_contact =
true;
319 "Domain error: there isn't defined at least a 6d contact for " +
326 found_contact =
true;
331 "Domain error: there isn't defined at least a 6d contact for " +
337 if (!found_contact) {
338 throw_pretty(
"Domain error: there isn't defined contact data for " +
344 std::shared_ptr<ForceDataAbstractTpl<Scalar> >
357 #include "crocoddyl/multibody/residuals/contact-wrench-cone.hxx"
359 CROCODDYL_DECLARE_EXTERN_TEMPLATE_CLASS(
361 CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(
Define a stack of impulse models.
Abstract class for residual models.
std::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.