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
Stack Of Tasks
dynamic-graph-python
Commits
ec8d47ea
Commit
ec8d47ea
authored
Jan 31, 2020
by
Joseph Mirabel
Committed by
olivier stasse
Feb 03, 2020
Browse files
Bind vector of Values from C++ to Python
At the moment, it is not possible to bind from Python to C++. See TODO
parent
d48a3221
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dynamic_graph/convert-dg-to-py.cc
View file @
ec8d47ea
...
...
@@ -215,6 +215,12 @@ command::Value pythonToValue(PyObject* pyObject, const command::Value::Type& val
}
return
Value
(
m4
);
break
;
case
(
Value
::
VALUES
):
// TODO the vector of values cannot be built since
// - the value type inside the vector are not know
// - inferring the value type from the Python type is not implemented.
throw
ExceptionPython
(
ExceptionPython
::
VALUE_PARSING
,
"not implemented: cannot create a vector of values"
);
break
;
default:
std
::
cerr
<<
"Only int, double and string are supported."
<<
std
::
endl
;
}
...
...
@@ -256,6 +262,15 @@ PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix) {
return
tuple
;
}
PyObject
*
valuesToPython
(
const
dynamicgraph
::
command
::
Values
&
vector
)
{
PyObject
*
tuple
=
PyTuple_New
(
vector
.
size
());
for
(
std
::
size_t
index
=
0
;
index
<
vector
.
size
();
index
++
)
{
PyObject
*
item
=
valueToPython
(
vector
[
index
]);
PyTuple_SET_ITEM
(
tuple
,
index
,
item
);
}
return
tuple
;
}
PyObject
*
valueToPython
(
const
command
::
Value
&
value
)
{
using
command
::
Value
;
bool
boolValue
;
...
...
@@ -298,6 +313,8 @@ PyObject* valueToPython(const command::Value& value) {
case
(
Value
::
MATRIX4D
):
matrix4dValue
=
value
.
value
();
return
matrix4dToPython
(
matrix4dValue
);
case
(
Value
::
VALUES
):
return
valuesToPython
(
value
.
constValuesValue
());
default:
return
Py_BuildValue
(
""
);
}
...
...
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