28 :
public boost::python::def_visitor<RigidConstraintModelPythonVisitor<RigidConstraintModel>>
30 typedef typename RigidConstraintModel::Scalar Scalar;
31 typedef typename RigidConstraintModel::SE3 SE3;
32 typedef RigidConstraintModel Self;
33 typedef typename RigidConstraintModel::ContactData ContactData;
35 typename RigidConstraintModel::BaumgarteCorrectorParameters BaumgarteCorrectorParameters;
37 typedef ModelTpl<Scalar, RigidConstraintModel::Options, JointCollectionDefaultTpl> Model;
38 typedef DataTpl<Scalar, RigidConstraintModel::Options, JointCollectionDefaultTpl> Data;
41 template<
class PyClass>
42 void visit(PyClass & cl)
const 49 ContactType,
const Model &, JointIndex,
const SE3 &, JointIndex,
const SE3 &,
50 bp::optional<ReferenceFrame>>(
51 (bp::arg(
"self"), bp::arg(
"contact_type"), bp::arg(
"model"), bp::arg(
"joint1_id"),
52 bp::arg(
"joint1_placement"), bp::arg(
"joint2_id"), bp::arg(
"joint2_placement"),
53 bp::arg(
"reference_frame")),
54 "Constructor from a given ContactType, joint index and placement for the two joints " 55 "implied in the constraint."))
58 ContactType,
const Model &, JointIndex,
const SE3 &, bp::optional<ReferenceFrame>>(
59 (bp::arg(
"self"), bp::arg(
"contact_type"), bp::arg(
"model"), bp::arg(
"joint1_id"),
60 bp::arg(
"joint1_placement"), bp::arg(
"reference_frame")),
61 "Constructor from a given ContactType, joint index and placement only for the first " 62 "joint implied in the constraint."))
64 bp::init<ContactType,
const Model &, JointIndex, bp::optional<ReferenceFrame>>(
65 (bp::arg(
"self"), bp::arg(
"contact_type"), bp::arg(
"model"), bp::arg(
"joint1_id"),
66 bp::arg(
"reference_frame")),
67 "Constructor from a given ContactType and joint index. The base joint is taken as 0 " 70 .PINOCCHIO_ADD_PROPERTY(Self, name,
"Name of the contact.")
71 .PINOCCHIO_ADD_PROPERTY(Self, type,
"Type of the contact.")
72 .PINOCCHIO_ADD_PROPERTY(Self, joint1_id,
"Index of first parent joint in the model tree.")
73 .PINOCCHIO_ADD_PROPERTY(
74 Self, joint2_id,
"Index of second parent joint in the model tree.")
75 .PINOCCHIO_ADD_PROPERTY(
76 Self, joint1_placement,
"Relative placement with respect to the frame of joint1.")
77 .PINOCCHIO_ADD_PROPERTY(
78 Self, joint2_placement,
"Relative placement with respect to the frame of joint2.")
79 .PINOCCHIO_ADD_PROPERTY(
80 Self, reference_frame,
81 "Reference frame where the constraint is expressed (WORLD, " 82 "LOCAL_WORLD_ALIGNED or LOCAL).")
83 .PINOCCHIO_ADD_PROPERTY(Self, desired_contact_placement,
"Desired contact placement.")
84 .PINOCCHIO_ADD_PROPERTY(
85 Self, desired_contact_velocity,
"Desired contact spatial velocity.")
86 .PINOCCHIO_ADD_PROPERTY(
87 Self, desired_contact_acceleration,
"Desired contact spatial acceleration.")
89 "createData", &RigidConstraintModelPythonVisitor::createData,
90 "Create a Data object for the given model.")
93 "calc", (
void (Self::*)(
const Model &,
const Data &, ContactData &)
const) & Self::calc,
94 bp::args(
"self",
"model",
"data",
"constraint_data"))
95 .def(
"jacobian", &jacobian, bp::args(
"self",
"model",
"data",
"constraint_data"))
97 "residualSize", &residualSize,
98 (bp::arg(
"self"), bp::arg(
"sel") = ConstraintSelectionType::CURRENT),
99 "Constraint size for the selection.")
101 "setCompliance", &setCompliance,
102 (bp::arg(
"self"), bp::arg(
"vec"), bp::arg(
"sel") = ConstraintSelectionType::CURRENT),
103 "Set the compliance value for the selected constraint.")
105 "retrieveCompliance", &retrieveCompliance,
106 (bp::arg(
"self"), bp::arg(
"sel") = ConstraintSelectionType::CURRENT),
107 "Retrieve the compliance value for the selected constraint.")
109 "setBaumgarteCorrectorParameters", &setBaumgarteCorrectorParameters,
110 (bp::arg(
"self"), bp::arg(
"bp"), bp::arg(
"sel") = ConstraintSelectionType::CURRENT),
111 "Set the Baumgarte parameters.");
113 "m_baumgarte_parameters",
115 +[](Self & self) -> BaumgarteCorrectorParameters & {
116 return self.baumgarte_corrector_parameters();
118 bp::return_internal_reference<>()),
120 +[](Self & self,
const BaumgarteCorrectorParameters &
copy) {
121 self.baumgarte_corrector_parameters() =
copy;
123 bp::return_internal_reference<>()),
124 "Baumgarte parameters associated with the constraint.");
127 static context::RigidConstraintModel convertToRigidConstraintModel_point(
128 const context::Model & model,
129 const context::PointAnchorConstraintModel & constraint,
130 const ReferenceFrame reference_frame)
132 return convertToRigidConstraintModel(model, constraint, reference_frame);
135 static context::RigidConstraintModel convertToRigidConstraintModel_frame(
136 const context::Model & model,
137 const context::FrameAnchorConstraintModel & constraint,
138 const ReferenceFrame reference_frame)
140 return convertToRigidConstraintModel(model, constraint, reference_frame);
145 bp::class_<RigidConstraintModel>(
146 "RigidConstraintModel",
"Rigid contact model for contact dynamic algorithms.",
152 RigidConstraintModel, ::pinocchio::RigidConstraintModel>());
155 "convertToRigidConstraintModel", convertToRigidConstraintModel_point,
156 (bp::arg(
"model"), bp::arg(
"constraint"),
157 bp::arg(
"reference_frame") = ReferenceFrame::LOCAL),
158 "Convert a PointAnchorConstraintModel to a RigidConstraintModel with contact type " 160 "The kinematic structure (joint IDs and placements) is preserved. The 3D desired " 161 "offset is placed in the translation of desired_contact_placement, and the 3D desired " 162 "velocity/acceleration are placed in the linear parts of the corresponding Motion " 167 "convertToRigidConstraintModel", convertToRigidConstraintModel_frame,
168 (bp::arg(
"model"), bp::arg(
"constraint"),
169 bp::arg(
"reference_frame") = ReferenceFrame::LOCAL),
170 "Convert a FrameAnchorConstraintModel to a RigidConstraintModel with contact type " 172 "The kinematic structure (joint IDs and placements) is preserved. The 6D desired " 173 "offset (ordered [linear; angular]) is mapped to desired_contact_placement via exp6, " 174 "and the 6D desired velocity/acceleration vectors are mapped directly to Motion fields.",
178 static ContactData createData(
const Self & self)
180 return ContactData(self);
183 static context::MatrixXs jacobian(
184 const Self & self,
const Model & model,
const Data & data, ContactData & constraint_data)
186 context::MatrixXs res(self.residualSize(), model.nv);
187 self.jacobian(model, data, constraint_data, res);
191 static int residualSize(
const Self & self, ConstraintSelectionType sel)
195 case ConstraintSelectionType::CURRENT:
196 return self.residualSize(CurrentSelection());
197 case ConstraintSelectionType::MAXIMAL:
198 return self.residualSize(MaximalSelection());
200 PINOCCHIO_UNREACHABLE();
205 setCompliance(Self & self, context::VectorXs & vector, ConstraintSelectionType sel)
209 case ConstraintSelectionType::CURRENT:
210 return self.setCompliance(vector, CurrentSelection());
211 case ConstraintSelectionType::MAXIMAL:
212 return self.setCompliance(vector, MaximalSelection());
216 static context::VectorXs retrieveCompliance(
const Self & self, ConstraintSelectionType sel)
220 case ConstraintSelectionType::CURRENT: {
221 context::VectorXs res(self.residualSize(CurrentSelection()));
222 self.retrieveCompliance(res, CurrentSelection());
225 case ConstraintSelectionType::MAXIMAL: {
226 context::VectorXs res(self.residualSize(MaximalSelection()));
227 self.retrieveCompliance(res, MaximalSelection());
231 PINOCCHIO_UNREACHABLE();
235 static void setBaumgarteCorrectorParameters(
236 Self & self,
const BaumgarteCorrectorParameters & bp, ConstraintSelectionType sel)
240 case ConstraintSelectionType::CURRENT:
241 return self.setBaumgarteCorrectorParameters(bp, CurrentSelection());
242 case ConstraintSelectionType::MAXIMAL:
243 return self.setBaumgarteCorrectorParameters(bp, MaximalSelection());
250 :
public boost::python::def_visitor<RigidConstraintDataPythonVisitor<RigidConstraintData>>
252 typedef typename RigidConstraintData::Scalar Scalar;
253 typedef RigidConstraintData Self;
254 typedef typename RigidConstraintData::ContactModel ContactModel;
257 template<
class PyClass>
258 void visit(PyClass & cl)
const 261 bp::init<const ContactModel &>(
262 bp::args(
"self",
"contact_model"),
"Default constructor."))
264 .PINOCCHIO_ADD_PROPERTY(Self, contact_force,
"Constraint force.")
265 .PINOCCHIO_ADD_PROPERTY(
266 Self, oMc1,
"Placement of the constraint frame 1 with respect to the WORLD frame.")
267 .PINOCCHIO_ADD_PROPERTY(
268 Self, oMc2,
"Placement of the constraint frame 2 with respect to the WORLD frame.")
269 .PINOCCHIO_ADD_PROPERTY(Self, c1Mc2,
"Relative displacement between the two frames.")
270 .PINOCCHIO_ADD_PROPERTY(
271 Self, contact_placement_error,
272 "Current contact placement error between the two contact Frames.\n" 273 "This corresponds to the relative placement between the two contact Frames seen as a " 275 .PINOCCHIO_ADD_PROPERTY(
276 Self, contact1_velocity,
"Current contact Spatial velocity of the constraint 1.")
277 .PINOCCHIO_ADD_PROPERTY(
278 Self, contact2_velocity,
"Current contact Spatial velocity of the constraint 2.")
279 .PINOCCHIO_ADD_PROPERTY(
280 Self, contact_velocity_error,
281 "Current contact Spatial velocity error between the two contact Frames.\n" 282 "This corresponds to the relative velocity between the two contact Frames.")
283 .PINOCCHIO_ADD_PROPERTY(
284 Self, contact_acceleration,
"Current contact Spatial acceleration.")
285 .PINOCCHIO_ADD_PROPERTY(
286 Self, contact_acceleration_desired,
"Desired contact acceleration.")
287 .PINOCCHIO_ADD_PROPERTY(
288 Self, contact_acceleration_error,
289 "Current contact spatial error (due to the integration step).")
290 .PINOCCHIO_ADD_PROPERTY(
291 Self, contact1_acceleration_drift,
292 "Current contact drift acceleration (acceleration only due to the Coriolis and " 293 "centrifugal effects) of the contact frame 1.")
294 .PINOCCHIO_ADD_PROPERTY(
295 Self, contact2_acceleration_drift,
296 "Current contact drift acceleration (acceleration only due to the Coriolis and " 297 "centrifugal effects) of the contact frame 2.")
298 .PINOCCHIO_ADD_PROPERTY(
299 Self, contact_acceleration_deviation,
300 "Contact deviation from the reference acceleration (a.k.a the error).")
302 .PINOCCHIO_ADD_PROPERTY(
303 Self, extended_motion_propagators_joint1,
304 "Extended force/motion propagators for joint 1.")
305 .PINOCCHIO_ADD_PROPERTY(
306 Self, lambdas_joint1,
"Extended force/motion propagators for joint 1.")
307 .PINOCCHIO_ADD_PROPERTY(
308 Self, extended_motion_propagators_joint2,
309 "Extended force/motion propagators for joint 2.")
316 bp::class_<RigidConstraintData>(
317 "RigidConstraintData",
318 "Rigid constraint data associated to a " 319 "RigidConstraintModel for contact dynamic algorithms.",
323 typedef typename RigidConstraintData::VectorOfMatrix6 VectorOfMatrix6;
324 StdVectorPythonVisitor<VectorOfMatrix6, true>::expose(
"StdVec_Matrix6_");