Controller initialization. :param opt_dict: dictionary of arguments. :return:
(self, opt_dict)
| 88 | print("Resetting ego-vehicle!") |
| 89 | |
| 90 | def _init_controller(self, opt_dict): |
| 91 | """ |
| 92 | Controller initialization. |
| 93 | |
| 94 | :param opt_dict: dictionary of arguments. |
| 95 | :return: |
| 96 | """ |
| 97 | # default params |
| 98 | self._dt = 1.0 / 20.0 |
| 99 | self._target_speed = 20.0 # Km/h |
| 100 | self._sampling_radius = self._target_speed * 1 / 3.6 # 1 seconds horizon |
| 101 | self._min_distance = self._sampling_radius * self.MIN_DISTANCE_PERCENTAGE |
| 102 | self._max_brake = 0.3 |
| 103 | self._max_throt = 0.75 |
| 104 | self._max_steer = 0.8 |
| 105 | args_lateral_dict = { |
| 106 | 'K_P': 1.95, |
| 107 | 'K_D': 0.2, |
| 108 | 'K_I': 0.07, |
| 109 | 'dt': self._dt} |
| 110 | args_longitudinal_dict = { |
| 111 | 'K_P': 1.0, |
| 112 | 'K_D': 0, |
| 113 | 'K_I': 0.05, |
| 114 | 'dt': self._dt} |
| 115 | |
| 116 | # parameters overload |
| 117 | if opt_dict: |
| 118 | if 'dt' in opt_dict: |
| 119 | self._dt = opt_dict['dt'] |
| 120 | if 'target_speed' in opt_dict: |
| 121 | self._target_speed = opt_dict['target_speed'] |
| 122 | if 'sampling_radius' in opt_dict: |
| 123 | self._sampling_radius = self._target_speed * \ |
| 124 | opt_dict['sampling_radius'] / 3.6 |
| 125 | if 'lateral_control_dict' in opt_dict: |
| 126 | args_lateral_dict = opt_dict['lateral_control_dict'] |
| 127 | if 'longitudinal_control_dict' in opt_dict: |
| 128 | args_longitudinal_dict = opt_dict['longitudinal_control_dict'] |
| 129 | if 'max_throttle' in opt_dict: |
| 130 | self._max_throt = opt_dict['max_throttle'] |
| 131 | if 'max_brake' in opt_dict: |
| 132 | self._max_brake = opt_dict['max_brake'] |
| 133 | if 'max_steering' in opt_dict: |
| 134 | self._max_steer = opt_dict['max_steering'] |
| 135 | |
| 136 | self._current_waypoint = self._map.get_waypoint(self._vehicle.get_location()) |
| 137 | self._vehicle_controller = VehiclePIDController(self._vehicle, |
| 138 | args_lateral=args_lateral_dict, |
| 139 | args_longitudinal=args_longitudinal_dict, |
| 140 | max_throttle=self._max_throt, |
| 141 | max_brake=self._max_brake, |
| 142 | max_steering=self._max_steer,) |
| 143 | |
| 144 | self._global_plan = False |
| 145 | |
| 146 | # compute initial waypoints |
| 147 | self._waypoints_queue.append((self._current_waypoint.next(self._sampling_radius)[0], RoadOption.LANEFOLLOW)) |
no test coverage detected