MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / run_step

Method run_step

PythonAPI/carla/agents/navigation/basic_agent.py:84–124  ·  view source on GitHub ↗

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

(self, debug=False)

Source from the content-addressed store, hash-verified

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

Callers 1

game_loopFunction · 0.95

Calls 3

_is_vehicle_hazardMethod · 0.80
_is_light_redMethod · 0.80
emergency_stopMethod · 0.80

Tested by

no test coverage detected