This method is in charge of overtaking behaviors. :param location: current location of the agent :param waypoint: current waypoint of the agent :param vehicle_list: list of all the nearby vehicles
(self, location, waypoint, vehicle_list)
| 184 | return 0 |
| 185 | |
| 186 | def _overtake(self, location, waypoint, vehicle_list): |
| 187 | """ |
| 188 | This method is in charge of overtaking behaviors. |
| 189 | |
| 190 | :param location: current location of the agent |
| 191 | :param waypoint: current waypoint of the agent |
| 192 | :param vehicle_list: list of all the nearby vehicles |
| 193 | """ |
| 194 | |
| 195 | left_turn = waypoint.left_lane_marking.lane_change |
| 196 | right_turn = waypoint.right_lane_marking.lane_change |
| 197 | |
| 198 | left_wpt = waypoint.get_left_lane() |
| 199 | right_wpt = waypoint.get_right_lane() |
| 200 | |
| 201 | if (left_turn == carla.LaneChange.Left or left_turn == |
| 202 | carla.LaneChange.Both) and waypoint.lane_id * left_wpt.lane_id > 0 and left_wpt.lane_type == carla.LaneType.Driving: |
| 203 | new_vehicle_state, _, _ = self._bh_is_vehicle_hazard(waypoint, location, vehicle_list, max( |
| 204 | self.behavior.min_proximity_threshold, self.speed_limit / 3), up_angle_th=180, lane_offset=-1) |
| 205 | if not new_vehicle_state: |
| 206 | print("Overtaking to the left!") |
| 207 | self.behavior.overtake_counter = 200 |
| 208 | self.set_destination(left_wpt.transform.location, |
| 209 | self.end_waypoint.transform.location, clean=True) |
| 210 | elif right_turn == carla.LaneChange.Right and waypoint.lane_id * right_wpt.lane_id > 0 and right_wpt.lane_type == carla.LaneType.Driving: |
| 211 | new_vehicle_state, _, _ = self._bh_is_vehicle_hazard(waypoint, location, vehicle_list, max( |
| 212 | self.behavior.min_proximity_threshold, self.speed_limit / 3), up_angle_th=180, lane_offset=1) |
| 213 | if not new_vehicle_state: |
| 214 | print("Overtaking to the right!") |
| 215 | self.behavior.overtake_counter = 200 |
| 216 | self.set_destination(right_wpt.transform.location, |
| 217 | self.end_waypoint.transform.location, clean=True) |
| 218 | |
| 219 | def _tailgating(self, location, waypoint, vehicle_list): |
| 220 | """ |
no test coverage detected