|
4 | 4 |
|
5 | 5 | author: Atsushi Sakai (@Atsushi_twi)
|
6 | 6 |
|
7 |
| -""" |
8 |
| -from __future__ import division, print_function |
| 7 | +Ref: |
| 8 | + - [Stanley: The robot that won the DARPA grand challenge](http://isl.ecst.csuchico.edu/DOCS/darpa2005/DARPA%202005%20Stanley.pdf) |
| 9 | + - [Autonomous Automobile Path Tracking](https://www.ri.cmu.edu/pub_files/2009/2/Automatic_Steering_Methods_for_Autonomous_Automobile_Path_Tracking.pdf) |
9 | 10 |
|
| 11 | +""" |
| 12 | +import numpy as np |
| 13 | +import matplotlib.pyplot as plt |
10 | 14 | import sys
|
11 |
| - |
12 | 15 | sys.path.append("../../PathPlanning/CubicSpline/")
|
13 | 16 |
|
14 |
| -import matplotlib.pyplot as plt |
15 |
| -import numpy as np |
| 17 | +try: |
| 18 | + import cubic_spline_planner |
| 19 | +except: |
| 20 | + raise |
16 | 21 |
|
17 |
| -import cubic_spline_planner |
18 | 22 |
|
19 | 23 | k = 0.5 # control gain
|
20 | 24 | Kp = 1.0 # speed propotional gain
|
@@ -131,12 +135,13 @@ def calc_target_index(state, cx, cy):
|
131 | 135 | dx = [fx - icx for icx in cx]
|
132 | 136 | dy = [fy - icy for icy in cy]
|
133 | 137 | d = [np.sqrt(idx ** 2 + idy ** 2) for (idx, idy) in zip(dx, dy)]
|
134 |
| - front_axle_vec = [-np.cos(state.yaw + np.pi/2), -np.sin(state.yaw + np.pi/2)] |
135 | 138 | closest_error = min(d)
|
136 | 139 | target_idx = d.index(closest_error)
|
137 |
| - |
138 |
| - #Project RMS error onto front axle vector |
139 |
| - error_front_axle = np.dot( [ dx[target_idx], dy[target_idx] ], front_axle_vec) |
| 140 | + |
| 141 | + # Project RMS error onto front axle vector |
| 142 | + front_axle_vec = [-np.cos(state.yaw + np.pi / 2), |
| 143 | + - np.sin(state.yaw + np.pi / 2)] |
| 144 | + error_front_axle = np.dot([dx[target_idx], dy[target_idx]], front_axle_vec) |
140 | 145 |
|
141 | 146 | return target_idx, error_front_axle
|
142 | 147 |
|
|
0 commit comments