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

Method run_step

agents/navigation/basic_agent.py:81–121  ·  view source on GitHub ↗

Execute one step of navigation. :return: carla.VehicleControl

(self, debug=False)

Source from the content-addressed store, hash-verified

79 return route
80
81 def run_step(self, debug=False):
82 """
83 Execute one step of navigation.
84 :return: carla.VehicleControl
85 """
86
87 # is there an obstacle in front of us?
88 hazard_detected = False
89
90 # retrieve relevant elements for safe navigation, i.e.: traffic lights
91 # and other vehicles
92 actor_list = self._world.get_actors()
93 vehicle_list = actor_list.filter("*vehicle*")
94 lights_list = actor_list.filter("*traffic_light*")
95
96 # check possible obstacles
97 vehicle_state, vehicle = self._is_vehicle_hazard(vehicle_list)
98 if vehicle_state:
99 if debug:
100 print('!!! VEHICLE BLOCKING AHEAD [{}])'.format(vehicle.id))
101
102 self._state = AgentState.BLOCKED_BY_VEHICLE
103 hazard_detected = True
104
105 # check for the state of the traffic lights
106 light_state, traffic_light = self._is_light_red(lights_list)
107 if light_state:
108 if debug:
109 print('=== RED LIGHT AHEAD [{}])'.format(traffic_light.id))
110
111 self._state = AgentState.BLOCKED_RED_LIGHT
112 hazard_detected = True
113
114 if hazard_detected:
115 control = self.emergency_stop()
116 else:
117 self._state = AgentState.NAVIGATING
118 # standard local planner behavior
119 control = self._local_planner.run_step(debug=debug)
120
121 return control
122
123 def done(self):
124 """

Callers

nothing calls this directly

Calls 4

get_actorsMethod · 0.80
emergency_stopMethod · 0.80
_is_vehicle_hazardMethod · 0.45
_is_light_redMethod · 0.45

Tested by

no test coverage detected