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

Method _tailgating

agents/navigation/behavior_agent.py:219–253  ·  view source on GitHub ↗

This method is in charge of tailgating 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)

Source from the content-addressed store, hash-verified

217 self.end_waypoint.transform.location, clean=True)
218
219 def _tailgating(self, location, waypoint, vehicle_list):
220 """
221 This method is in charge of tailgating behaviors.
222
223 :param location: current location of the agent
224 :param waypoint: current waypoint of the agent
225 :param vehicle_list: list of all the nearby vehicles
226 """
227
228 left_turn = waypoint.left_lane_marking.lane_change
229 right_turn = waypoint.right_lane_marking.lane_change
230
231 left_wpt = waypoint.get_left_lane()
232 right_wpt = waypoint.get_right_lane()
233
234 behind_vehicle_state, behind_vehicle, _ = self._bh_is_vehicle_hazard(waypoint, location, vehicle_list, max(
235 self.behavior.min_proximity_threshold, self.speed_limit / 2), up_angle_th=180, low_angle_th=160)
236 if behind_vehicle_state and self.speed < get_speed(behind_vehicle):
237 if (right_turn == carla.LaneChange.Right or right_turn ==
238 carla.LaneChange.Both) and waypoint.lane_id * right_wpt.lane_id > 0 and right_wpt.lane_type == carla.LaneType.Driving:
239 new_vehicle_state, _, _ = self._bh_is_vehicle_hazard(waypoint, location, vehicle_list, max(
240 self.behavior.min_proximity_threshold, self.speed_limit / 2), up_angle_th=180, lane_offset=1)
241 if not new_vehicle_state:
242 print("Tailgating, moving to the right!")
243 self.behavior.tailgate_counter = 200
244 self.set_destination(right_wpt.transform.location,
245 self.end_waypoint.transform.location, clean=True)
246 elif left_turn == carla.LaneChange.Left and waypoint.lane_id * left_wpt.lane_id > 0 and left_wpt.lane_type == carla.LaneType.Driving:
247 new_vehicle_state, _, _ = self._bh_is_vehicle_hazard(waypoint, location, vehicle_list, max(
248 self.behavior.min_proximity_threshold, self.speed_limit / 2), up_angle_th=180, lane_offset=-1)
249 if not new_vehicle_state:
250 print("Tailgating, moving to the left!")
251 self.behavior.tailgate_counter = 200
252 self.set_destination(left_wpt.transform.location,
253 self.end_waypoint.transform.location, clean=True)
254
255 def collision_and_car_avoid_manager(self, location, waypoint):
256 """

Callers 1

Calls 3

set_destinationMethod · 0.95
get_speedFunction · 0.90
_bh_is_vehicle_hazardMethod · 0.80

Tested by

no test coverage detected