Skip to content

Commit

Permalink
implemented target steer angle and yaw rate calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ShisatoYano committed Jun 25, 2024
1 parent 4f25298 commit f5f3ac3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/control/pid/pid_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ def _calculate_target_acceleration_mps2(self, state):
diff_speed_mps = self.course.calculate_speed_difference_mps(state, self.target_course_index)
self.target_accel_mps2 = self.SPEED_PROPORTIONAL_GAIN * diff_speed_mps

def _calculate_target_steer_angle_rad(self, state):
"""
Private function to calculate steering angle input
state: Vehicle's state object
"""

diff_angle_rad = self.course.calculate_angle_difference_rad(state, self.target_course_index)
self.target_steer_rad = atan2((2 * self.WHEEL_BASE_M * sin(diff_angle_rad)), self.look_ahead_distance_m)

def _calculate_target_yaw_rate_rps(self, state):
"""
Private function to calculate yaw rate input
state: Vehicle's state object
"""

self.target_yaw_rate_rps = state.get_speed_mps() * tan(self.target_steer_rad) / self.WHEEL_BASE_M

def update(self, state):
"""
Function to update data for path tracking
Expand All @@ -73,3 +90,7 @@ def update(self, state):
self._calculate_target_course_index(state)

self._calculate_target_acceleration_mps2(state)

self._calculate_target_steer_angle_rad(state)

self._calculate_target_yaw_rate_rps(state)

0 comments on commit f5f3ac3

Please sign in to comment.