Skip to content

Commit cd0d022

Browse files
committed
fix minor bugs for RVC3 examples running in Jupyter
1 parent f2e152f commit cd0d022

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

roboticstoolbox/mobile/DistanceTransformPlanner.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __str__(self):
106106

107107
return s
108108

109-
def plan(self, goal=None, animate=False, verbose=False):
109+
def plan(self, goal=None, animate=False, summary=False):
110110
r"""
111111
Plan path using distance transform
112112
@@ -135,7 +135,8 @@ def plan(self, goal=None, animate=False, verbose=False):
135135
self.occgrid.grid,
136136
goal=self._goal,
137137
metric=self._metric,
138-
animate=animate
138+
animate=animate,
139+
summary=summary,
139140
)
140141

141142
def next(self, position):
@@ -215,7 +216,7 @@ def plot_3d(self, path=None, ls=None):
215216
line/surface handling.
216217
"""
217218
fig = plt.figure()
218-
ax = fig.gca(projection="3d")
219+
ax = fig.add_subplot(111, projection="3d")
219220

220221
distance = self._distancemap
221222
X, Y = np.meshgrid(np.arange(distance.shape[1]), np.arange(distance.shape[0]))
@@ -273,7 +274,7 @@ def distancexform(occgrid, goal, metric="cityblock", animate=False, summary=Fals
273274
# - other cells are inf
274275
# - goal is zero
275276

276-
goal = base.getvector(goal, 2, dtype=np.int)
277+
goal = base.getvector(goal, 2, dtype=int)
277278

278279
distance = occgrid.astype(np.float32)
279280
distance[occgrid > 0] = np.nan # assign nan to obstacle cells

roboticstoolbox/mobile/DubinsPlanner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,15 @@ def __str__(self):
391391
super().__str__()
392392
+ f"\n curvature={self.curvature}, stepsize={self.stepsize}"
393393
)
394+
return s
395+
396+
@property
397+
def curvature(self):
398+
return self._curvature
399+
400+
@property
401+
def stepsize(self):
402+
return self._stepsize
394403

395404
def query(self, start, goal, **kwargs):
396405
r"""

roboticstoolbox/mobile/PRMPlanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def plot(self, *args, vertex={}, edge={}, **kwargs):
294294
edge = {**dict(linewidth=0.5), **edge}
295295

296296
# add the roadmap graph
297-
self.graph.plot(text=False, vopt=vertex, eopt=edge)
297+
self.graph.plot(text=False, vopt=vertex, eopt=edge, ax=ax)
298298

299299

300300
if __name__ == "__main__":

roboticstoolbox/mobile/PlannerBase.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from spatialmath.base.transforms2d import *
1212
from spatialmath.base.vectors import *
1313
from spatialmath.base.argcheck import getvector
14-
from spatialmath.base.graphics import axes_logic, plotvol2
14+
from spatialmath.base.graphics import axes_logic, plotvol2, axes_get_scale
1515

1616
# from spatialmath import SE2, SE3
1717
from matplotlib import cm
@@ -125,8 +125,8 @@ def __str__(self):
125125
:rtype: str
126126
"""
127127
s = f"{self.__class__.__name__}: "
128-
if self._occgrid0 is not None:
129-
s += "\n " + str(self.occgrid)
128+
if hasattr(self, "_occgrid") and self._occgrid is not None:
129+
s += "\n " + str(self._occgrid)
130130
if self._start is not None:
131131
s += f"\n Start: {self.start}"
132132
if self._goal is not None:
@@ -766,7 +766,8 @@ def plot(
766766
else:
767767
ax.set_zlabel(r"$\theta$")
768768

769-
plt.show(block=block)
769+
if block:
770+
plt.show(block=block)
770771

771772
return ax
772773

@@ -802,6 +803,7 @@ def plot_bg(
802803
ax=None,
803804
inflated=True,
804805
colorbar=True,
806+
block=False,
805807
**unused,
806808
):
807809
"""

0 commit comments

Comments
 (0)