Skip to content

Commit 00b803d

Browse files
committed
Better scoping of env usage.
1 parent 4c47ca0 commit 00b803d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/prpy/base/robot.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ def __init__(self, robot_name=None):
8080
self.smoother = self.retimer
8181
self.affine_retimer = OpenRAVEAffineRetimer()
8282

83-
# Since we don't want to endlessly create postprocessing environments,
84-
# we maintain a map that uniquely associates each OpenRAVE environment
85-
# with a given postprocessing environment. This way, if we re-clone
86-
# into a previously used environment, we will not create a new one.
87-
self._postprocess_env = Robot._postprocess_envs[
88-
openravepy.RaveGetEnvironmentId(self.GetEnv())]
89-
9083
def __dir__(self):
9184
# We have to manually perform a lookup in InstanceDeduplicator because
9285
# __methods__ bypass __getattribute__.
@@ -300,8 +293,15 @@ def PostProcessPath(self, path,
300293
logger.debug('Detected "%s" tag on trajectory: Setting smooth'
301294
' = True', Tags.SMOOTH)
302295

296+
# Since we don't want to endlessly create postprocessing environments,
297+
# we maintain a map that uniquely associates each OpenRAVE environment
298+
# with a given postprocessing environment. This way, if we re-clone
299+
# into a previously used environment, we will not create a new one.
300+
postprocess_env = Robot._postprocess_envs[
301+
openravepy.RaveGetEnvironmentId(self.GetEnv())]
302+
303303
with Clone(self.GetEnv(),
304-
clone_env=self._postprocess_env) as cloned_env:
304+
clone_env=postprocess_env) as cloned_env:
305305
cloned_robot = cloned_env.Cloned(self)
306306

307307
# Planners only operate on the active DOFs. We'll set any DOFs

0 commit comments

Comments
 (0)