Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph-python
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
Stack Of Tasks
dynamic-graph-python
Commits
ec8d47ea
Commit
ec8d47ea
authored
5 years ago
by
Joseph Mirabel
Committed by
olivier stasse
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
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
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dynamic_graph/convert-dg-to-py.cc
+17
-0
17 additions, 0 deletions
src/dynamic_graph/convert-dg-to-py.cc
with
17 additions
and
0 deletions
src/dynamic_graph/convert-dg-to-py.cc
+
17
−
0
View file @
ec8d47ea
...
@@ -215,6 +215,12 @@ command::Value pythonToValue(PyObject* pyObject, const command::Value::Type& val
...
@@ -215,6 +215,12 @@ command::Value pythonToValue(PyObject* pyObject, const command::Value::Type& val
}
}
return
Value
(
m4
);
return
Value
(
m4
);
break
;
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
:
default
:
std
::
cerr
<<
"Only int, double and string are supported."
<<
std
::
endl
;
std
::
cerr
<<
"Only int, double and string are supported."
<<
std
::
endl
;
}
}
...
@@ -256,6 +262,15 @@ PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix) {
...
@@ -256,6 +262,15 @@ PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix) {
return
tuple
;
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
)
{
PyObject
*
valueToPython
(
const
command
::
Value
&
value
)
{
using
command
::
Value
;
using
command
::
Value
;
bool
boolValue
;
bool
boolValue
;
...
@@ -298,6 +313,8 @@ PyObject* valueToPython(const command::Value& value) {
...
@@ -298,6 +313,8 @@ PyObject* valueToPython(const command::Value& value) {
case
(
Value
::
MATRIX4D
):
case
(
Value
::
MATRIX4D
):
matrix4dValue
=
value
.
value
();
matrix4dValue
=
value
.
value
();
return
matrix4dToPython
(
matrix4dValue
);
return
matrix4dToPython
(
matrix4dValue
);
case
(
Value
::
VALUES
):
return
valuesToPython
(
value
.
constValuesValue
());
default
:
default
:
return
Py_BuildValue
(
""
);
return
Py_BuildValue
(
""
);
}
}
...
...
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