aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
multibody-wrench-cone.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "./fwd.hpp"
5
6#include <pinocchio/multibody/model.hpp>
7
8#include <pinocchio/algorithm/proximal.hpp>
9
10namespace aligator {
11
12template <typename Scalar> struct MultibodyWrenchConeDataTpl;
13
18
19template <typename _Scalar>
21public:
22 using Scalar = _Scalar;
25 using BaseData = typename Base::Data;
26 using Model = pinocchio::ModelTpl<Scalar>;
27 using SE3 = pinocchio::SE3Tpl<Scalar>;
29 using RigidConstraintModelVector = PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(
30 pinocchio::RigidConstraintModel);
32 PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(pinocchio::RigidConstraintData);
33 using ProxSettings = pinocchio::ProximalSettingsTpl<Scalar>;
34
39 double mu_;
40 double hL_;
41 double hW_;
43
44 Eigen::Matrix<Scalar, 17, 6> Acone_;
45
47 const int ndx, const Model &model, const MatrixXs &actuation,
48 const RigidConstraintModelVector &constraint_models,
49 const ProxSettings &prox_settings, const std::string &contact_name,
50 const double mu, const double half_length, const double half_width)
51 : Base(ndx, (int)actuation.cols(), 17)
52 , pin_model_(model)
53 , actuation_matrix_(actuation)
54 , constraint_models_(constraint_models)
55 , prox_settings_(prox_settings)
56 , mu_(mu)
57 , hL_(half_length)
58 , hW_(half_width) {
59 if (model.nv != actuation.rows()) {
60 ALIGATOR_DOMAIN_ERROR(
61 fmt::format("actuation matrix should have number of rows = pinocchio "
62 "model nv ({} and {}).",
63 actuation.rows(), model.nv));
64 }
65 contact_id_ = -1;
66 for (std::size_t i = 0; i < constraint_models.size(); i++) {
67 if (constraint_models[i].name == contact_name) {
68 contact_id_ = (int)i;
69 }
70 }
71 if (contact_id_ == -1) {
73 "Contact name is not included in constraint models");
74 }
75 Acone_ << 0, 0, -1, 0, 0, 0, -1, 0, -mu_, 0, 0, 0, 1, 0, -mu_, 0, 0, 0, 0,
76 -1, -mu_, 0, 0, 0, 0, 1, -mu_, 0, 0, 0, 0, 0, -hW_, -1, 0, 0, 0, 0,
77 -hW_, 1, 0, 0, 0, 0, -hL_, 0, -1, 0, 0, 0, -hL_, 0, 1, 0, -hW_, -hL_,
78 -(hL_ + hW_) * mu_, mu_, mu_, -1, -hW_, hL_, -(hL_ + hW_) * mu_, mu_,
79 -mu_, -1, hW_, -hL_, -(hL_ + hW_) * mu_, -mu_, mu_, -1, hW_, hL_,
80 -(hL_ + hW_) * mu_, -mu_, -mu_, -1, hW_, hL_, -(hL_ + hW_) * mu_, mu_,
81 mu_, 1, hW_, -hL_, -(hL_ + hW_) * mu_, mu_, -mu_, 1, -hW_, hL_,
82 -(hL_ + hW_) * mu_, -mu_, mu_, 1, -hW_, -hL_, -(hL_ + hW_) * mu_, -mu_,
83 -mu_, 1;
84 }
85
86 void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
87 BaseData &data) const;
88
89 void computeJacobians(const ConstVectorRef &, const ConstVectorRef &,
90 BaseData &data) const;
91
92 shared_ptr<BaseData> createData() const {
93 return std::make_shared<Data>(this);
94 }
95};
96
97template <typename Scalar>
99 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
101 using PinData = pinocchio::DataTpl<Scalar>;
106 PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(pinocchio::RigidConstraintData);
107
112
114 pinocchio::ProximalSettingsTpl<Scalar> settings;
115
118};
119
120} // namespace aligator
121
122#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
123#include "aligator/modelling/multibody/multibody-wrench-cone.txx"
124#endif
#define ALIGATOR_RUNTIME_ERROR(...)
Definition exceptions.hpp:7
Base definitions for ternary functions.
Main package namespace.
typename math_types< Scalar >::MatrixXs MatrixXs
typename math_types< Scalar >::VectorXs VectorXs
MultibodyWrenchConeDataTpl(const MultibodyWrenchConeResidualTpl< Scalar > *model)
pinocchio::ProximalSettingsTpl< Scalar > settings
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(pinocchio::RigidConstraintData) RigidConstraintDataVector
typename math_types< Scalar >::Matrix6Xs Matrix6Xs
This residual returns the derivative of centroidal momentum for a kinodynamics model.
shared_ptr< BaseData > createData() const
Instantiate a Data object.
void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, BaseData &data) const
MultibodyWrenchConeResidualTpl(const int ndx, const Model &model, const MatrixXs &actuation, const RigidConstraintModelVector &constraint_models, const ProxSettings &prox_settings, const std::string &contact_name, const double mu, const double half_length, const double half_width)
MultibodyWrenchConeDataTpl< Scalar > Data
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(pinocchio::RigidConstraintData) RigidConstraintDataVector
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR( pinocchio::RigidConstraintModel) RigidConstraintModelVector
pinocchio::ProximalSettingsTpl< Scalar > ProxSettings
void computeJacobians(const ConstVectorRef &, const ConstVectorRef &, BaseData &data) const
StageFunctionDataTpl(const int ndx, const int nu, const int nr)
StageFunctionDataTpl< Scalar > Data
StageFunctionTpl(const int ndx, const int nu, const int nr)
Typedefs for math (Eigen vectors, matrices) depending on scalar type.
Definition math.hpp:100