Skip to content

Commit

Permalink
Adjust steering PID controller
Browse files Browse the repository at this point in the history
  • Loading branch information
nyukhalov committed May 1, 2020
1 parent ea8ecfb commit 2e6a102
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions carla_ai/av/control/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class Controller(object):
def __init__(self, sim: Simulation, state_updater: StateUpdater):
self.sim = sim
self.state_updater = state_updater
self.steer_pid = PID(0.04, 0, 0.002)
self.steer_pid = PID(0.03, 0, 0.02)
self.throttle_pid = PID(0.05, 0.00022, 0.008)
self.prev_steer = 0.0

def tick(self) -> None:
cte = self.state_updater.cte
speed_err = self.state_updater.speed_err

max_delta = 0.05
max_delta = 100
steer = clamp(-1, self.steer_pid.update(cte), 1)
steer = clamp(self.prev_steer - max_delta, steer, self.prev_steer + max_delta)
self.prev_steer = steer
Expand Down
4 changes: 3 additions & 1 deletion carla_ai/state_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def _get_target_speed(self) -> float:
return closest_node.speed_limit

def _calc_lateral_error(self) -> float:
cur_pose = self.ego_location
# use the center position intead of the rear axle center position
# as it works better with PID steering controller
cur_pose = self.sim.ego_car.get_transform().location
path = self.planner.path

closest_node_idx = None
Expand Down

0 comments on commit 2e6a102

Please sign in to comment.