aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-force-cost.cpp
Go to the documentation of this file.
1
3#ifdef ALIGATOR_WITH_PINOCCHIO
4
7
8#ifdef ALIGATOR_PINOCCHIO_V3
13
14namespace aligator {
15namespace python {
16
17using Vector3or6 = Eigen::Matrix<double, -1, 1, Eigen::ColMajor, 6, 1>;
18using context::ConstVectorRef;
21using context::Scalar;
24using RigidConstraintModel =
25 pinocchio::RigidConstraintModelTpl<context::Scalar, 0>;
26using RigidConstraintData =
27 pinocchio::RigidConstraintDataTpl<context::Scalar, 0>;
28
29using RigidConstraintModelVector =
30 PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel);
31using RigidConstraintDataVector =
32 PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintData);
33
34const PolymorphicMultiBaseVisitor<StageFunction> func_visitor;
35
36void exposeContactForce() {
37 using ContactForceResidual = ContactForceResidualTpl<Scalar>;
38 using ContactForceData = ContactForceDataTpl<Scalar>;
39
40 using MultibodyWrenchConeResidual = MultibodyWrenchConeResidualTpl<Scalar>;
41 using MultibodyWrenchConeData = MultibodyWrenchConeDataTpl<Scalar>;
42
43 using MultibodyFrictionConeResidual =
44 MultibodyFrictionConeResidualTpl<Scalar>;
45 using MultibodyFrictionConeData = MultibodyFrictionConeDataTpl<Scalar>;
46
47 bp::class_<ContactForceResidual, bp::bases<StageFunction>>(
48 "ContactForceResidual",
49 "A residual function :math:`r(x) = v_{j,xy} e^{-s z_j}` where :math:`j` "
50 "is a given frame index.",
51 bp::no_init)
52 .def(bp::init<int, PinModel, const context::MatrixXs &,
53 const RigidConstraintModelVector &,
54 const pinocchio::ProximalSettingsTpl<Scalar> &,
55 const Eigen::VectorXd &, const std::string &>(bp::args(
56 "self", "ndx", "model", "actuation_matrix", "constraint_models",
57 "prox_settings", "fref", "contact_name")))
58 .def(func_visitor)
59 .def("getReference", &ContactForceResidual::getReference,
60 bp::args("self"), bp::return_internal_reference<>(),
61 "Get the target force.")
62 .def("setReference", &ContactForceResidual::setReference,
63 bp::args("self", "fnew"), "Set the target force.")
64 .def_readwrite("constraint_models",
65 &ContactForceResidual::constraint_models_);
66
67 bp::class_<ContactForceData, bp::bases<StageFunctionData>>("ContactForceData",
68 bp::no_init)
69 .def_readwrite("tau", &ContactForceData::tau_)
70 .def_readwrite("pin_data", &ContactForceData::pin_data_)
71 .def_readwrite("constraint_datas", &ContactForceData::constraint_datas_);
72
73 bp::class_<MultibodyWrenchConeResidual, bp::bases<StageFunction>>(
74 "MultibodyWrenchConeResidual", "A residual function :math:`r(x) = Af` ",
75 bp::no_init)
76 .def(bp::init<int, PinModel, const context::MatrixXs &,
77 const RigidConstraintModelVector &,
78 const pinocchio::ProximalSettingsTpl<Scalar> &,
79 const std::string &, const double, const double,
80 const double>(bp::args(
81 "self", "ndx", "model", "actuation_matrix", "constraint_models",
82 "prox_settings", "contact_name", "mu", "half_length", "half_width")))
83 .def(func_visitor)
84 .def_readwrite("constraint_models",
85 &MultibodyWrenchConeResidual::constraint_models_);
86
87 bp::class_<MultibodyWrenchConeData, bp::bases<StageFunctionData>>(
88 "MultibodyWrenchConeData", bp::no_init)
89 .def_readwrite("tau", &MultibodyWrenchConeData::tau_)
90 .def_readwrite("pin_data", &MultibodyWrenchConeData::pin_data_)
91 .def_readwrite("constraint_datas",
92 &MultibodyWrenchConeData::constraint_datas_);
93
94 bp::class_<MultibodyFrictionConeResidual, bp::bases<StageFunction>>(
95 "MultibodyFrictionConeResidual", "A residual function :math:`r(x) = Af` ",
96 bp::no_init)
97 .def(bp::init<int, PinModel, const context::MatrixXs &,
98 const RigidConstraintModelVector &,
99 const pinocchio::ProximalSettingsTpl<Scalar> &,
100 const std::string &, const double>(
101 bp::args("self", "ndx", "model", "actuation_matrix",
102 "constraint_models", "prox_settings", "contact_name", "mu")))
103 .def(func_visitor)
104 .def_readwrite("constraint_models",
105 &MultibodyFrictionConeResidual::constraint_models_);
106
107 bp::class_<MultibodyFrictionConeData, bp::bases<StageFunctionData>>(
108 "MultibodyFrictionConeData", bp::no_init)
109 .def_readwrite("tau", &MultibodyFrictionConeData::tau_)
110 .def_readwrite("pin_data", &MultibodyFrictionConeData::pin_data_)
111 .def_readwrite("constraint_datas",
112 &MultibodyFrictionConeData::constraint_datas_);
113}
114
115} // namespace python
116} // namespace aligator
117
118#endif
119
120#endif
pinocchio::ModelTpl< Scalar, Options > PinModel
Definition context.hpp:9
StageFunctionTpl< Scalar > StageFunction
Definition context.hpp:16
proxsuite::nlp::MultibodyPhaseSpace< Scalar > MultibodyPhaseSpace
Definition context.hpp:16
StageFunctionDataTpl< Scalar > StageFunctionData
Definition context.hpp:18
PolymorphicMultiBaseVisitor< StageFunction > func_visitor
Main package namespace.