Skip to content

Commit 50f9a0f

Browse files
authored
Merge pull request #292 from compas-dev/lazyload-vrep
Lazy-load V-REP remote API library
2 parents c803015 + 2373903 commit 50f9a0f

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Unreleased
1818
**Changed**
1919

2020
* The `Configuration` class has moved to `compas.robots`, but is still aliased within `compas_fab.robots`
21+
* Lazily load `V-REP remoteApi` library
2122

2223
**Fixed**
2324

src/compas_fab/backends/vrep/backend_features/vrep_add_attached_collision_mesh.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
from compas_fab.backends.vrep.helpers import assert_robot
5+
from compas_fab.backends.interfaces import AddAttachedCollisionMesh
66
from compas_fab.backends.vrep.helpers import DEFAULT_OP_MODE
77
from compas_fab.backends.vrep.helpers import VrepError
8-
from compas_fab.backends.interfaces import AddAttachedCollisionMesh
9-
from compas_fab.backends.vrep.remote_api import vrep
8+
from compas_fab.backends.vrep.helpers import assert_robot
9+
from compas_fab.utilities import LazyLoader
1010

1111
__all__ = [
1212
'VrepAddAttachedCollisionMesh',
1313
]
1414

15+
vrep = LazyLoader('vrep', globals(), 'compas_fab.backends.vrep.remote_api.vrep')
16+
1517

1618
class VrepAddAttachedCollisionMesh(AddAttachedCollisionMesh):
1719
"""Callable to add a building member to the 3D scene and attach it to the robot.

src/compas_fab/backends/vrep/backend_features/vrep_remove_collision_mesh.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
from compas_fab.backends.vrep.helpers import DEFAULT_OP_MODE
6-
from compas_fab.backends.vrep.remote_api import vrep
75
from compas_fab.backends.interfaces import RemoveCollisionMesh
8-
6+
from compas_fab.backends.vrep.helpers import DEFAULT_OP_MODE
7+
from compas_fab.utilities import LazyLoader
98

109
__all__ = [
1110
'VrepRemoveCollisionMesh',
1211
]
1312

13+
vrep = LazyLoader('vrep', globals(), 'compas_fab.backends.vrep.remote_api.vrep')
14+
1415

1516
class VrepRemoveCollisionMesh(RemoveCollisionMesh):
1617
"""Callable to remove collision meshes from the 3D scene.

src/compas_fab/backends/vrep/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
import logging
44

5-
from compas_fab.backends.vrep.helpers import DEFAULT_OP_MODE
65
from compas_fab.backends.interfaces.client import ClientInterface
76
from compas_fab.backends.vrep import VrepError
7+
from compas_fab.backends.vrep.helpers import DEFAULT_OP_MODE
88
from compas_fab.backends.vrep.helpers import assert_robot
99
from compas_fab.backends.vrep.helpers import config_from_vrep
1010
from compas_fab.backends.vrep.helpers import config_to_vrep
1111
from compas_fab.backends.vrep.helpers import floats_from_vrep
1212
from compas_fab.backends.vrep.helpers import floats_to_vrep
1313
from compas_fab.backends.vrep.helpers import resolve_host
1414
from compas_fab.backends.vrep.planner import VrepPlanner
15-
from compas_fab.backends.vrep.remote_api import vrep
15+
from compas_fab.utilities import LazyLoader
1616

1717
DEFAULT_SCALE = 1.
18-
CHILD_SCRIPT_TYPE = vrep.sim_scripttype_childscript
18+
CHILD_SCRIPT_TYPE = 1 # defined in vrepConst.sim_scripttype_childscript, but redefined here to prevent loading the remoteApi library
1919
LOG = logging.getLogger('compas_fab.backends.vrep.client')
2020

21+
vrep = LazyLoader('vrep', globals(), 'compas_fab.backends.vrep.remote_api.vrep')
22+
2123
__all__ = [
2224
'VrepClient',
2325
]

src/compas_fab/backends/vrep/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
from compas.robots import Configuration
66

77
from compas_fab.backends.exceptions import BackendError
8-
from compas_fab.backends.vrep.remote_api import vrep
98

109

1110
__all__ = [
1211
'VrepError',
1312
]
1413

15-
DEFAULT_OP_MODE = vrep.simx_opmode_blocking
14+
DEFAULT_OP_MODE = 0x010000 # defined in vrepConst.simx_opmode_blocking, but redefined here to prevent loading the remoteApi library
1615

1716
# --------------------------------------------------------------------------
1817
# MAPPINGS

0 commit comments

Comments
 (0)