@@ -176,16 +176,7 @@ def __init__(self, dthresh=0.05, seed=0, **kwargs):
176
176
veh.control = driver
177
177
178
178
The waypoints are positioned inside a rectangular region defined by
179
- the vehicle that is specified by (see ``plotvol2``):
180
-
181
- ============== ======= =======
182
- ``workspace`` x-range y-range
183
- ============== ======= =======
184
- A (scalar) -A:A -A:A
185
- [A, B] A:B A:B
186
- [A, B, C, D] A:B C:D
187
- ============== ======= =======
188
-
179
+ the `workspace`
189
180
190
181
.. note::
191
182
- It is possible in some cases for the vehicle to move outside the desired
@@ -202,30 +193,14 @@ def __init__(self, dthresh=0.05, seed=0, **kwargs):
202
193
203
194
# TODO options to specify region, maybe accept a Map object?
204
195
205
- if hasattr (workspace , "workspace" ):
206
- # workspace can be defined by an object with a workspace attribute
207
- self ._workspace = base .expand_dims (workspace .workspace )
208
- else :
209
- self ._workspace = base .expand_dims (workspace )
196
+ super ().__init__ (** kwargs )
210
197
211
- self ._speed = speed
212
198
self ._dthresh = dthresh * np .diff (self ._workspace [0 :2 ])
213
199
self ._goal_marker = None
214
- if goalmarkerstyle is None :
215
- self ._goal_marker_style = {
216
- "marker" : "D" ,
217
- "markersize" : 6 ,
218
- "color" : "r" ,
219
- "linestyle" : "None" ,
220
- }
221
- else :
222
- self ._goal_marker_style = goalmarkerstyle
223
- self ._headinggain = headinggain
224
200
225
201
self ._d_prev = np .inf
226
202
self ._random = np .random .default_rng (seed )
227
203
self ._seed = seed
228
- self .verbose = True
229
204
self ._goal = None
230
205
self ._dthresh = dthresh * max (
231
206
self ._workspace [1 ] - self ._workspace [0 ],
@@ -235,10 +210,11 @@ def __init__(self, dthresh=0.05, seed=0, **kwargs):
235
210
self ._veh = None
236
211
237
212
def __str__ (self ):
238
- """%RandomPath.char Convert to string
239
- %
240
- % s = R.char() is a string showing driver parameters and state in in
241
- % a compact human readable format."""
213
+ """Convert to string
214
+
215
+ :return: driver parameters and state in in a compact human readable format
216
+ :rtype: str
217
+ """
242
218
243
219
s = "RandomPath driver object\n "
244
220
s += (
@@ -248,19 +224,6 @@ def __str__(self):
248
224
s += f" current goal={ self ._goal } "
249
225
return s
250
226
251
- @property
252
- def workspace (self ):
253
- """
254
- Size of robot driving workspace
255
-
256
- :return: workspace bounds [xmin, xmax, ymin, ymax]
257
- :rtype: ndarray(4)
258
-
259
- Returns the bounds of the workspace as specified by constructor
260
- option ``workspace``
261
- """
262
- return self ._workspace
263
-
264
227
def init (self , ax = None ):
265
228
"""
266
229
Initialize random path driving agent
@@ -305,14 +268,7 @@ def demand(self):
305
268
# self.choose_goal()
306
269
self ._d_prev = d
307
270
308
- speed = self ._speed
309
-
310
- goal_heading = atan2 (
311
- self ._goal [1 ] - self ._veh ._x [1 ], self ._goal [0 ] - self ._veh ._x [0 ]
312
- )
313
- delta_heading = base .angdiff (goal_heading , self ._veh ._x [2 ])
314
-
315
- return np .r_ [speed , self ._headinggain * delta_heading ]
271
+ return self .driveto (self ._goal )
316
272
317
273
## private method, invoked from demand() to compute a new waypoint
318
274
@@ -332,7 +288,7 @@ def _new_goal(self):
332
288
if np .linalg .norm (self ._goal - self ._veh ._x [0 :2 ]) > 2 * self ._dthresh :
333
289
break
334
290
335
- if self ._veh .verbose :
291
+ if self ._veh .verbose or self . _verbose :
336
292
print (f"set goal: { self ._goal } " )
337
293
338
294
# update the goal marker
0 commit comments