-
Notifications
You must be signed in to change notification settings - Fork 4
/
localisationtest.py
47 lines (37 loc) · 1.44 KB
/
localisationtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
import unittest
from localisation import *
class ScoreTest( unittest.TestCase ):
def assertEqualPose( self, p, q, places=6 ):
self.assertAlmostEqual( p[0], q[0], places )
self.assertAlmostEqual( p[1], q[1], places )
self.assertAlmostEqual( p[2], q[2], places )
def setUp( self ):
pass
def testKalmanFilter( self ):
loc = KalmanFilter()
self.assertEqualPose( loc.pose(), (0,0,0) )
loc.setPxPa( 1.0, 0.0 )
self.assertEqualPose( loc.pose(), (1.0,0,0) )
loc.updateCompass( 0 ) # North
self.assertEqualPose( loc.pose(), (1.0,0,math.pi/2) )
loc.updateCompass( 900 ) # East
self.assertEqualPose( loc.pose(), (1.0,0,math.pi/4) ) # NW (average)
loc.setPxPa( 0.0, -math.pi/4 )
self.assertEqualPose( loc.pose(), (1.0,0,0) )
loc.updateCompass( 900 ) # East
self.assertEqualPose( loc.pose(), (1.0,0,0) )
loc.updateGPS( (123,456,9,1.1) )
self.assertEqualPose( loc.pose(), (123.0,456.0,0) )
loc.updateGPS( (125,458,9,1.1) )
self.assertEqualPose( loc.pose(), (124.0,457.0,0) )
def testSimplePositiveRoute( self ):
return
s = (16.606789, 49.204815) # I seg
f = (16.607101, 49.205705) # Z seg
self.assert_( score( self.route, s, f ) > 0 )
self.assertAlmostEqual( 10.17, score( self.route, s, f), 1 )
self.assert_( score( self.route, f, s ) > 0 )
self.assertAlmostEqual( 80.46, score( self.route, f, s), 1 )
if __name__ == "__main__":
unittest.main()