Skip to content
GitLab
Menu
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
a05e1f98
Commit
a05e1f98
authored
Jun 30, 2020
by
Joseph Mirabel
Browse files
Update Python signal wrapper.
parent
49916ff3
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/python/signal-wrapper.hh
View file @
a05e1f98
...
...
@@ -18,7 +18,7 @@ class PythonSignalContainer : public Entity {
DYNAMIC_GRAPH_ENTITY_DECL
();
public:
PythonSignalContainer
(
const
std
::
string
&
name
)
;
using
Entity
::
Entity
;
void
signalRegistration
(
const
SignalArray
<
int
>&
signals
);
...
...
src/dynamic_graph/dynamic-graph-py.cc
View file @
a05e1f98
...
...
@@ -17,6 +17,7 @@
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/command.h>
#include <dynamic-graph/factory.h>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/tracer.h>
...
...
@@ -24,6 +25,7 @@
#include "dynamic-graph/python/dynamic-graph-py.hh"
#include "dynamic-graph/python/signal-wrapper.hh"
#include "dynamic-graph/python/convert-dg-to-py.hh"
#include "dynamic-graph/python/module.hh"
namespace
dynamicgraph
{
namespace
python
{
...
...
@@ -69,6 +71,24 @@ dg::SignalBase<int>* getSignal(dg::Entity& e, const std::string& name) {
return
&
e
.
getSignal
(
name
);
}
class
PythonEntity
:
public
dg
::
Entity
{
DYNAMIC_GRAPH_ENTITY_DECL
();
public:
using
dg
::
Entity
::
Entity
;
void
signalRegistration
(
dg
::
SignalBase
<
int
>
&
signal
)
{
dg
::
Entity
::
signalRegistration
(
signal
);
}
void
signalDeregistration
(
const
std
::
string
&
name
)
{
dg
::
Entity
::
signalDeregistration
(
name
);
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
PythonEntity
,
"PythonEntity"
);
void
exposeEntityBase
()
{
using
namespace
dynamicgraph
;
...
...
@@ -175,6 +195,16 @@ void exposeEntityBase()
// For backward compat
.
add_static_property
(
"entities"
,
bp
::
make_function
(
&
getEntityMap
,
reference_existing_object
()))
;
python
::
exposeEntity
<
PythonEntity
,
bp
::
bases
<
Entity
>
,
0
>
()
.
def
(
"signalRegistration"
,
&
PythonEntity
::
signalRegistration
)
.
def
(
"signalDeregistration"
,
&
PythonEntity
::
signalDeregistration
)
;
python
::
exposeEntity
<
python
::
PythonSignalContainer
,
bp
::
bases
<
Entity
>
,
0
>
()
.
def
(
"rmSignal"
,
&
python
::
PythonSignalContainer
::
rmSignal
,
"Remove a signal"
,
bp
::
arg
(
"signal_name"
))
;
}
void
exposeCommand
()
...
...
src/dynamic_graph/signal-base-py.cc
View file @
a05e1f98
...
...
@@ -17,6 +17,7 @@
#include "dynamic-graph/python/dynamic-graph-py.hh"
#include "dynamic-graph/python/convert-dg-to-py.hh"
#include "dynamic-graph/python/signal-wrapper.hh"
#include "dynamic-graph/python/module.hh"
using
dynamicgraph
::
SignalBase
;
...
...
@@ -111,6 +112,13 @@ template<> auto exposeSignal<MatrixHomogeneous, time_type> (const std::string& n
return
obj
;
}
template
<
typename
T
,
typename
Time
>
auto
exposeSignalWrapper
(
const
std
::
string
&
name
)
{
typedef
SignalWrapper
<
T
,
Time
>
S_t
;
bp
::
class_
<
S_t
,
bp
::
bases
<
Signal
<
T
,
Time
>
>
,
boost
::
noncopyable
>
obj
(
name
.
c_str
(),
bp
::
no_init
);
return
obj
;
}
template
<
typename
T
,
typename
Time
>
auto
exposeSignalPtr
(
const
std
::
string
&
name
)
{
typedef
SignalPtr
<
T
,
Time
>
S_t
;
...
...
@@ -133,6 +141,7 @@ void exposeSignalsOfType(const std::string& name)
{
exposeSignal
<
T
,
Time
>
(
"Signal"
+
name
);
exposeSignalPtr
<
T
,
Time
>
(
"SignalPtr"
+
name
);
exposeSignalWrapper
<
T
,
Time
>
(
"SignalWrapper"
+
name
);
exposeSignalTimeDependent
<
T
,
Time
>
(
"SignalTimeDependent"
+
name
);
}
...
...
src/dynamic_graph/signal-wrapper.cc
View file @
a05e1f98
...
...
@@ -8,19 +8,6 @@
namespace
dynamicgraph
{
namespace
python
{
PythonSignalContainer
::
PythonSignalContainer
(
const
std
::
string
&
name
)
:
Entity
(
name
)
{
std
::
string
docstring
;
docstring
=
"
\n
"
" Remove a signal
\n
"
"
\n
"
" Input:
\n
"
" - name of the signal
\n
"
"
\n
"
;
addCommand
(
"rmSignal"
,
command
::
makeCommandVoid1
(
*
this
,
&
PythonSignalContainer
::
rmSignal
,
docstring
));
}
void
PythonSignalContainer
::
signalRegistration
(
const
SignalArray
<
int
>&
signals
)
{
Entity
::
signalRegistration
(
signals
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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