Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bindings/pydrake/multibody/plant_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ void DoScalarDependentDefinitions(py::module m, T) {
.def("AddWeldConstraint", &Class::AddWeldConstraint, py::arg("body_A"),
py::arg("X_AP"), py::arg("body_B"), py::arg("X_BQ"),
py_rvp::reference_internal, cls_doc.AddWeldConstraint.doc)
.def("AddTendonConstraint", &Class::AddTendonConstraint,
py::arg("joints"), py::arg("a"), py::arg("offset") = std::nullopt,
py::arg("lower_limit") = std::nullopt,
py::arg("upper_limit") = std::nullopt,
py::arg("stiffness") = std::nullopt,
py::arg("damping") = std::nullopt, py_rvp::reference_internal,
cls_doc.AddTendonConstraint.doc)
.def("RemoveConstraint", &Class::RemoveConstraint, py::arg("id"),
cls_doc.RemoveConstraint.doc);
// Mathy bits
Expand Down
29 changes: 29 additions & 0 deletions bindings/pydrake/multibody/test/plant_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,35 @@ def test_weld_constraint_api(self, T):
# Verify the constraint was added.
self.assertEqual(plant.num_constraints(), 1)

@numpy_compare.check_all_types
def test_tendon_constraint_api(self, T):
plant = MultibodyPlant_[T](0.01)
plant.set_discrete_contact_approximation(
DiscreteContactApproximation.kSap)

# Add weld constraint.
body_A = plant.AddRigidBody(name="A")
body_B = plant.AddRigidBody(name="B")
revolute_joint = plant.AddJoint(RevoluteJoint_[T](
name="revolute_joint", frame_on_parent=plant.world_frame(),
frame_on_child=body_A.body_frame(), axis=[0, 0, 1],
damping=0.))
prismatic_joint = plant.AddJoint(PrismaticJoint_[T](
name="prismatic_joint", frame_on_parent=plant.world_frame(),
frame_on_child=body_B.body_frame(), axis=[0, 0, 1],
damping=0.))

plant.AddTendonConstraint(
joints=[revolute_joint.index(), prismatic_joint.index()],
a=[0.1, 0.2], offset=0.3, lower_limit=-1.2, upper_limit=3.4,
stiffness=5.6, damping=7.8)

# We are done creating the model.
plant.Finalize()

# Verify the constraint was added.
self.assertEqual(plant.num_constraints(), 1)

@numpy_compare.check_all_types
def test_remove_constraint(self, T):
plant = MultibodyPlant_[T](0.01)
Expand Down