-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdriver_test.py
More file actions
35 lines (25 loc) · 1.06 KB
/
driver_test.py
File metadata and controls
35 lines (25 loc) · 1.06 KB
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
#!/usr/bin/python
from mock import MagicMock
import math
import unittest
from driver import Driver
class DriverTest(unittest.TestCase):
def test_followLineG( self ):
robot = MagicMock()
robot.localisation.pose.return_value = (0, 0.3, 0)
driver = Driver(robot, maxSpeed = 0.5)
offsetDistance = 0.03
gen = driver.followPolyLineG(pts = [(0, 0), (1.0, 0)],
offsetDistance=offsetDistance)
speed, angularSpeed = gen.next()
self.assertAlmostEqual(angularSpeed, -4 * math.radians(20))
self.assertAlmostEqual(speed, 0.444444444444)
# now for closer distance reduce the turning angle
robot.localisation.pose.return_value = (0, 1.5 * offsetDistance, 0)
speed, angularSpeed = gen.next()
self.assertAlmostEqual(angularSpeed, -4 * math.radians(10))
self.assertAlmostEqual(speed, 0.4722222222222222)
if __name__ == "__main__":
unittest.main()
#-------------------------------------------------------------------
# vim: expandtab sw=4 ts=4