Execute one step of navigation. :param debug: boolean for debugging :return control: carla.VehicleControl
(self, debug=False)
| 358 | return control |
| 359 | |
| 360 | def run_step(self, debug=False): |
| 361 | """ |
| 362 | Execute one step of navigation. |
| 363 | |
| 364 | :param debug: boolean for debugging |
| 365 | :return control: carla.VehicleControl |
| 366 | """ |
| 367 | control = None |
| 368 | if self.behavior.tailgate_counter > 0: |
| 369 | self.behavior.tailgate_counter -= 1 |
| 370 | if self.behavior.overtake_counter > 0: |
| 371 | self.behavior.overtake_counter -= 1 |
| 372 | |
| 373 | ego_vehicle_loc = self.vehicle.get_location() |
| 374 | ego_vehicle_wp = self._map.get_waypoint(ego_vehicle_loc) |
| 375 | |
| 376 | # 1: Red lights and stops behavior |
| 377 | |
| 378 | if self.traffic_light_manager(ego_vehicle_wp) != 0: |
| 379 | return self.emergency_stop() |
| 380 | |
| 381 | # 2.1: Pedestrian avoidancd behaviors |
| 382 | |
| 383 | walker_state, walker, w_distance = self.pedestrian_avoid_manager( |
| 384 | ego_vehicle_loc, ego_vehicle_wp) |
| 385 | |
| 386 | if walker_state: |
| 387 | # Distance is computed from the center of the two cars, |
| 388 | # we use bounding boxes to calculate the actual distance |
| 389 | distance = w_distance - max( |
| 390 | walker.bounding_box.extent.y, walker.bounding_box.extent.x) - max( |
| 391 | self.vehicle.bounding_box.extent.y, self.vehicle.bounding_box.extent.x) |
| 392 | |
| 393 | # Emergency brake if the car is very close. |
| 394 | if distance < self.behavior.braking_distance: |
| 395 | return self.emergency_stop() |
| 396 | |
| 397 | # 2.2: Car following behaviors |
| 398 | vehicle_state, vehicle, distance = self.collision_and_car_avoid_manager( |
| 399 | ego_vehicle_loc, ego_vehicle_wp) |
| 400 | |
| 401 | if vehicle_state: |
| 402 | # Distance is computed from the center of the two cars, |
| 403 | # we use bounding boxes to calculate the actual distance |
| 404 | distance = distance - max( |
| 405 | vehicle.bounding_box.extent.y, vehicle.bounding_box.extent.x) - max( |
| 406 | self.vehicle.bounding_box.extent.y, self.vehicle.bounding_box.extent.x) |
| 407 | |
| 408 | # Emergency brake if the car is very close. |
| 409 | if distance < self.behavior.braking_distance: |
| 410 | return self.emergency_stop() |
| 411 | else: |
| 412 | control = self.car_following_manager(vehicle, distance) |
| 413 | |
| 414 | # 4: Intersection behavior |
| 415 | |
| 416 | # Checking if there's a junction nearby to slow down |
| 417 | elif self.incoming_waypoint.is_junction and (self.incoming_direction == RoadOption.LEFT or self.incoming_direction == RoadOption.RIGHT): |
no test coverage detected