Execute one step of control invoking both lateral and longitudinal PID controllers to reach a target waypoint at a given target_speed. :param target_speed: desired vehicle speed :param waypoint: target location encoded as a waypoint :retu
(self, target_speed, waypoint)
| 48 | self._lat_controller = PIDLateralController(self._vehicle, **args_lateral) |
| 49 | |
| 50 | def run_step(self, target_speed, waypoint): |
| 51 | """ |
| 52 | Execute one step of control invoking both lateral and longitudinal |
| 53 | PID controllers to reach a target waypoint |
| 54 | at a given target_speed. |
| 55 | |
| 56 | :param target_speed: desired vehicle speed |
| 57 | :param waypoint: target location encoded as a waypoint |
| 58 | :return: distance (in meters) to the waypoint |
| 59 | """ |
| 60 | |
| 61 | acceleration = self._lon_controller.run_step(target_speed) |
| 62 | current_steering = self._lat_controller.run_step(waypoint) |
| 63 | control = carla.VehicleControl() |
| 64 | if acceleration >= 0.0: |
| 65 | control.throttle = min(acceleration, self.max_throt) |
| 66 | control.brake = 0.0 |
| 67 | else: |
| 68 | control.throttle = 0.0 |
| 69 | control.brake = min(abs(acceleration), self.max_brake) |
| 70 | |
| 71 | # Steering regulation: changes cannot happen abruptly, can't steer too much. |
| 72 | |
| 73 | if current_steering > self.past_steering + 0.1: |
| 74 | current_steering = self.past_steering + 0.1 |
| 75 | elif current_steering < self.past_steering - 0.1: |
| 76 | current_steering = self.past_steering - 0.1 |
| 77 | |
| 78 | if current_steering >= 0: |
| 79 | steering = min(self.max_steer, current_steering) |
| 80 | else: |
| 81 | steering = max(-self.max_steer, current_steering) |
| 82 | |
| 83 | control.steer = steering |
| 84 | control.hand_brake = False |
| 85 | control.manual_gear_shift = False |
| 86 | self.past_steering = steering |
| 87 | |
| 88 | return control |
| 89 | |
| 90 | |
| 91 | class PIDLongitudinalController(): |
nothing calls this directly
no outgoing calls
no test coverage detected