Commit a70c03b7 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Python] API and tests for ContactModel::generatorMatrix method

parent affd699a
......@@ -21,6 +21,7 @@ struct ContactModelPythonVisitor : public boost::python::def_visitor<ContactMode
typedef typename ContactModel::Scalar Scalar;
typedef scenario::ContactType ContactType;
typedef typename ContactModel::Matrix3X Matrix3X;
typedef typename ContactModel::Matrix6X Matrix6X;
template <class PyClass>
void visit(PyClass& cl) const {
......@@ -37,6 +38,9 @@ struct ContactModelPythonVisitor : public boost::python::def_visitor<ContactMode
"3xnum_contact_points matrix defining the contact points positions in the frame of the contact "
"placement. \n"
"num_contact_points is automatically updated to the number of columns of this matrix.")
.def("generatorMatrix", &ContactModel::generatorMatrix,
"generatorMatrix Return a 6x(num_contact_points*3) matrix"
"containing the generator used to compute contact forces.")
.def(bp::self == bp::self)
.def(bp::self != bp::self)
.def("copy", &copy, "Returns a copy of *this.");
......@@ -50,6 +54,7 @@ struct ContactModelPythonVisitor : public boost::python::def_visitor<ContactMode
......@@ -208,6 +208,10 @@ class ContactModelTest(unittest.TestCase):
self.assertEqual(mp1.contact_points_positions.shape[1], 5)
self.assertTrue(isclose(mp1.contact_points_positions, pos).all())
generators = mp1.generatorMatrix()
self.assertEqual(generators.shape[0], 6)
self.assertEqual(generators.shape[1], 5*3)
mp1.num_contact_points = 2
self.assertEqual(mp1.num_contact_points, 2)
self.assertEqual(mp1.contact_points_positions.shape[0], 3)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment