@@ -84,7 +84,7 @@ def setUp(self):
84
84
def test_init (self ):
85
85
86
86
self .assertIsInstance (self .rs .map , rtb .LandmarkMap )
87
- # self.assertIsInstance(self.rs.robot, rtb.Vehicle )
87
+ self .assertIsInstance (self .rs .robot , rtb .Bicycle )
88
88
89
89
self .assertIsInstance (str (self .rs ), str )
90
90
@@ -97,27 +97,27 @@ def test_reading(self):
97
97
# test missing samples
98
98
rs = RangeBearingSensor (self .veh , self .map , every = 2 )
99
99
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)
104
101
z , lm_id = rs .reading ()
105
102
self .assertEqual (z , None )
106
103
107
104
z , lm_id = rs .reading ()
108
105
self .assertIsInstance (z , np .ndarray )
109
106
self .assertEqual (z .shape , (2 ,))
110
107
108
+ z , lm_id = rs .reading ()
109
+ self .assertEqual (z , None )
110
+
111
111
def test_h (self ):
112
112
xv = np .r_ [2 , 3 , 0.5 ]
113
113
p = np .r_ [3 , 4 ]
114
114
z = self .rs .h (xv , 10 )
115
115
self .assertIsInstance (z , np .ndarray )
116
116
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 ]))
118
118
theta = z [1 ] + xv [2 ]
119
119
nt .assert_almost_equal (
120
- self .rs .map . landmark ( 10 ) ,
120
+ self .rs .map [ 10 ] ,
121
121
xv [:2 ] + z [0 ] * np .r_ [np .cos (theta ), np .sin (theta )],
122
122
)
123
123
@@ -138,7 +138,7 @@ def test_h(self):
138
138
nt .assert_almost_equal (z [k , :], self .rs .h (xv , k ))
139
139
140
140
# 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 ]
142
142
z = self .rs .h (x , 10 )
143
143
self .assertEqual (tuple (z ), (0 , 0 ))
144
144
@@ -219,27 +219,22 @@ def test_init(self):
219
219
220
220
map = LandmarkMap (20 )
221
221
222
- self .assertEqual (map . nlandmarks , 20 )
222
+ self .assertEqual (len ( map ) , 20 )
223
223
224
- lm = map . landmark ( 0 )
224
+ lm = map [ 0 ]
225
225
self .assertIsInstance (lm , np .ndarray )
226
226
self .assertTrue (lm .shape , (2 ,))
227
227
228
228
self .assertIsInstance (str (lm ), str )
229
229
230
- self .assertEqual (map .x .shape , (20 ,))
231
- self .assertEqual (map .y .shape , (20 ,))
232
- self .assertEqual (map .xy .shape , (2 , 20 ))
233
-
234
230
def test_range (self ):
235
231
map = LandmarkMap (1000 , workspace = [- 10 , 10 , 100 , 200 ])
236
232
237
233
self .assertTrue (map ._map .shape , (2 , 1000 ))
238
234
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 )
243
238
244
239
def test_plot (self ):
245
240
plt .clf ()
0 commit comments