Skip to content

Commit 228fef4

Browse files
committed
implementing target yaw rate calculation
1 parent 79a2262 commit 228fef4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/components/control/rear_wheel_feedback/rear_wheel_feedback_controller.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Author: Shisato Yano
55
"""
66

7+
from math import sin, cos
8+
79

810
class RearWheelFeedbackController:
911
"""
@@ -17,6 +19,8 @@ def __init__(self, spec, course=None):
1719
"""
1820

1921
self.SPEED_PROPORTIONAL_GAIN = 1.0
22+
self.YAW_ERROR_GAIN = 1.0
23+
self.LAT_ERROR_GAIN = 0.5
2024
self.WHEEL_BASE_M = spec.wheel_base_m
2125

2226
self.course = course
@@ -51,7 +55,19 @@ def _calculate_tracking_error(self, state):
5155

5256
error_lon_m, error_lat_m, error_yaw_rad = self.course.calculate_lonlat_error(state, self.target_course_index)
5357
return error_lon_m, error_lat_m, error_yaw_rad
54-
58+
59+
def _calculate_target_yaw_rate_rps(self, state, error_lat_m, error_yaw_rad):
60+
"""
61+
Private function to calculate yaw rate input
62+
state: Vehicle's state object
63+
error_lat_m: Lateral error against reference course[m]
64+
error_yaw_rad: Yaw angle error against reference course[rad]
65+
"""
66+
67+
curr_spd = state.get_speed_mps()
68+
trgt_curv = self.course.point_curvature(self.target_course_index)
69+
70+
yaw_rate_rps = curr_spd * trgt_curv * cos(error_yaw_rad) / (1.0 - trgt_curv * error_lat_m)
5571

5672
def update(self, state):
5773
"""
@@ -65,7 +81,9 @@ def update(self, state):
6581

6682
self._calculate_target_acceleration_mps2(state)
6783

68-
error_lon_m, error_lat_m, error_yaw_rad = self._calculate_tracking_error(state)
84+
_, error_lat_m, error_yaw_rad = self._calculate_tracking_error(state)
85+
86+
self._calculate_target_yaw_rate_rps(state, error_lat_m, error_yaw_rad)
6987

7088
def get_target_accel_mps2(self):
7189
"""

0 commit comments

Comments
 (0)