@@ -160,49 +160,28 @@ def GetTrajectoryManipulators(self, traj):
160
160
161
161
def ExecutePath (self , path , simplify = True , smooth = True , defer = False ,
162
162
timeout = 1. , ** kwargs ):
163
- retimer = self .smoother if smooth else self .retimer
163
+ def do_execute (path , simplify , smooth , timeout , ** kwargs ):
164
+ if simplify :
165
+ path = self .simplifier .ShortcutPath (self , path , defer = False ,
166
+ timeout = timeout , ** kwargs )
164
167
165
- # TODO: Verify that the path is untimed.
168
+ retimer = self .smoother if smooth else self .retimer
169
+ timed_traj = retimer .RetimeTrajectory (self , path , defer = False , ** kwargs )
170
+ return self .ExecuteTrajectory (timed_traj , defer = False , ** kwargs )
166
171
167
172
if defer :
168
- from trollius import async , coroutine , From , Return , Task
169
173
from trollius .executor import get_default_executor
170
174
from trollius .futures import wrap_future
171
175
172
- @coroutine
173
- def do_execute (path , simplify , smooth , timeout , ** kwargs ):
174
- if simplify :
175
- print 'SIMPLYFING TRAJECTORY'
176
- path = yield From (
177
- self .simplifier .ShortcutPath (self , path , defer = True ,
178
- timeout = timeout , ** kwargs )
179
- )
180
-
181
- print 'TIMING TRAJECTORY'
182
- timed_traj = yield From (
183
- retimer .RetimeTrajectory (self , path , defer = True , ** kwargs )
184
- )
185
- print 'EXECUTING TRAJECTORY'
186
- executed_traj = yield From (
187
- self .ExecuteTrajectory (timed_traj , defer = True , ** kwargs )
188
- )
189
- raise Return (executed_traj )
190
-
191
- print 'RETURNING TASK'
192
-
193
176
executor = kwargs .get ('executor' , get_default_executor ())
194
- return do_execute (
195
- path , simplify = simplify , smooth = smooth , timeout = timeout ,
196
- ** kwargs
197
- )
177
+ return \
178
+ executor .submit (do_execute ,
179
+ path , simplify = simplify , smooth = smooth , timeout = timeout ,
180
+ ** kwargs
181
+ )
198
182
else :
199
- if simplify :
200
- path = self .simplifier .ShortcutPath (
201
- self , path , timeout = timeout , ** kwargs )
202
-
203
- traj = retimer .RetimeTrajectory (self , path , ** kwargs )
204
-
205
- return self .ExecuteTrajectory (traj , ** kwargs )
183
+ return do_execute (path , simplify = simplify , smooth = smooth ,
184
+ timeout = timeout , ** kwargs )
206
185
207
186
def ExecuteTrajectory (self , traj , defer = False , timeout = None , ** kw_args ):
208
187
# TODO: Verify that the trajectory is timed.
0 commit comments