Reputation: 1
I downloaded the Carla simulator to my Windows PC and I am trying to link Carla real engine to python but I am not sure how. I want to be able to locate vehicles using python. How do we access the interface in python? Thank you!
Upvotes: 0
Views: 1196
Reputation: 195
So you need to launch CARLA and connect to a client then integrate the API...
First, launch CARLA via command line using the executable in (Windows version)
cd /carla/root
./CarlaUE4.sh
You are going to the file directory then running the engine
To use CARLA through the python API, you need to connect the Python client to the server through a port so you can connect and control the simulation
import Carla
# Connecting to a client and retrieving the world object
client = carla.Client('localhost', 2000)
world = client.get_world()
The client object is just the instance of the client connection to the server which you would use to load functions
In your case, if you want to mind all the vehicles in the simulation using the world.get_actors() method, you can filter out vehicles and use the set_autopilot() method to control the vehicle to the traffic manager
for vehicle in world.get_actors().filter('vehicle'):
vehicle.set_autopilot(true)
Upvotes: 1