@@ -68,7 +68,7 @@ def m_line(self):
68
68
return self ._m_line
69
69
70
70
# 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 ):
72
72
"""
73
73
Find a path using Bug2 reactive navigation algorithm
74
74
@@ -122,7 +122,7 @@ def run(self, start=None, goal=None, animate=False, trail=True, movie=None, **kw
122
122
path = robot
123
123
h = None
124
124
125
- trail_line , = plt .plot (0 , 0 , 'y.' )
125
+ trail_line , = plt .plot (0 , 0 , 'y.' , label = 'robot path' )
126
126
trail_head , = plt .plot (0 , 0 , 'ko' , zorder = 10 )
127
127
128
128
# 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
132
132
if trail :
133
133
trail_line .set_data (path .T )
134
134
135
- plt .pause (0.001 )
135
+ if pause > 0 :
136
+ plt .pause (pause )
136
137
# plt.draw()
137
138
# plt.show(block=False)
138
139
# plt.gcf().canvas.flush_events()
@@ -165,15 +166,15 @@ def plot_m_line(self, ls=None):
165
166
if self ._m_line [1 ] == 0 :
166
167
# handle the case that the line is vertical
167
168
plt .plot ([self ._start [0 ], self ._start [0 ]],
168
- [y_min , y_max ], 'k--' )
169
+ [y_min , y_max ], 'k--' , label = 'm-line' )
169
170
else :
170
171
# regular line
171
172
x = np .array ([
172
173
[x_min , 1 ],
173
174
[x_max , 1 ] ])
174
175
y = - x @ np .r_ [self ._m_line [0 ], self ._m_line [2 ]]
175
176
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' )
177
178
178
179
def next (self , position ):
179
180
0 commit comments