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
4c6a4178
Commit
4c6a4178
authored
Oct 02, 2019
by
Guilhem Saurel
Browse files
[Python 3] fix imports
parent
36a361e9
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/dynamic_graph/__init__.py
View file @
4c6a4178
...
...
@@ -5,15 +5,22 @@ Author: Florent Lamiraux
import
sys
import
DLFCN
import
entity
# noqa
import
signal_base
# noqa
from
.
import
entity
# noqa
from
.
import
signal_base
# noqa
try
:
from
DLFCN
import
RTLD_NOW
,
RTLD_GLOBAL
except
ModuleNotFoundError
:
# Python 3
from
os
import
RTLD_NOW
,
RTLD_GLOBAL
flags
=
sys
.
getdlopenflags
()
# Import C++ symbols in a global scope
# This is necessary for signal compiled in different modules to be compatible
flags
=
sys
.
getdlopenflags
()
sys
.
setdlopenflags
(
DLFCN
.
RTLD_NOW
|
DLFCN
.
RTLD_GLOBAL
)
from
wrap
import
*
# noqa
sys
.
setdlopenflags
(
RTLD_NOW
|
RTLD_GLOBAL
)
from
.wrap
import
*
# noqa
# Recover previous flags
sys
.
setdlopenflags
(
flags
)
...
...
src/dynamic_graph/entity.py
View file @
4c6a4178
...
...
@@ -3,12 +3,11 @@
Author: Florent Lamiraux, Nicolas Mansard
"""
import
new
import
types
from
enum
import
Enum
import
signal_base
import
wrap
from
attrpath
import
setattrpath
from
.
import
signal_base
,
wrap
from
.attrpath
import
setattrpath
if
'display'
not
in
globals
().
keys
():
...
...
@@ -248,7 +247,7 @@ class Entity(object):
docstring
=
wrap
.
entity_get_command_docstring
(
self
.
obj
,
cmdName
)
cmd
=
Entity
.
createCommandBind
(
cmdName
,
docstring
)
# Limitation (todo): does not handle for path attribute name (see setattrpath).
setattr
(
self
,
cmdName
,
new
.
instancem
ethod
(
cmd
,
self
,
self
.
__class__
))
setattr
(
self
,
cmdName
,
types
.
M
ethod
Type
(
cmd
,
self
))
def
boundAllNewCommands
(
self
):
"""
...
...
src/dynamic_graph/script_shortcuts.py
View file @
4c6a4178
...
...
@@ -11,9 +11,9 @@
# Changing prompt
import
sys
from
dynamic_graph
.entity
import
Entity
from
dynamic_graph.signal_base
import
SignalBase
from
matlab
import
matlab
from
.entity
import
Entity
from
.matlab
import
matlab
from
.signal_base
import
SignalBase
# Enables shortcut "name"
...
...
src/dynamic_graph/signal_base.py
View file @
4c6a4178
...
...
@@ -5,8 +5,10 @@
"""
import
re
import
entity
import
wrap
from
.wrap
import
(
create_signal_wrapper
,
signal_base_display
,
signal_base_display_dependencies
,
signal_base_get_class_name
,
signal_base_get_name
,
signal_base_get_time
,
signal_base_get_value
,
signal_base_getPlugged
,
signal_base_isPlugged
,
signal_base_recompute
,
signal_base_set_time
,
signal_base_set_value
,
signal_base_unplug
)
def
stringToTuple
(
vector
):
...
...
@@ -110,7 +112,7 @@ def objectToString(obj):
else
:
# vector
return
tupleToString
(
obj
)
elif
isinstance
(
obj
,
entity
.
Entity
):
elif
hasattr
(
obj
,
'name'
):
return
obj
.
name
else
:
return
str
(
obj
)
...
...
@@ -176,7 +178,7 @@ class SignalBase(object):
"""
Get time of signal
"""
return
wrap
.
signal_base_get_time
(
self
.
obj
)
return
signal_base_get_time
(
self
.
obj
)
@
time
.
setter
def
time
(
self
,
val
):
...
...
@@ -186,7 +188,7 @@ class SignalBase(object):
Input:
- an integer
"""
return
wrap
.
signal_base_set_time
(
self
.
obj
,
val
)
return
signal_base_set_time
(
self
.
obj
,
val
)
@
property
def
value
(
self
):
...
...
@@ -210,7 +212,7 @@ class SignalBase(object):
>>> s.value
(2.5, 0.1, 100.0)
"""
string
=
wrap
.
signal_base_get_value
(
self
.
obj
)
string
=
signal_base_get_value
(
self
.
obj
)
return
stringToObject
(
string
)
@
value
.
setter
...
...
@@ -220,64 +222,64 @@ class SignalBase(object):
If the signal is plugged, it will be unplugged
"""
string
=
objectToString
(
val
)
return
wrap
.
signal_base_set_value
(
self
.
obj
,
string
)
return
signal_base_set_value
(
self
.
obj
,
string
)
def
getName
(
self
):
"""
Get name of signal
"""
return
wrap
.
signal_base_get_name
(
self
.
obj
)
return
signal_base_get_name
(
self
.
obj
)
@
property
def
name
(
self
):
"""
Get name of signal
"""
return
wrap
.
signal_base_get_name
(
self
.
obj
)
return
signal_base_get_name
(
self
.
obj
)
def
getClassName
(
self
):
"""
Get class name of signal
"""
return
wrap
.
signal_base_get_class_name
(
self
.
obj
)
return
signal_base_get_class_name
(
self
.
obj
)
def
recompute
(
self
,
time
):
"""
Force signal to recompute the value at given time.
"""
return
wrap
.
signal_base_recompute
(
self
.
obj
,
time
)
return
signal_base_recompute
(
self
.
obj
,
time
)
def
unplug
(
self
):
"""
Unplug a PTR signal.
"""
return
wrap
.
signal_base_unplug
(
self
.
obj
)
return
signal_base_unplug
(
self
.
obj
)
def
isPlugged
(
self
):
"""
Return whether a signal is plugged.
"""
return
wrap
.
signal_base_isPlugged
(
self
.
obj
)
return
signal_base_isPlugged
(
self
.
obj
)
def
getPlugged
(
self
):
"""
Return the plugged signal.
"""
return
SignalBase
(
obj
=
wrap
.
signal_base_getPlugged
(
self
.
obj
))
return
SignalBase
(
obj
=
signal_base_getPlugged
(
self
.
obj
))
def
__str__
(
self
):
"""
Print signal in a string
"""
return
wrap
.
signal_base_display
(
self
.
obj
)
return
signal_base_display
(
self
.
obj
)
def
displayDependencies
(
self
,
iter
):
"""
Print signal dependencies in a string
"""
return
(
wrap
.
signal_base_display_dependencies
(
self
.
obj
,
iter
))
return
(
signal_base_display_dependencies
(
self
.
obj
,
iter
))
class
SignalWrapper
(
SignalBase
):
def
__init__
(
self
,
name
,
type
,
func
):
super
(
SignalWrapper
,
self
).
__init__
(
name
,
wrap
.
create_signal_wrapper
(
name
,
type
,
func
))
super
(
SignalWrapper
,
self
).
__init__
(
name
,
create_signal_wrapper
(
name
,
type
,
func
))
src/dynamic_graph/tools.py
View file @
4c6a4178
# -*- coding: utf-8 -*-
# Copyright 2011, Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST
from
__future__
import
print_function
def
addTrace
(
robot
,
trace
,
entityName
,
signalName
,
autoRecompute
=
True
):
"""
...
...
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