Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#9293 from mpetersen94/py_more_bind…
Browse files Browse the repository at this point in the history
…ings

pydrake: Add bindings for AddLinearEqualityConstraint
  • Loading branch information
ggould-tri authored Aug 23, 2018
2 parents 557e31a + 4823a63 commit 6001128
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bindings/pydrake/solvers/mathematicalprogram_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ PYBIND11_MODULE(_mathematicalprogram_py, m) {
.def("AddLinearConstraint",
static_cast<Binding<LinearConstraint> (MathematicalProgram::*)(
const Formula&)>(&MathematicalProgram::AddLinearConstraint))
.def("AddLinearEqualityConstraint",
static_cast<Binding<LinearEqualityConstraint> (
MathematicalProgram::*)(
const Eigen::Ref<const Eigen::MatrixXd>&,
const Eigen::Ref<const Eigen::VectorXd>&,
const Eigen::Ref<const VectorXDecisionVariable>&)>(
&MathematicalProgram::AddLinearEqualityConstraint))
.def("AddLinearEqualityConstraint",
static_cast<Binding<LinearEqualityConstraint> (
MathematicalProgram::*)(const Expression&, double)>(
&MathematicalProgram::AddLinearEqualityConstraint))
.def("AddLinearEqualityConstraint",
static_cast<Binding<LinearEqualityConstraint> (
MathematicalProgram::*)(const Formula&)>(
&MathematicalProgram::AddLinearEqualityConstraint))
.def("AddLorentzConeConstraint",
static_cast<Binding<LorentzConeConstraint> (MathematicalProgram::*)(
const Eigen::Ref<const VectorX<drake::symbolic::Expression>>&)>(
Expand Down
4 changes: 4 additions & 0 deletions bindings/pydrake/solvers/test/mathematicalprogram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ def test_linear_constraints(self):
prog.AddBoundingBoxConstraint(0., 1., x)
prog.AddLinearConstraint(np.eye(2), np.zeros(2), np.ones(2), x)

prog.AddLinearEqualityConstraint(np.eye(2), np.zeros(2), x)
prog.AddLinearEqualityConstraint(x[0] == 1)
prog.AddLinearEqualityConstraint(x[0] + x[1], 1)

def test_pycost_and_pyconstraint(self):
prog = mp.MathematicalProgram()
x = prog.NewContinuousVariables(1, 'x')
Expand Down
3 changes: 3 additions & 0 deletions bindings/pydrake/util/eigen_geometry_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ PYBIND11_MODULE(eigen_geometry, m) {
}, py::arg("position"))
.def("inverse", [](const Class* self) {
return self->inverse();
})
.def("conjugate", [](const Class* self) {
return self->conjugate();
});
}

Expand Down
2 changes: 2 additions & 0 deletions bindings/pydrake/util/test/eigen_geometry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def test_quaternion(self):
(q.multiply(position=[1, 2, 3]) == [3, 1, 2]).all())
q_I = q.inverse().multiply(q)
self.assertTrue(np.allclose(q_I.wxyz(), [1, 0, 0, 0]))
q_conj = q.conjugate()
self.assertTrue(np.allclose(q_conj.wxyz(), [0.5, -0.5, -0.5, -0.5]))

# Test `type_caster`s.
value = test_util.create_quaternion()
Expand Down

0 comments on commit 6001128

Please sign in to comment.