Skip to content

Commit 841d5c6

Browse files
committed
Lazy load V-REP remoteApi library
1 parent 2f725a5 commit 841d5c6

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
from compas.geometry import matrix_from_frame
55

66
from compas_fab.backends.exceptions import BackendError
7-
from compas_fab.backends.vrep.remote_api import vrep
8-
97
from compas_fab.robots import Configuration
108

119
__all__ = [
1210
'VrepError',
1311
]
1412

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

1715
# --------------------------------------------------------------------------
1816
# MAPPINGS

0 commit comments

Comments
 (0)