@@ -184,14 +184,11 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
184
184
185
185
186
186
try :
187
- collision_error = None
188
187
while t < traj .GetDuration () + epsilon :
189
188
# Check for a timeout.
190
189
current_time = time .time ()
191
190
if (timelimit is not None and
192
191
current_time - start_time > timelimit ):
193
- if collision_error is not None :
194
- raise collision_error
195
192
raise TimeoutPlanningError (timelimit )
196
193
197
194
# Hypothesize new configuration as closest IK to current
@@ -203,34 +200,12 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
203
200
releasegil = True
204
201
)
205
202
206
- # FindIKSolutions is slower than FindIKSolution,
207
- # so call this only to identify error when there is no solution
208
- if qnew is None :
209
- ik_solutions = manip .FindIKSolutions (
210
- openravepy .matrixFromPose (traj .Sample (t + dt )[0 :7 ]),
211
- openravepy .IkFilterOptions .IgnoreSelfCollisions ,
212
- ikreturn = False ,
213
- releasegil = True
214
- )
215
-
216
- # update collision_error to contain collision info.
217
- with robot .CreateRobotStateSaver (p .LinkTransformation ):
218
- for q in ik_solutions :
219
- robot .SetActiveDOFValues (q )
220
- report = CollisionReport ()
221
- if self .env .CheckCollision (robot , report = report ):
222
- collision_error = CollisionPlanningError .FromReport (report )
223
- elif robot .CheckSelfCollision (report = report ):
224
- collision_error = SelfCollisionPlanningError .FromReport (report )
225
-
226
203
# Check if the step was within joint DOF resolution.
227
204
infeasible_step = True
228
205
if qnew is not None :
229
206
# Found an IK
230
207
step = abs (qnew - qcurr )
231
208
if (max (step ) < min_step ) and qtraj :
232
- if collision_error is not None :
233
- raise collision_error
234
209
raise PlanningError ('Not making progress.' )
235
210
infeasible_step = any (step > robot .GetActiveDOFResolutions ())
236
211
if infeasible_step :
@@ -254,7 +229,31 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
254
229
255
230
# Throw an error if we haven't reached the minimum waypoint.
256
231
if t < min_time :
257
- raise
232
+ # FindIKSolutions is slower than FindIKSolution,
233
+ # so call this only to identify error when there is no solution
234
+ ik_solutions = manip .FindIKSolutions (
235
+ openravepy .matrixFromPose (traj .Sample (t + dt * 2.0 )[0 :7 ]),
236
+ openravepy .IkFilterOptions .IgnoreSelfCollisions ,
237
+ ikreturn = False , releasegil = True
238
+ )
239
+
240
+ collision_error = None
241
+ # update collision_error to contain collision info.
242
+ with robot .CreateRobotStateSaver (p .LinkTransformation ):
243
+ for q in ik_solutions :
244
+ robot .SetActiveDOFValues (q )
245
+ report = CollisionReport ()
246
+ if self .env .CheckCollision (robot , report = report ):
247
+ collision_error = CollisionPlanningError .FromReport (report )
248
+ elif robot .CheckSelfCollision (report = report ):
249
+ collision_error = SelfCollisionPlanningError .FromReport (report )
250
+ else :
251
+ collision_error = None
252
+ if collision_error is not None :
253
+ raise collision_error
254
+ else :
255
+ raise
256
+
258
257
# Otherwise we'll gracefully terminate.
259
258
else :
260
259
logger .warning ('Terminated early at time %f < %f: %s' ,
0 commit comments