我在运行官方示例时遇到了Traffic-Manager端口占用问题导致无法生成交通流,具体报错如下:
EN: When I run the official example, I encountered a Traffic-Manager port occupation issue that prevents traffic generation. The specific error message is as follows:
X:\OpenCDA>python opencda.py -t platoon_stability_2lanefree_carla -v 0.9.12
OpenCDA Version: 0.1.3
load opendrive map '2lane_freeway_simplified.xodr'.
Creating platoons/
Spawning CARLA traffic flow.
Traceback (most recent call last):
File "X:\OpenCDA\opencda\scenario_testing\platoon_stability_2lanefree_carla.py", line 44, in run_scenario
scenario_manager.create_traffic_carla()
File "X:\OpenCDA\opencda\scenario_testing\utils\sim_api.py", line 586, in create_traffic_carla
tm = self.client.get_trafficmanager()
RuntimeError: trying to create rpc server for traffic manager; but the system failed to create because of bind error.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "opencda.py", line 59, in <module>
main()
File "opencda.py", line 54, in main
scenario_runner(opt, config_yaml)
File "X:\OpenCDA\opencda\scenario_testing\platoon_stability_2lanefree_carla.py", line 161, in run_scenario
eval_manager.evaluate()
UnboundLocalError: local variable 'eval_manager' referenced before assignment
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 99 (sensor.other.gnss)
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 100 (sensor.other.imu)
......
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 97 (sensor.other.imu)
原因是我本地电脑的8000端口被httpd占用,我将 "X:\OpenCDA\opencda\scenario_testing\utils\sim_api.py" 中第 714 行 create_traffic_carla 函数的 tm = self.client.get_trafficmanager() 改为 tm = self.client.get_trafficmanager(2004) 将TM指定到空闲端口(2004)后,再将该文件中 vehicle.set_autopilot(True, 8000) 写入的端口8000全部改为2004,示例代码才得以正常运行。
建议在配置文件中新增 tm-port 选项以避免端口被占用情况;以及在 sim_api.py 中自动获取 self.client.get_trafficmanager() 设置的TM端口变量,用到 vehicle.set_autopilot() 等需要使用端口进行通信的函数中,以便适配端口更改。
EN: The reason is that the 8000 port on my local computer is occupied by httpd. I changed the line 714 in the file "X:\OpenCDA\opencda\scenario_testing\utils\sim_api.py" where the function create_traffic_carla calls tm = self.client.get_trafficmanager() to tm = self.client.get_trafficmanager(2004), specifying the TM to an unoccupied port (2004). Then, I changed all instances of the port 8000 written as vehicle.set_autopilot(True, 8000) in the same file to 2004. Only after these changes could the sample code run normally.
It is recommended to add a new option tm-port in the configuration file to avoid port occupation; and automatically obtain the TM port variable set by self.client.get_trafficmanager() in sim_api.py. This will be used in functions such as vehicle.set_autopilot() that require communication through ports, so as to adapt to changes in ports.
我在运行官方示例时遇到了Traffic-Manager端口占用问题导致无法生成交通流,具体报错如下:
原因是我本地电脑的8000端口被httpd占用,我将
"X:\OpenCDA\opencda\scenario_testing\utils\sim_api.py"中第 714 行create_traffic_carla函数的tm = self.client.get_trafficmanager()改为tm = self.client.get_trafficmanager(2004)将TM指定到空闲端口(2004)后,再将该文件中vehicle.set_autopilot(True, 8000)写入的端口8000全部改为2004,示例代码才得以正常运行。建议在配置文件中新增 tm-port 选项以避免端口被占用情况;以及在
sim_api.py中自动获取self.client.get_trafficmanager()设置的TM端口变量,用到vehicle.set_autopilot()等需要使用端口进行通信的函数中,以便适配端口更改。