@@ -181,7 +181,10 @@ def GetTrajectoryManipulators(self, traj):
181
181
182
182
return active_manipulators
183
183
184
- def PostProcessPath (self , path , defer = False , executor = None , ** kwargs ):
184
+ def PostProcessPath (self , path , defer = False , executor = None ,
185
+ constrained = None , smooth = None , default_timelimit = 0.5 ,
186
+ shortcut_options = None , smoothing_options = None ,
187
+ retiming_options = None ):
185
188
""" Post-process a geometric path to prepare it for execution.
186
189
187
190
This method post-processes a geometric path by (optionally) optimizing
@@ -218,38 +221,35 @@ def PostProcessPath(self, path, defer=False, executor=None, **kwargs):
218
221
@param retiming_options kwargs to RetimeTrajectory for timing
219
222
@return trajectory ready for execution
220
223
"""
221
-
222
- def do_postprocess (path , constrained = None , smooth = None ,
223
- default_timelimit = 0.5 , shortcut_options = None ,
224
- smoothing_options = None , retiming_options = None ):
225
- from ..planning .base import Tags
226
- from ..util import GetTrajectoryTags , CopyTrajectory
227
-
228
- # Default parameters.
229
- if shortcut_options is None :
230
- shortcut_options = dict ()
231
- if smoothing_options is None :
232
- smoothing_options = dict ()
233
- if retiming_options is None :
234
- retiming_options = dict ()
235
-
236
- shortcut_options .setdefault ('timelimit' , default_timelimit )
237
- smoothing_options .setdefault ('timelimit' , default_timelimit )
238
- retiming_options .setdefault ('timelimit' , default_timelimit )
239
-
240
- # Read default parameters from the trajectory's tags.
241
- tags = GetTrajectoryTags (path )
242
-
243
- if constrained is None :
244
- constrained = tags .get (Tags .CONSTRAINED , False )
245
- logger .debug ('Detected "%s" tag on trajectory: Setting'
246
- ' constrained = True.' , Tags .CONSTRAINED )
247
-
248
- if smooth is None :
249
- smooth = tags .get (Tags .SMOOTH , False )
250
- logger .debug ('Detected "%s" tag on trajectory: Setting smooth'
251
- ' = True' , Tags .SMOOTH )
252
-
224
+ from ..planning .base import Tags
225
+ from ..util import GetTrajectoryTags , CopyTrajectory
226
+
227
+ # Default parameters.
228
+ if shortcut_options is None :
229
+ shortcut_options = dict ()
230
+ if smoothing_options is None :
231
+ smoothing_options = dict ()
232
+ if retiming_options is None :
233
+ retiming_options = dict ()
234
+
235
+ shortcut_options .setdefault ('timelimit' , default_timelimit )
236
+ smoothing_options .setdefault ('timelimit' , default_timelimit )
237
+ retiming_options .setdefault ('timelimit' , default_timelimit )
238
+
239
+ # Read default parameters from the trajectory's tags.
240
+ tags = GetTrajectoryTags (path )
241
+
242
+ if constrained is None :
243
+ constrained = tags .get (Tags .CONSTRAINED , False )
244
+ logger .debug ('Detected "%s" tag on trajectory: Setting'
245
+ ' constrained = True.' , Tags .CONSTRAINED )
246
+
247
+ if smooth is None :
248
+ smooth = tags .get (Tags .SMOOTH , False )
249
+ logger .debug ('Detected "%s" tag on trajectory: Setting smooth'
250
+ ' = True' , Tags .SMOOTH )
251
+
252
+ def do_postprocess ():
253
253
with Clone (self .GetEnv ()) as cloned_env :
254
254
cloned_robot = cloned_env .Cloned (self )
255
255
@@ -288,12 +288,13 @@ def do_postprocess(path, constrained=None, smooth=None,
288
288
# The trajectory is not constrained, so we can shortcut it
289
289
# before execution.
290
290
logger .debug ('Shortcutting an unconstrained path.' )
291
- path = self .simplifier .ShortcutPath (
291
+ shortcut_path = self .simplifier .ShortcutPath (
292
292
cloned_robot , path , defer = False , ** shortcut_options )
293
293
294
294
logger .debug ('Smoothing an unconstrained path.' )
295
295
traj = self .smoother .RetimeTrajectory (
296
- cloned_robot , path , defer = False , ** smoothing_options )
296
+ cloned_robot , shortcut_path , defer = False ,
297
+ ** smoothing_options )
297
298
298
299
return CopyTrajectory (traj , env = self .GetEnv ())
299
300
@@ -304,9 +305,9 @@ def do_postprocess(path, constrained=None, smooth=None,
304
305
if executor is None :
305
306
executor = get_default_executor ()
306
307
307
- return wrap_future (executor .submit (do_postprocess , path , ** kwargs ))
308
+ return wrap_future (executor .submit (do_postprocess ))
308
309
else :
309
- return do_postprocess (path , ** kwargs )
310
+ return do_postprocess ()
310
311
311
312
def ExecutePath (self , path , simplify = True , smooth = True , defer = False ,
312
313
timeout = 1. , ** kwargs ):
0 commit comments