diff --git a/src/carla_traffic_light/README.md b/src/carla_traffic_light/README.md index 76adf016de..7bcc1939fa 100644 --- a/src/carla_traffic_light/README.md +++ b/src/carla_traffic_light/README.md @@ -1,5 +1,5 @@ -# CARLA 0.9.11 中的交通灯检测与自主控制 -本项目使用 CARLA 仿真器(0.9.11 版本)实现了一套简易自主控制系统。系统利用摄像头数据检测**交通灯**,并控制车辆**红灯停车**、**绿灯通行**。 +# CARLA 0.9.15 中的交通灯检测与自主控制 +本项目使用 CARLA 仿真器(0.9.15 版本)实现了一套简易自主控制系统。系统利用摄像头数据检测**交通灯**,并控制车辆**红灯停车**、**绿灯通行**。 ## 功能特点: - 利用 RGB 摄像头与边界框进行**交通灯检测**。 diff --git a/src/carla_traffic_light/code/automatic_control.py b/src/carla_traffic_light/code/automatic_control.py index 3bce2effc4..7ee3aa37e3 100644 --- a/src/carla_traffic_light/code/automatic_control.py +++ b/src/carla_traffic_light/code/automatic_control.py @@ -7,7 +7,7 @@ # For a copy, see . """Example of automatic vehicle control from client side.""" - +# -*- coding: utf-8 -*- from __future__ import print_function import argparse @@ -701,12 +701,12 @@ def game_loop(args): spawn_points = world.map.get_spawn_points() random.shuffle(spawn_points) - if spawn_points[0].location != agent.vehicle.get_location(): + if spawn_points[0].location != world.player.get_location(): destination = spawn_points[0].location else: destination = spawn_points[1].location - agent.set_destination(agent.vehicle.get_location(), destination, clean=True) + agent.set_destination(world.player.get_location(), destination) clock = pygame.time.Clock() @@ -733,27 +733,28 @@ def game_loop(args): control.manual_gear_shift = False world.player.apply_control(control) else: - agent.update_information() + #agent.update_information() world.tick(clock) world.render(display) pygame.display.flip() # Set new destination when target has been reached - if len(agent.get_local_planner().waypoints_queue) < num_min_waypoints and args.loop: - agent.reroute(spawn_points) - tot_target_reached += 1 - world.hud.notification("The target has been reached " + - str(tot_target_reached) + " times.", seconds=4.0) - - elif len(agent.get_local_planner().waypoints_queue) == 0 and not args.loop: - print("Target reached, mission accomplished...") - break + #if len(agent.get_local_planner().waypoints_queue) < num_min_waypoints and args.loop: + # agent.reroute(spawn_points) + # tot_target_reached += 1 + # world.hud.notification("The target has been reached " + + # str(tot_target_reached) + " times.", seconds=4.0) + + #elif len(agent.get_local_planner().waypoints_queue) == 0 and not args.loop: + # print("Target reached, mission accomplished...") + # break speed_limit = world.player.get_speed_limit() agent.get_local_planner().set_speed(speed_limit) control = agent.run_step() + print(f"Throttle: {control.throttle}, Steer: {control.steer}, Brake: {control.brake}") # 添加这行 world.player.apply_control(control) finally: @@ -843,4 +844,4 @@ def main(): if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/src/carla_traffic_light/requirements.txt b/src/carla_traffic_light/requirements.txt index 57c1429743..ba632b7ae3 100644 --- a/src/carla_traffic_light/requirements.txt +++ b/src/carla_traffic_light/requirements.txt @@ -1,11 +1,9 @@ requirements file: -carla==0.9.11 +carla==0.9.15 pygame==2.1.0 -numpy==1.23.5 +numpy==1.21.6 opencv-python==4.8.0.76 -matplotlib==3.7.1 -torch==2.0.0 # Only if you're using PyTorch for detection -torchvision==0.15.1 +matplotlib==3.5.3 Pillow==9.4.0