@@ -250,10 +250,12 @@ def test_GetLinearCollisionCheckPts_SinglePointTraj(self):
250
250
q0 = [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ]
251
251
desired_num_checks = 1
252
252
traj = self .CreateTrajectory (q0 , q0 ) # makes traj with 1 waypoint
253
+ # Linear sampling
254
+ linear = prpy .util .SampleTimeGenerator
253
255
checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
254
256
traj , \
255
257
norm_order = 2 , \
256
- sampling_order = ' linear' )
258
+ sampling_func = linear )
257
259
num_checks = sum (1 for x in checks )
258
260
if num_checks != desired_num_checks :
259
261
error = str (num_checks ) + ' is the wrong number of check pts.'
@@ -270,10 +272,12 @@ def test_GetLinearCollisionCheckPts_TwoPointTraj_LessThanDOFRes(self):
270
272
q1 = 0.5 * self .dof_resolutions
271
273
desired_num_checks = 2
272
274
traj = self .CreateTrajectory (q0 , q1 )
275
+ # Linear sampling
276
+ linear = prpy .util .SampleTimeGenerator
273
277
checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
274
278
traj , \
275
279
norm_order = 2 , \
276
- sampling_order = ' linear' )
280
+ sampling_func = linear )
277
281
num_checks = 0
278
282
for t , q in checks :
279
283
num_checks = num_checks + 1
@@ -301,10 +305,12 @@ def test_GetLinearCollisionCheckPts_TwoPointTraj_EqualToDOFRes(self):
301
305
q1 = 1.0 * self .dof_resolutions
302
306
desired_num_checks = 2
303
307
traj = self .CreateTrajectory (q0 , q1 )
308
+ # Linear sampling
309
+ linear = prpy .util .SampleTimeGenerator
304
310
checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
305
311
traj , \
306
312
norm_order = 2 , \
307
- sampling_order = ' linear' )
313
+ sampling_func = linear )
308
314
num_checks = 0
309
315
for t , q in checks :
310
316
num_checks = num_checks + 1
@@ -325,10 +331,12 @@ def test_GetLinearCollisionCheckPts_TwoPointTraj_GreaterThanDOFRes(self):
325
331
q1 = 1.2 * self .dof_resolutions
326
332
desired_num_checks = 3
327
333
traj = self .CreateTrajectory (q0 , q1 )
334
+ # Linear sampling
335
+ linear = prpy .util .SampleTimeGenerator
328
336
checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
329
337
traj , \
330
338
norm_order = 2 , \
331
- sampling_order = ' linear' )
339
+ sampling_func = linear )
332
340
num_checks = 0
333
341
for t , q in checks :
334
342
num_checks = num_checks + 1
@@ -349,60 +357,43 @@ def test_GetLinearCollisionCheckPts_SamplingOrderMethods(self):
349
357
q1 = [0.01 , 0.02 , 0.03 , 0.04 , 0.03 , 0.02 , 0.01 ]
350
358
traj = self .CreateTrajectory (q0 , q1 )
351
359
352
- # Linear
353
- method = 'linear'
360
+ # Linear sampling
361
+ linear = prpy . util . SampleTimeGenerator
354
362
checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
355
363
traj , \
356
364
norm_order = 2 , \
357
- sampling_order = method )
365
+ sampling_func = linear )
358
366
try :
359
367
# Exception can be thrown only when we try to use the generator
360
368
num_checks = sum (1 for x in checks )
361
369
except ValueError :
362
- error = "Unknown sampling_order method : '" + method + "' "
370
+ error = "Unknown sampling_func : '" + method + "' "
363
371
self .fail (error )
364
372
except Exception , e :
365
373
error = 'Unexpected exception thrown: ' + str (e .message )
366
374
self .fail (error )
367
375
else :
368
376
pass # test passed
369
377
370
- # Van der Corput
371
- method = 'van_der_corput'
378
+ # An approximate Van der Corput sequence, between the
379
+ # start and end points
380
+ vdc = prpy .util .VanDerCorputSampleGenerator
372
381
checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
373
382
traj , \
374
383
norm_order = 2 , \
375
- sampling_order = method )
384
+ sampling_func = vdc )
376
385
try :
377
386
# Exception can be thrown only when we try to use the generator
378
387
num_checks = sum (1 for x in checks )
379
388
except ValueError :
380
- error = "Unknown sampling_order method : '" + method + "' "
389
+ error = "Unknown sampling_func : '" + method + "' "
381
390
self .fail (error )
382
391
except Exception , e :
383
392
error = 'Unexpected exception thrown: ' + str (e .message )
384
393
self .fail (error )
385
394
else :
386
395
pass # test passed
387
396
388
- # unknown method
389
- method = 'garbage'
390
- checks = prpy .util .GetLinearCollisionCheckPts (self .robot , \
391
- traj , \
392
- norm_order = 2 , \
393
- sampling_order = method )
394
- try :
395
- # Exception can be thrown only when we try to use the generator
396
- num_checks = sum (1 for x in checks )
397
- except ValueError :
398
- pass # test passed, an exception was thrown
399
-
400
- except Exception , e :
401
- error = 'Unexpected exception thrown: ' + str (e .message )
402
- self .fail (error )
403
- else :
404
- self .fail ('Expected exception not thrown' )
405
-
406
397
407
398
# ConvertIntToBinaryString()
408
399
@@ -501,7 +492,7 @@ def test_VanDerCorputSampleGenerator_ExcessLessThanHalfStep(self):
501
492
verbose = True )
502
493
503
494
def test_VanDerCorputSampleGenerator_ExcessEqualToHalfStep (self ):
504
- # Check that the end-point is NOT included when it's distance
495
+ # Check that the end-point is NOT included when it's distance
505
496
# is EQUAL too (or less than) the step-size.
506
497
expected_sequence = [0.0 , 12.0 , 6.0 , 4.0 , 8.0 , 2.0 , 10.0 ]
507
498
traj_dur = 13.0
0 commit comments