carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
10.79k stars 3.47k forks source link

set_autopilot() error in carla0.9.15 #7803

Open ccconquer opened 1 week ago

ccconquer commented 1 week ago

I searched for information online, and some people suggested that the default port 8000 might be occupied. However, I tried many different ports and still encountered the error. What could be causing the error 'RuntimeError: trying to create rpc server for traffic manager; but the system failed to create because of bind error'?

Traceback (most recent call last): File "/mnt/home/zhuyanting/CARLA_0.9.15/PythonAPI/202404/0425BaseAPI.py", line 106, in main() File "/mnt/home/zhuyanting/CARLA_0.9.15/PythonAPI/202404/0425BaseAPI.py", line 52, in main ego_vehicle.set_autopilot(True, 2002) RuntimeError: trying to create rpc server for traffic manager; but the system failed to create because of bind error.

屏幕截图 2024-06-18 203513
GoodarzMehr commented 1 week ago

Are you creating the traffic manager and setting it to use port 2002 (which you are using for autopilot)? Are you using the synchronous mode?

You should try to provide your code, or the piece that's causing the error. Otherwise the answers you get here may not be helpful because nobody knows what you're doing. This time I found it in your repo, and you need to first create the traffic manager using

tm = client.get_trafficmanager(port)

The port is 8000 by default, but if you want to use 2002 here you can set the port to that.

ccconquer commented 1 week ago

Thanks!! No, i didn't use synchronous mode and traffic manager. Do set_autopilot() only work in synchronous mode and must have a traffic manager?

GoodarzMehr commented 1 week ago

Yes, you need to create a Traffic Manager so it can control vehicles autonomously. You can read more about the Traffic Manager here.

glopezdiest commented 1 week ago

@GoodarzMehr @ccconquer No, the TrafficManager is created automatically once the first vehicle is registered to it, unless you actually call the tm = client.get_trafficmanager(port) first. You can just create a vehicle and use the set_autopilot(), and it won't cause any issues. Also, it doesn't matter if the simulation is synchronous or not. An asycnhronous TM will have a worse behavior, but it will not crash.

From what I understand, you tried doing the set_autopilot() without any port first, which used the default 8000 and that crashed? And what are you doing in the script apart from running the TM?

GoodarzMehr commented 1 week ago

@GoodarzMehr @ccconquer No, the TrafficManager is created automatically once the first vehicle is registered to it, unless you actually call the tm = client.get_trafficmanager(port) first. You can just create a vehicle and use the set_autopilot(), and it won't cause any issues.

Sorry, didn't know that. I had always seen the TM created before setting the autopilot in the examples so I assumed it was a requirement.