~mrol-dev/mrol/trunk

« back to all changes in this revision

Viewing changes to test/mapper_test.py

  • Committer: Julian Ryde
  • Date: 2012-03-04 17:10:07 UTC
  • mto: (16.1.12 trunk) (29.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: julian_ryde-20120304171007-hfbttvxk2nhmqoad
Changed some functions to take pose objects rather than pose tuples.  Tidied up cost_min so it considers quantised pose steps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
import depth_image
16
16
import unittest
17
17
 
18
 
visualise = True
 
18
visualise = False
19
19
testdir = os.path.dirname(__file__)
20
20
if testdir == '':
21
21
    testdir = '.'
227
227
        angular_tol = np.radians(2)
228
228
        position_tol = 0.05
229
229
        assert bestpose.is_close(truepose, position_tol, angular_tol), 'Pose is not close enough to true pose'
230
 
        
231
230
 
232
 
def _run_mapping():
 
231
def _run_mapping(scans):
233
232
    tm = TestMapper()
234
 
    vmap = tm._map_build(16)
 
233
    vmap = tm._map_build(scans)
 
234
    return vmap
235
235
 
236
236
if __name__ == '__main__':
237
237
    # run for profiling
238
 
    import cProfile
239
 
    import pstats
 
238
    profile = False
 
239
    if profile:
 
240
        import cProfile
 
241
        import pstats
 
242
        results_fname = '/tmp/mapper_test.profile'
240
243
    start = time.time()
241
 
    stmt = '_run_mapping()'
242
 
    results_fname = '/tmp/mapper_test.profile'
243
 
    cProfile.run(stmt, results_fname)
 
244
    if profile:
 
245
        stmt = '_run_mapping(16)'
 
246
        cProfile.run(stmt, results_fname)
 
247
    else:
 
248
        vmap = _run_mapping(3) # fail fast if there is a serious problem
 
249
        vmap = _run_mapping(16)
244
250
    taken = time.time() - start
245
251
    print 'Execution time: %.2fs' % taken
246
252
 
247
 
    # now show the results
248
 
    P = pstats.Stats(results_fname)
249
 
    
250
 
    P.sort_stats('cumulative').print_stats(15)
251
 
    print
252
 
    P.sort_stats('time').print_stats(15)
 
253
    if profile:
 
254
        # now show the results
 
255
        P = pstats.Stats(results_fname)
 
256
        
 
257
        P.sort_stats('cumulative').print_stats(15)
 
258
        print
 
259
        P.sort_stats('time').print_stats(15)