Source code for agents.substep_managers.pedestrian_detection

 1from typing import TYPE_CHECKING
 2
 3from agents.tools.hints import ObstacleDetectionResult
 4from agents.tools.lunatic_agent_tools import detect_vehicles
 5from classes.constants import RoadOption
 6
 7if TYPE_CHECKING:
 8    from agents.lunatic_agent import LunaticAgent
 9
10# TODO: Despite a few constants very similar to vehicle to the collision_detection_manager,
11# might be fusable
12
13
[docs] 14def pedestrian_detection_manager(self: "LunaticAgent") -> ObstacleDetectionResult: 15 """ 16 This module is in charge of warning in case of a collision 17 with any pedestrian. 18 19 :param location: current location of the agent 20 :return vehicle_state: True if there is a walker nearby, False if not 21 :return vehicle: nearby walker 22 :return distance: distance to nearby walker 23 """ 24 walker_list = self.walkers_nearby 25 26 if self.config.live_info.incoming_direction == RoadOption.CHANGELANELEFT: 27 detection_result = detect_vehicles(self, walker_list, 28 self.max_detection_distance("other_lane"), 29 up_angle_th=self.config.obstacles.detection_angles.walkers_lane_change[1], 30 lane_offset=-1) 31 elif self.config.live_info.incoming_direction == RoadOption.CHANGELANERIGHT: 32 detection_result = detect_vehicles(self, walker_list, 33 self.max_detection_distance("other_lane"), 34 up_angle_th=self.config.obstacles.detection_angles.walkers_lane_change[1], 35 lane_offset=1) 36 else: 37 detection_result = detect_vehicles(self, walker_list, 38 self.max_detection_distance("same_lane"), 39 up_angle_th=self.config.obstacles.detection_angles.walkers_same_lane[1]) 40 return detection_result