MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / _is_vehicle_hazard

Method _is_vehicle_hazard

agents/navigation/agent.py:189–218  ·  view source on GitHub ↗

: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)

Source from the content-addressed store, hash-verified

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

Callers 2

run_stepMethod · 0.45
run_stepMethod · 0.45

Calls 4

is_within_distance_aheadFunction · 0.90
get_locationMethod · 0.80
get_waypointMethod · 0.80
get_transformMethod · 0.80

Tested by

no test coverage detected