7#include "pinocchio/constraints.hpp" 8#include "pinocchio/bindings/python/fwd.hpp" 9#include "pinocchio/bindings/python/utils/printable.hpp" 10#include "pinocchio/bindings/python/algorithm/constraints/constraint-model-inheritance.hpp" 16 namespace bp = boost::python;
21 bp::class_<T> & expose_constraint_model(bp::class_<T> & cl)
28 bp::class_<context::PointContactConstraintModel> &
29 expose_constraint_model(bp::class_<context::PointContactConstraintModel> & cl)
31 typedef context::PointContactConstraintModel Self;
32 return cl.def(
"getFriction", &Self::getFriction,
"Get coulomb friction coefficient.")
33 .def(
"setFriction", &Self::setFriction,
"Set coulomb friction coefficient.")
34 .def_readwrite(
"geom1_id", &Self::geom1_id,
"Index of the first geometry object.")
35 .def_readwrite(
"geom2_id", &Self::geom2_id,
"Index of the second geometry object.");
39 bp::class_<context::JointFrictionConstraintModel> &
40 expose_constraint_model(bp::class_<context::JointFrictionConstraintModel> & cl)
42 typedef typename context::JointFrictionConstraintModel::JointIndexVector JointIndexVector;
43 typedef context::JointFrictionConstraintModel Self;
44 typedef context::VectorXs VectorXs;
46 bp::init<const context::Model &, const JointIndexVector &>(
47 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"m_active_joints")),
48 "Constructor from given joint index vector " 49 "implied in the constraint."))
52 const context::Model &,
const JointIndexVector &,
const context::VectorXs &,
53 const context::VectorXs &>(
54 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"m_active_joints"), bp::arg(
"lb"),
56 "Full constructor from model, active joints, lower and upper friction bounds."))
58 bp::init<const context::Model &>(
59 (bp::arg(
"self"), bp::arg(
"model")),
"Constructor from the model only."))
61 "getActiveJoints", &Self::getActiveJoints,
62 bp::return_value_policy<bp::copy_const_reference>())
64 "getActiveDofs", &Self::getActiveDofs,
65 bp::return_value_policy<bp::copy_const_reference>())
67 "getFrictionLowerLimit", &Self::getFrictionLowerLimit,
68 bp::return_value_policy<bp::copy_const_reference>(),
"Get friction lower limit.")
70 "setFrictionLowerLimit", bp::make_function(+[](Self & self,
const VectorXs & lb) {
71 self.setFrictionLowerLimit(lb);
73 "Set friction lower limit.")
75 "getFrictionUpperLimit", &Self::getFrictionUpperLimit,
76 bp::return_value_policy<bp::copy_const_reference>(),
"Get friction upper limit.")
78 "setFrictionUpperLimit", bp::make_function(+[](Self & self,
const VectorXs & ub) {
79 self.setFrictionUpperLimit(ub);
81 "Set friction upper limit.")
83 "getTimeStep", &Self::getTimeStep,
84 "Get dt used to convert friction force limits to impulse limits.")
86 "setTimeStep", +[](Self & self,
const context::Scalar dt) { self.setTimeStep(dt); },
87 bp::args(
"self",
"dt"),
88 "Set dt used to convert friction force limits to impulse limits.");
93 bp::class_<context::JointLimitConstraintModel> &
94 expose_constraint_model(bp::class_<context::JointLimitConstraintModel> & cl)
96 typedef typename context::JointLimitConstraintModel::JointIndexVector JointIndexVector;
97 typedef typename context::JointLimitConstraintModel Self;
99 bp::init<const context::Model &, const JointIndexVector &>(
100 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"activable_joints")),
101 "Constructor from given joint index vector " 102 "implied in the constraint."))
105 const context::Model &,
const JointIndexVector &,
const context::VectorXs &,
106 const context::VectorXs &>(
107 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"activable_joints"), bp::arg(
"lb"),
109 "Constructor from given joint index vector " 110 "implied in the constraint."))
113 const context::Model &,
const JointIndexVector &,
const context::VectorXs &,
114 const context::VectorXs &,
const context::VectorXs &>(
115 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"activable_joints"), bp::arg(
"lb"),
116 bp::arg(
"ub"), bp::arg(
"margin")),
117 "Constructor from given joint index vector " 118 "implied in the constraint."))
120 bp::init<const context::Model &>(
121 (bp::arg(
"self"), bp::arg(
"model")),
"Constructor from the model only."))
123 "getSelectedJoints", &Self::getSelectedJoints,
124 bp::return_value_policy<bp::copy_const_reference>(),
125 "Joints for which there is at least one position limit.")
126 .def(
"getNqReduce", &Self::getNqReduce,
"Sum of nq of activable joints.")
127 .def(
"getMaxOfNvs", &Self::getMaxOfNvs,
"Max nv of atomic joints in activable joints.")
129 "getActivablePositionLimit", &Self::getActivablePositionLimit,
130 bp::return_value_policy<bp::copy_const_reference>(),
131 "Position limit of the dof of the constraints.")
134 +[](
const Self & self, ConstraintSelectionType sel) ->
int {
137 case ConstraintSelectionType::CURRENT:
138 return self.lowerResidualSize(CurrentSelection());
139 case ConstraintSelectionType::MAXIMAL:
140 return self.lowerResidualSize(MaximalSelection());
142 PINOCCHIO_UNREACHABLE();
145 (bp::arg(
"self"), bp::arg(
"sel") = ConstraintSelectionType::CURRENT))
148 +[](
const Self & self, ConstraintSelectionType sel) ->
int {
151 case ConstraintSelectionType::CURRENT:
152 return self.upperResidualSize(CurrentSelection());
153 case ConstraintSelectionType::MAXIMAL:
154 return self.upperResidualSize(MaximalSelection());
156 PINOCCHIO_UNREACHABLE();
159 (bp::arg(
"self"), bp::arg(
"sel") = ConstraintSelectionType::CURRENT))
161 "setPositionLimitAndMargin",
163 Self & self,
const context::VectorXs & lb,
const context::VectorXs & ub,
164 const context::VectorXs & margin) ->
void {
165 self.setPositionLimitAndMargin(lb, ub, margin);
167 (bp::arg(
"self"), bp::arg(
"lb"), bp::arg(
"ub"), bp::arg(
"margin")),
168 "Set position limit and margin for activable constraints from lower_bound, upper_bound " 169 "and margin of size model.nq.")
171 "makeSelectionMaximal", &Self::makeSelectionMaximal, bp::arg(
"self"),
172 "Make the selection maximal (all activable constraints become active).")
174 "makeSelectionFilteredByLimitProximity",
175 +[](Self & self,
const context::VectorXs & q) {
176 self.makeSelectionFilteredByLimitProximity(q);
178 bp::args(
"self",
"q"),
179 "Set the selection to constraints that are near their limits given configuration q.")
181 "active_idx_in_activable",
182 +[](
const Self & self) ->
const typename Self::VectorOfSize & {
183 return self.active_idx_in_activable();
185 bp::return_internal_reference<>(),
186 "Vector of active indices in the activable constraints.");
Main pinocchio namespace.