1
2
3from typing import TYPE_CHECKING
4
5from agents.tools.lunatic_agent_tools import detect_obstacles_in_path
6
7if TYPE_CHECKING:
8 from agents.lunatic_agent import LunaticAgent
9
10# TODO: Unify distance and obstacle thresholds
11
12
[docs]
13def collision_detection_manager(self: "LunaticAgent"):
14 """
15 This module is in charge of warning in case of a collision
16 with vehicles or static obstacles.
17
18 :param location: current location of the agent
19 :return vehicle_state: True if there is a vehicle nearby, False if not
20 :return vehicle: nearby vehicle
21 :return distance: distance to nearby vehicle
22
23 # NOTE: Former collision_and_car_avoid_manager, which evaded car via the tailgating function
24 now rule based.
25 """
26
27 vehicle_detection_result = detect_obstacles_in_path(self, self.vehicles_nearby)
28 static_obstacle_detection_result = detect_obstacles_in_path(self, self.static_obstacles_nearby)
29
30 return vehicle_detection_result, static_obstacle_detection_result