Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
robotpkg-wip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gepetto
robotpkg-wip
Commits
4a48fe47
Commit
4a48fe47
authored
9 years ago
by
Rohan Budhiraja
Committed by
Matthieu Herrb
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[wip/py-dynamic-graph3] Patch for inputing Eigen::Transform as Matrix4d
parent
9479d9d1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py-dynamic-graph3/Makefile
+3
-0
3 additions, 0 deletions
py-dynamic-graph3/Makefile
py-dynamic-graph3/distinfo
+1
-0
1 addition, 0 deletions
py-dynamic-graph3/distinfo
py-dynamic-graph3/patches/patch-aa
+127
-0
127 additions, 0 deletions
py-dynamic-graph3/patches/patch-aa
with
131 additions
and
0 deletions
py-dynamic-graph3/Makefile
+
3
−
0
View file @
4a48fe47
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
DISTNAME
=
dynamic-graph-python-
${
VERSION
}
DISTNAME
=
dynamic-graph-python-
${
VERSION
}
VERSION
=
3.0.0
VERSION
=
3.0.0
PKGREVISION
=
1
PKGNAME
=
${
PKGTAG.python-
}
dynamic-graph-
${
VERSION
}
PKGNAME
=
${
PKGTAG.python-
}
dynamic-graph-
${
VERSION
}
MASTER_SITES
=
${
MASTER_SITE_OPENROBOTS:
=
dynamic-graph-python/
}
MASTER_SITES
=
${
MASTER_SITE_OPENROBOTS:
=
dynamic-graph-python/
}
MASTER_REPOSITORY
=
${
MASTER_REPOSITORY_GITHUB
}
/proyan/dynamic-graph-python
MASTER_REPOSITORY
=
${
MASTER_REPOSITORY_GITHUB
}
/proyan/dynamic-graph-python
...
@@ -29,6 +31,7 @@ CMAKE_ARGS+= -DCMAKE_INSTALL_LIBDIR=lib
...
@@ -29,6 +31,7 @@ CMAKE_ARGS+= -DCMAKE_INSTALL_LIBDIR=lib
# fixed here
# fixed here
CMAKE_ARGS
+=
-DCXX_DISABLE_WERROR
=
yes
CMAKE_ARGS
+=
-DCXX_DISABLE_WERROR
=
yes
PATCH_STRIP
?=
-p1
DEPEND_ABI.python
+=
python<3
DEPEND_ABI.python
+=
python<3
include
../../wip/dynamic-graph3/depend.mk
include
../../wip/dynamic-graph3/depend.mk
...
...
This diff is collapsed.
Click to expand it.
py-dynamic-graph3/distinfo
+
1
−
0
View file @
4a48fe47
SHA1 (dynamic-graph-python-3.0.0.tar.gz) = 8c847cca3273d60b9d12c5fb883f3ff8aba25117
SHA1 (dynamic-graph-python-3.0.0.tar.gz) = 8c847cca3273d60b9d12c5fb883f3ff8aba25117
RMD160 (dynamic-graph-python-3.0.0.tar.gz) = 64c15fd48b1cf96d60e3e9b7f4267ecbb9a878d3
RMD160 (dynamic-graph-python-3.0.0.tar.gz) = 64c15fd48b1cf96d60e3e9b7f4267ecbb9a878d3
Size (dynamic-graph-python-3.0.0.tar.gz) = 778414 bytes
Size (dynamic-graph-python-3.0.0.tar.gz) = 778414 bytes
SHA1 (patch-aa) = 3f3f7224e931fd652ac8861b20a2eae39695b8af
This diff is collapsed.
Click to expand it.
py-dynamic-graph3/patches/patch-aa
0 → 100644
+
127
−
0
View file @
4a48fe47
Patch for inputing Eigen::Transform as Matrix4d
diff --git a/src/convert-dg-to-py.cc b/src/convert-dg-to-py.cc
index 0c9cc61..446dba0 100644
--- a/src/convert-dg-to-py.cc
+++ b/src/convert-dg-to-py.cc
@@ -49,6 +49,24 @@
namespace dynamicgraph {
"a floating point number.");
}
}
+ void fillMatrixRow(Eigen::Matrix4d& m, unsigned iRow, PyObject* tuple)
+ {
+ if (PyTuple_Size(tuple) != (int)m.cols()) {
+ throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
+ "lines of matrix have different sizes.");
+ }
+ for (int iCol=0; iCol < m.cols(); iCol++) {
+ PyObject* pyDouble = PyTuple_GetItem(tuple, iCol);
+ if (PyFloat_Check(pyDouble))
+ m(iRow, iCol) = PyFloat_AsDouble(pyDouble);
+ else if(PyInt_Check(pyDouble))
+ m(iRow, iCol) = (int)PyInt_AS_LONG(pyDouble)+0.0;
+ else
+ throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
+ "element of matrix should be "
+ "a floating point number.");
+ }
+ }
command::Value pythonToValue(PyObject* pyObject,
const command::Value::Type& valueType)
@@ -62,6 +80,7 @@
namespace dynamicgraph {
std::string svalue;
Vector v;
Matrix m;
+ Eigen::Matrix4d m4;
Py_ssize_t nCols;
Py_ssize_t size;
PyObject* row;
@@ -175,6 +194,36 @@
namespace dynamicgraph {
}
return Value(m);
break;
+ case (Value::MATRIX4D) :
+ // Check that argument is a tuple
+ if (!PyTuple_Check(pyObject)) {
+ throw ExceptionPython(ExceptionPython::VALUE_PARSING,
+ "matrix4d");
+ }
+ nRows = PyTuple_Size(pyObject);
+ if (nRows == 0) {
+ return Value(Eigen::Matrix4d());
+ }
+ row = PyTuple_GetItem(pyObject, 0);
+ if (!PyTuple_Check(row)) {
+ throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
+ "matrix4d");
+ }
+ nCols = PyTuple_Size(row);
+
+ m4.resize(nRows, nCols);
+ fillMatrixRow(m4, 0, row);
+
+ for (Py_ssize_t iRow=1; iRow<nRows; iRow++) {
+ row = PyTuple_GetItem(pyObject, iRow);
+ if (!PyTuple_Check(row)) {
+ throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
+ "matrix");
+ }
+ fillMatrixRow(m4, static_cast<unsigned> (iRow), row);
+ }
+ return Value(m4);
+ break;
default:
std::cerr << "Only int, double and string are supported."
<< std::endl;
@@ -206,6 +255,20 @@
namespace dynamicgraph {
return tuple;
}
+ PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix)
+ {
+ PyObject* tuple = PyTuple_New(matrix.rows());
+ for (int iRow = 0; iRow < matrix.rows(); iRow++) {
+ PyObject* row = PyTuple_New(matrix.cols());
+ for (int iCol=0; iCol < matrix.cols(); iCol++) {
+ PyObject* pyDouble = PyFloat_FromDouble(matrix(iRow, iCol));
+ PyTuple_SET_ITEM(row, iCol, pyDouble);
+ }
+ PyTuple_SET_ITEM(tuple, iRow, row);
+ }
+ return tuple;
+ }
+
PyObject* valueToPython(const command::Value& value)
{
using command::Value;
@@ -217,6 +280,7 @@
namespace dynamicgraph {
std::string stringValue;
Vector vectorValue;
Matrix matrixValue;
+ Eigen::Matrix4d matrix4dValue;
switch(value.type()) {
case (Value::BOOL) :
boolValue = value.value();
@@ -245,6 +309,9 @@
namespace dynamicgraph {
case (Value::MATRIX) :
matrixValue = value.value();
return matrixToPython(matrixValue);
+ case (Value::MATRIX4D) :
+ matrix4dValue = value.value();
+ return matrix4dToPython(matrix4dValue);
default:
return Py_BuildValue("");
}
diff --git a/src/convert-dg-to-py.hh b/src/convert-dg-to-py.hh
index 62d6fc2..13f114f 100644
--- a/src/convert-dg-to-py.hh
+++ b/src/convert-dg-to-py.hh
@@ -26,6 +26,7 @@
namespace dynamicgraph {
const command::Value::Type& valueType);
PyObject* vectorToPython(const Vector& vector);
PyObject* matrixToPython(const ::dynamicgraph::Matrix& matrix);
+ PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix);
PyObject* valueToPython(const ::dynamicgraph::command::Value& value);
} // namespace dynamicgraph
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment