Skip to content

Commit

Permalink
removed look ahead distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ShisatoYano committed Jun 30, 2024
1 parent 5b7b737 commit 40b19b8
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/components/control/pid/pid_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def __init__(self, spec, course=None):
"""

self.MIN_LOOK_AHEAD_DISTANCE_M = 2.0
self.LOOK_FORWARD_GAIN = 0.3
self.SPEED_PROPORTIONAL_GAIN = 1.0
self.WHEEL_BASE_M = spec.wheel_base_m

Expand All @@ -30,26 +29,14 @@ def __init__(self, spec, course=None):
self.target_accel_mps2 = 0.0
self.target_steer_rad = 0.0
self.target_yaw_rate_rps = 0.0

def _calculate_look_ahead_distance(self, state):
"""
Private function to calculate look ahead distance to target point
state: Vehicle's state object
"""

self.look_ahead_distance_m = self.LOOK_FORWARD_GAIN * state.get_speed_mps() + self.MIN_LOOK_AHEAD_DISTANCE_M

def _calculate_target_course_index(self, state):
"""
Private function to calculate target point's index on course
state: Vehicle's state object
"""

nearest_index = self.course.search_nearest_point_index(state)
while self.look_ahead_distance_m > self.course.calculate_distance_from_point(state, nearest_index):
if nearest_index + 1 >= self.course.length(): break
nearest_index += 1
self.target_course_index = nearest_index
self.target_course_index = self.course.search_nearest_point_index(state)

def _calculate_target_acceleration_mps2(self, state):
"""
Expand Down Expand Up @@ -85,8 +72,6 @@ def update(self, state):

if not self.course: return

self._calculate_look_ahead_distance(state)

self._calculate_target_course_index(state)

self._calculate_target_acceleration_mps2(state)
Expand Down

0 comments on commit 40b19b8

Please sign in to comment.