:param vehicle_list: list of potential obstacle to check :return: a tuple given by (bool_flag, vehicle), where - bool_flag is True if there is a vehicle ahead blocking us and False otherwise - vehicle is the blocker object itself
(self, vehicle_list)
| 187 | return (False, None, -1) |
| 188 | |
| 189 | def _is_vehicle_hazard(self, vehicle_list): |
| 190 | """ |
| 191 | |
| 192 | :param vehicle_list: list of potential obstacle to check |
| 193 | :return: a tuple given by (bool_flag, vehicle), where |
| 194 | - bool_flag is True if there is a vehicle ahead blocking us |
| 195 | and False otherwise |
| 196 | - vehicle is the blocker object itself |
| 197 | """ |
| 198 | |
| 199 | ego_vehicle_location = self._vehicle.get_location() |
| 200 | ego_vehicle_waypoint = self._map.get_waypoint(ego_vehicle_location) |
| 201 | |
| 202 | for target_vehicle in vehicle_list: |
| 203 | # do not account for the ego vehicle |
| 204 | if target_vehicle.id == self._vehicle.id: |
| 205 | continue |
| 206 | |
| 207 | # if the object is not in our lane it's not an obstacle |
| 208 | target_vehicle_waypoint = self._map.get_waypoint(target_vehicle.get_location()) |
| 209 | if target_vehicle_waypoint.road_id != ego_vehicle_waypoint.road_id or \ |
| 210 | target_vehicle_waypoint.lane_id != ego_vehicle_waypoint.lane_id: |
| 211 | continue |
| 212 | |
| 213 | if is_within_distance_ahead(target_vehicle.get_transform(), |
| 214 | self._vehicle.get_transform(), |
| 215 | self._proximity_vehicle_threshold): |
| 216 | return (True, target_vehicle) |
| 217 | |
| 218 | return (False, None) |
| 219 | |
| 220 | |
| 221 | @staticmethod |
no test coverage detected