Skip to content

Commit d8fe2fc

Browse files
committed
repair mobile tests
1 parent ce4baf6 commit d8fe2fc

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

tests/test_mobile.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def setUp(self):
8484
def test_init(self):
8585

8686
self.assertIsInstance(self.rs.map, rtb.LandmarkMap)
87-
# self.assertIsInstance(self.rs.robot, rtb.Vehicle)
87+
self.assertIsInstance(self.rs.robot, rtb.Bicycle)
8888

8989
self.assertIsInstance(str(self.rs), str)
9090

@@ -97,27 +97,27 @@ def test_reading(self):
9797
# test missing samples
9898
rs = RangeBearingSensor(self.veh, self.map, every=2)
9999

100-
z, lm_id = rs.reading()
101-
self.assertIsInstance(z, np.ndarray)
102-
self.assertEqual(z.shape, (2,))
103-
100+
# first return is (None, None)
104101
z, lm_id = rs.reading()
105102
self.assertEqual(z, None)
106103

107104
z, lm_id = rs.reading()
108105
self.assertIsInstance(z, np.ndarray)
109106
self.assertEqual(z.shape, (2,))
110107

108+
z, lm_id = rs.reading()
109+
self.assertEqual(z, None)
110+
111111
def test_h(self):
112112
xv = np.r_[2, 3, 0.5]
113113
p = np.r_[3, 4]
114114
z = self.rs.h(xv, 10)
115115
self.assertIsInstance(z, np.ndarray)
116116
self.assertEqual(z.shape, (2,))
117-
self.assertAlmostEqual(z[0], np.linalg.norm(self.rs.map.landmark(10) - xv[:2]))
117+
self.assertAlmostEqual(z[0], np.linalg.norm(self.rs.map[10] - xv[:2]))
118118
theta = z[1] + xv[2]
119119
nt.assert_almost_equal(
120-
self.rs.map.landmark(10),
120+
self.rs.map[10],
121121
xv[:2] + z[0] * np.r_[np.cos(theta), np.sin(theta)],
122122
)
123123

@@ -138,7 +138,7 @@ def test_h(self):
138138
nt.assert_almost_equal(z[k, :], self.rs.h(xv, k))
139139

140140
# if vehicle at landmark 10 range=bearing=0
141-
x = np.r_[self.map.landmark(10), 0]
141+
x = np.r_[self.map[10], 0]
142142
z = self.rs.h(x, 10)
143143
self.assertEqual(tuple(z), (0, 0))
144144

@@ -219,27 +219,22 @@ def test_init(self):
219219

220220
map = LandmarkMap(20)
221221

222-
self.assertEqual(map.nlandmarks, 20)
222+
self.assertEqual(len(map), 20)
223223

224-
lm = map.landmark(0)
224+
lm = map[0]
225225
self.assertIsInstance(lm, np.ndarray)
226226
self.assertTrue(lm.shape, (2,))
227227

228228
self.assertIsInstance(str(lm), str)
229229

230-
self.assertEqual(map.x.shape, (20,))
231-
self.assertEqual(map.y.shape, (20,))
232-
self.assertEqual(map.xy.shape, (2, 20))
233-
234230
def test_range(self):
235231
map = LandmarkMap(1000, workspace=[-10, 10, 100, 200])
236232

237233
self.assertTrue(map._map.shape, (2, 1000))
238234

239-
x = map.x
240-
y = map.y
241-
self.assertTrue(all([-10 <= a <= 10 for a in x]))
242-
self.assertTrue(all([100 <= a <= 200 for a in y]))
235+
for x, y in map:
236+
self.assertTrue(-10 <= x <= 10)
237+
self.assertTrue(100 <= y <= 200)
243238

244239
def test_plot(self):
245240
plt.clf()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy