Execute one step of navigation. :return: carla.VehicleControl
(self, debug=False)
| 32 | self._local_planner = LocalPlanner(self._vehicle) |
| 33 | |
| 34 | def run_step(self, debug=False): |
| 35 | """ |
| 36 | Execute one step of navigation. |
| 37 | :return: carla.VehicleControl |
| 38 | """ |
| 39 | |
| 40 | # is there an obstacle in front of us? |
| 41 | hazard_detected = False |
| 42 | |
| 43 | # retrieve relevant elements for safe navigation, i.e.: traffic lights |
| 44 | # and other vehicles |
| 45 | actor_list = self._world.get_actors() |
| 46 | vehicle_list = actor_list.filter("*vehicle*") |
| 47 | lights_list = actor_list.filter("*traffic_light*") |
| 48 | |
| 49 | # check possible obstacles |
| 50 | vehicle_state, vehicle = self._is_vehicle_hazard(vehicle_list) |
| 51 | if vehicle_state: |
| 52 | if debug: |
| 53 | print('!!! VEHICLE BLOCKING AHEAD [{}])'.format(vehicle.id)) |
| 54 | |
| 55 | self._state = AgentState.BLOCKED_BY_VEHICLE |
| 56 | hazard_detected = True |
| 57 | |
| 58 | # check for the state of the traffic lights |
| 59 | light_state, traffic_light = self._is_light_red(lights_list) |
| 60 | if light_state: |
| 61 | if debug: |
| 62 | print('=== RED LIGHT AHEAD [{}])'.format(traffic_light.id)) |
| 63 | |
| 64 | self._state = AgentState.BLOCKED_RED_LIGHT |
| 65 | hazard_detected = True |
| 66 | |
| 67 | if hazard_detected: |
| 68 | control = self.emergency_stop() |
| 69 | else: |
| 70 | self._state = AgentState.NAVIGATING |
| 71 | # standard local planner behavior |
| 72 | control = self._local_planner.run_step() |
| 73 | |
| 74 | return control |
nothing calls this directly
no test coverage detected