Skip to content

Commit fe8f675

Browse files
committed
Adding logic to clone the environment eshen simplifying and smoothing a path. This allows us to set the dofs in the trajectory as active.
1 parent 68df42c commit fe8f675

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/prpy/base/robot.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,27 @@ def GetTrajectoryManipulators(self, traj):
160160

161161
def ExecutePath(self, path, simplify=True, smooth=True, defer=False,
162162
timeout=1., **kwargs):
163+
164+
logger.debug('Begin ExecutePath')
165+
163166
def do_execute(path, simplify, smooth, timeout, **kwargs):
164-
if simplify:
165-
path = self.simplifier.ShortcutPath(self, path, defer=False,
166-
timeout=timeout, **kwargs)
167167

168-
retimer = self.smoother if smooth else self.retimer
169-
timed_traj = retimer.RetimeTrajectory(self, path, defer=False, **kwargs)
168+
with Clone(self.GetEnv()) as cloned_env:
169+
traj_dofs = prpy.util.GetTrajectoryIndices(path)
170+
cloned_env.Cloned(self).SetActiveDOFs(traj_dofs)
171+
cloned_robot = cloned_env.Cloned(self)
172+
173+
if simplify:
174+
path = self.simplifier.ShortcutPath(cloned_robot, path, defer=False,
175+
timeout=timeout, **kwargs)
176+
177+
retimer = self.smoother if smooth else self.retimer
178+
cloned_timed_traj = retimer.RetimeTrajectory(cloned_robot, path, defer=False, **kwargs)
179+
180+
# Copy the trajectory back to the original environment.
181+
from ..util import CopyTrajectory
182+
timed_traj = CopyTrajectory(cloned_timed_traj, env=self.GetEnv())
183+
170184
return self.ExecuteTrajectory(timed_traj, defer=False, **kwargs)
171185

172186
if defer:
@@ -188,6 +202,7 @@ def ExecuteTrajectory(self, traj, defer=False, timeout=None, period=0.01, **kw_a
188202
# TODO: Verify that the trajectory is timed.
189203
# TODO: Check if this trajectory contains the base.
190204

205+
logger.debug('Begin ExecuteTrajectory')
191206
needs_base = False
192207

193208
self.GetController().SetPath(traj)
@@ -223,7 +238,9 @@ def do_poll():
223238

224239
return trollius.async(do_poll())
225240
else:
226-
util.WaitForControllers(active_controllers, timeout=timeout)
241+
import prpy.viz
242+
with prpy.viz.RenderTrajectory(self, traj):
243+
util.WaitForControllers(active_controllers, timeout=timeout)
227244

228245
return traj
229246

0 commit comments

Comments
 (0)