10 #ifndef CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_COP_POSITION_HPP_
11 #define CROCODDYL_MULTIBODY_RESIDUALS_CONTACT_COP_POSITION_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-3d.hpp"
17 #include "crocoddyl/multibody/contacts/contact-6d.hpp"
18 #include "crocoddyl/multibody/contacts/multiple-contacts.hpp"
19 #include "crocoddyl/multibody/cop-support.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"
66 template <
typename _Scalar>
70 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
72 typedef _Scalar Scalar;
80 typedef typename MathBase::VectorXs VectorXs;
81 typedef typename MathBase::MatrixXs MatrixXs;
82 typedef typename MathBase::Matrix46s Matrix46;
98 const pinocchio::FrameIndex
id,
100 const std::size_t nu,
101 const bool fwddyn =
true);
114 const pinocchio::FrameIndex
id,
130 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
131 const Eigen::Ref<const VectorXs>& x,
132 const Eigen::Ref<const VectorXs>& u);
144 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
145 const Eigen::Ref<const VectorXs>& x);
159 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
160 const Eigen::Ref<const VectorXs>& x,
161 const Eigen::Ref<const VectorXs>& u);
174 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
175 const Eigen::Ref<const VectorXs>& x);
217 void set_id(pinocchio::FrameIndex
id);)
222 void set_reference(
const CoPSupport& reference);
229 virtual void print(std::ostream& os)
const;
238 bool update_jacobians_;
240 pinocchio::FrameIndex id_;
244 template <
typename _Scalar>
247 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
249 typedef _Scalar Scalar;
254 typedef typename MathBase::MatrixXs MatrixXs;
256 template <
template <
typename Scalar>
class Model>
259 :
Base(model, data) {
261 bool is_contact =
true;
266 if (d1 == NULL && d2 == NULL) {
268 "Invalid argument: the shared data should be derived from "
269 "DataCollectorContact or DataCollectorImpulse");
276 const pinocchio::FrameIndex
id = model->get_id();
277 const boost::shared_ptr<StateMultibody>& state =
278 boost::static_pointer_cast<StateMultibody>(model->get_state());
279 std::string frame_name = state->get_pinocchio()->frames[id].name;
280 bool found_contact =
false;
282 for (
typename ContactModelMultiple::ContactDataContainer::iterator it =
283 d1->contacts->contacts.begin();
284 it != d1->contacts->contacts.end(); ++it) {
285 if (it->second->frame ==
id) {
289 found_contact =
true;
292 "Domain error: there isn't defined at least a 6d contact for " +
299 found_contact =
true;
304 "Domain error: there isn't defined at least a 6d contact for " +
310 for (
typename ImpulseModelMultiple::ImpulseDataContainer::iterator it =
311 d2->impulses->impulses.begin();
312 it != d2->impulses->impulses.end(); ++it) {
313 if (it->second->frame ==
id) {
317 found_contact =
true;
320 "Domain error: there isn't defined at least a 6d contact for " +
327 found_contact =
true;
332 "Domain error: there isn't defined at least a 6d contact for " +
338 if (!found_contact) {
339 throw_pretty(
"Domain error: there isn't defined contact data for " +
345 boost::shared_ptr<ForceDataAbstractTpl<Scalar> >
contact;
357 #include "crocoddyl/multibody/residuals/contact-cop-position.hxx"
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.