@@ -119,7 +119,7 @@ def rear_wheel_feedback_control(state, e, k, yaw_ref):
119
119
return delta
120
120
121
121
122
- def simulate (track , goal ):
122
+ def simulate (path_ref , goal ):
123
123
T = 500.0 # max simulation time
124
124
goal_dis = 0.3
125
125
@@ -133,11 +133,11 @@ def simulate(track, goal):
133
133
t = [0.0 ]
134
134
goal_flag = False
135
135
136
- s = np .arange (0 , track .length , 0.1 )
137
- e , k , yaw_ref , s0 = track .calc_track_error (state .x , state .y , 0.0 )
136
+ s = np .arange (0 , path_ref .length , 0.1 )
137
+ e , k , yaw_ref , s0 = path_ref .calc_track_error (state .x , state .y , 0.0 )
138
138
139
139
while T >= time :
140
- e , k , yaw_ref , s0 = track .calc_track_error (state .x , state .y , s0 )
140
+ e , k , yaw_ref , s0 = path_ref .calc_track_error (state .x , state .y , s0 )
141
141
di = rear_wheel_feedback_control (state , e , k , yaw_ref )
142
142
143
143
speed_ref = calc_target_speed (state , yaw_ref )
@@ -165,9 +165,9 @@ def simulate(track, goal):
165
165
# for stopping simulation with the esc key.
166
166
plt .gcf ().canvas .mpl_connect ('key_release_event' ,
167
167
lambda event : [exit (0 ) if event .key == 'escape' else None ])
168
- plt .plot (track .X (s ), track .Y (s ), "-r" , label = "course" )
168
+ plt .plot (path_ref .X (s ), path_ref .Y (s ), "-r" , label = "course" )
169
169
plt .plot (x , y , "ob" , label = "trajectory" )
170
- plt .plot (track .X (s0 ), track .Y (s0 ), "xg" , label = "target" )
170
+ plt .plot (path_ref .X (s0 ), path_ref .Y (s0 ), "xg" , label = "target" )
171
171
plt .axis ("equal" )
172
172
plt .grid (True )
173
173
plt .title ("speed[km/h]:{:.2f}, target s-param:{:.2f}" .format (round (state .v * 3.6 , 2 ), s0 ))
@@ -196,10 +196,10 @@ def main():
196
196
ay = [0.0 , 0.0 , 5.0 , 6.5 , 3.0 , 5.0 , - 2.0 ]
197
197
goal = [ax [- 1 ], ay [- 1 ]]
198
198
199
- track = CubicSplinePath (ax , ay )
200
- s = np .arange (0 , track .length , 0.1 )
199
+ reference_path = CubicSplinePath (ax , ay )
200
+ s = np .arange (0 , reference_path .length , 0.1 )
201
201
202
- t , x , y , yaw , v , goal_flag = simulate (track , goal )
202
+ t , x , y , yaw , v , goal_flag = simulate (reference_path , goal )
203
203
204
204
# Test
205
205
assert goal_flag , "Cannot goal"
@@ -208,7 +208,7 @@ def main():
208
208
plt .close ()
209
209
plt .subplots (1 )
210
210
plt .plot (ax , ay , "xb" , label = "input" )
211
- plt .plot (track .X (s ), track .Y (s ), "-r" , label = "spline" )
211
+ plt .plot (reference_path .X (s ), reference_path .Y (s ), "-r" , label = "spline" )
212
212
plt .plot (x , y , "-g" , label = "tracking" )
213
213
plt .grid (True )
214
214
plt .axis ("equal" )
@@ -217,14 +217,14 @@ def main():
217
217
plt .legend ()
218
218
219
219
plt .subplots (1 )
220
- plt .plot (s , np .rad2deg (track .calc_yaw (s )), "-r" , label = "yaw" )
220
+ plt .plot (s , np .rad2deg (reference_path .calc_yaw (s )), "-r" , label = "yaw" )
221
221
plt .grid (True )
222
222
plt .legend ()
223
223
plt .xlabel ("line length[m]" )
224
224
plt .ylabel ("yaw angle[deg]" )
225
225
226
226
plt .subplots (1 )
227
- plt .plot (s , track .calc_curvature (s ), "-r" , label = "curvature" )
227
+ plt .plot (s , reference_path .calc_curvature (s ), "-r" , label = "curvature" )
228
228
plt .grid (True )
229
229
plt .legend ()
230
230
plt .xlabel ("line length[m]" )
0 commit comments