Source code for agents.substep_managers.obstacle_detection

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