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
Guilhem Saurel
dynamic-graph-python
Commits
b055ba73
Commit
b055ba73
authored
13 years ago
by
Nicolas Mansard
Committed by
Florent Lamiraux florent@laas.fr
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Modify SignalBase.value.
parent
ce7e72d0
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/signal-base-py.cc
+55
-13
55 additions, 13 deletions
src/signal-base-py.cc
with
55 additions
and
13 deletions
src/signal-base-py.cc
+
55
−
13
View file @
b055ba73
...
...
@@ -18,6 +18,7 @@
#include
<sstream>
#include
<dynamic-graph/signal-base.h>
#include
<dynamic-graph/signal-ptr.h>
#include
<dynamic-graph/signal.h>
#include
<dynamic-graph/signal-caster.h>
#include
<dynamic-graph/linear-algebra.h>
...
...
@@ -154,20 +155,61 @@ namespace dynamicgraph {
pointer
=
PyCObject_AsVoidPtr
(
object
);
SignalBase
<
int
>*
signal
=
(
SignalBase
<
int
>*
)
pointer
;
/* Temptative for specific signal type. */
Signal
<
dynamicgraph
::
Vector
,
int
>
*
sigvec
=
dynamic_cast
<
Signal
<
dynamicgraph
::
Vector
,
int
>*
>
(
signal
);
if
(
NULL
!=
sigvec
)
{
return
vectorToPython
(
sigvec
->
accessCopy
()
);
}
{
// --- VECTOR SIGNALS -----------------
// Two cases: the signal embeds directly a vector, or embeds
// an object deriving from vector.In the first case,
// the signal is directly cast into sig<vector>.
// In the second case, the derived object can be access as a vector
// using the signal-ptr<vector> type.
Signal
<
dynamicgraph
::
Vector
,
int
>
*
sigvec
=
dynamic_cast
<
Signal
<
dynamicgraph
::
Vector
,
int
>*
>
(
signal
);
if
(
NULL
!=
sigvec
)
{
return
vectorToPython
(
sigvec
->
accessCopy
()
);
}
// Extraction of object derinving from vector: plug signal into
// a vector signal and get the value from the signal-ptr instead
// of the original vector.
SignalPtr
<
dynamicgraph
::
Vector
,
int
>
sigptr
(
NULL
,
"vector-caster"
);
try
{
sigptr
.
plug
(
signal
);
return
vectorToPython
(
sigptr
.
accessCopy
()
);
}
catch
(
dynamicgraph
::
ExceptionSignal
&
ex
)
{
if
(
ex
.
getCode
()
!=
dynamicgraph
::
ExceptionSignal
::
PLUG_IMPOSSIBLE
)
throw
;
}
}
{
// --- MATRIX SIGNALS --------------------
// Two cases: the signal embeds directly a matrix, or embeds
// an object deriving from matrix.In the first case,
// the signal is directly cast into sig<matrix>.
// In the second case, the derived object can be access as a matrix
// using the signal-ptr<matrix> type.
Signal
<
dynamicgraph
::
Matrix
,
int
>
*
sigmat
=
dynamic_cast
<
Signal
<
dynamicgraph
::
Matrix
,
int
>*
>
(
signal
);
if
(
NULL
!=
sigmat
)
{
return
matrixToPython
(
sigmat
->
accessCopy
()
);
}
SignalPtr
<
dynamicgraph
::
Matrix
,
int
>
sigptr
(
NULL
,
"matrix-caster"
);
try
{
sigptr
.
plug
(
signal
);
return
matrixToPython
(
sigptr
.
accessCopy
()
);
}
catch
(
dynamicgraph
::
ExceptionSignal
&
ex
)
{
if
(
ex
.
getCode
()
!=
dynamicgraph
::
ExceptionSignal
::
PLUG_IMPOSSIBLE
)
throw
;
}
}
Signal
<
dynamicgraph
::
Matrix
,
int
>
*
sigmat
=
dynamic_cast
<
Signal
<
dynamicgraph
::
Matrix
,
int
>*
>
(
signal
);
if
(
NULL
!=
sigmat
)
{
return
matrixToPython
(
sigmat
->
accessCopy
()
);
}
Signal
<
double
,
int
>
*
sigdouble
=
dynamic_cast
<
Signal
<
double
,
int
>*
>
(
signal
);
...
...
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