Skip to content

Commit 5f2818a

Browse files
committed
feat: Limit the maximum steering angle to improve path tracking control
1 parent 466943f commit 5f2818a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

PathTracking/pure_pursuit/pure_pursuit.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
WIDTH = 2.0 # Vehicle width
2929
WHEEL_LEN = 0.6 # Wheel length
3030
WHEEL_WIDTH = 0.2 # Wheel width
31+
MAX_STEER = math.pi / 4 # Maximum steering angle [rad]
3132

3233

3334
show_animation = True
@@ -144,12 +145,8 @@ def pure_pursuit_steer_control(state, trajectory, pind):
144145
# Reverse steering angle when reversing
145146
delta = state.direction * math.atan2(2.0 * WB * math.sin(alpha) / Lf, 1.0)
146147

147-
if delta > math.pi / 4:
148-
delta = math.pi / 4
149-
elif delta < - math.pi / 4:
150-
delta = - 1 * math.pi / 4
151-
else:
152-
delta = delta
148+
# Limit steering angle to max value
149+
delta = max(min(delta, MAX_STEER), -MAX_STEER)
153150

154151
return delta, ind
155152

0 commit comments

Comments
 (0)