Skip to content

Commit 12ca412

Browse files
committed
tidy up graphics
1 parent cd350cf commit 12ca412

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

roboticstoolbox/mobile/Bug2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def m_line(self):
6868
return self._m_line
6969

7070
# override query method of base class
71-
def run(self, start=None, goal=None, animate=False, trail=True, movie=None, **kwargs):
71+
def run(self, start=None, goal=None, animate=False, pause=0.001, trail=True, movie=None, **kwargs):
7272
"""
7373
Find a path using Bug2 reactive navigation algorithm
7474
@@ -122,7 +122,7 @@ def run(self, start=None, goal=None, animate=False, trail=True, movie=None, **kw
122122
path = robot
123123
h = None
124124

125-
trail_line, = plt.plot(0, 0, 'y.')
125+
trail_line, = plt.plot(0, 0, 'y.', label='robot path')
126126
trail_head, = plt.plot(0, 0, 'ko', zorder=10)
127127

128128
# iterate using the next() method until we reach the goal
@@ -132,7 +132,8 @@ def run(self, start=None, goal=None, animate=False, trail=True, movie=None, **kw
132132
if trail:
133133
trail_line.set_data(path.T)
134134

135-
plt.pause(0.001)
135+
if pause > 0:
136+
plt.pause(pause)
136137
# plt.draw()
137138
# plt.show(block=False)
138139
# plt.gcf().canvas.flush_events()
@@ -165,15 +166,15 @@ def plot_m_line(self, ls=None):
165166
if self._m_line[1] == 0:
166167
# handle the case that the line is vertical
167168
plt.plot([self._start[0], self._start[0]],
168-
[y_min, y_max], 'k--')
169+
[y_min, y_max], 'k--', label='m-line')
169170
else:
170171
# regular line
171172
x = np.array([
172173
[x_min, 1],
173174
[x_max, 1] ])
174175
y = -x @ np.r_[self._m_line[0], self._m_line[2]]
175176
y = y / self._m_line[1]
176-
plt.plot([x_min, x_max], y, ls, zorder=10)
177+
plt.plot([x_min, x_max], y, ls, zorder=10, label='m-line')
177178

178179
def next(self, position):
179180

0 commit comments

Comments
 (0)