Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
loco-3d
Multicontact-api
Commits
a70c03b7
Commit
a70c03b7
authored
May 07, 2020
by
Pierre Fernbach
Browse files
[Python] API and tests for ContactModel::generatorMatrix method
parent
affd699a
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/multicontact-api/bindings/python/scenario/contact-model.hpp
View file @
a70c03b7
...
...
@@ -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
.
def
(
PrintableVisitor
<
ContactModel
>
());
ENABLE_SPECIFIC_MATRIX_TYPE
(
Matrix3X
);
ENABLE_SPECIFIC_MATRIX_TYPE
(
Matrix6X
);
}
private:
...
...
unittest/python/scenario.py
View file @
a70c03b7
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment