Hello,
I have an issue controlling multiple vehicles using Python APIs.
Here are my specs:
-UE 4.24.3, VS2019, Python 3.7, Windows 10
I looked through this documentation https://microsoft.github.io/AirSim/multi_vehicle/ to pilot multiple cars as well as run a simple script in the image below. I can get multiple cars to spawn, however only the first vehicle responds to API commands.
Here is an image of my code and simulation environment:
Here is my settings.json file:
From what I can only assume, the simulator is able to identify multiple vehicles, but I am not quite sure why the second vehicle is not responding.
How am I able to use APIs to control multiple vehicles?
Thank you
So I took a look in to the Issues within the repository and tried/noticed a few things:
{
"SettingsVersion": 1.2,
"SimMode": "Car",
"Vehicles": {
"Car1": {
"VehicleType": "PhysXCar",
"ApiServerPort": 41451
},
"Car2": {
"VehicleType": "PhysXCar",
"X": -5,
"Y": -4,
"Z": 0,
"ApiServerPort": 41452
}
}
}@InfraredLaser Sharing in case you need swarmControl.py
Thank you @buribae for the file PATH. I also took a look at the sample code for both car and drone above yet only the first vehicle is able to move with API's.
Ahhh silly me, after running the car file above yet again both vehicles suddenly moved with API's!
I took a look of the example code that I was running and compared it with the above code and it turns out that in my code I did not add the car name as a parameter in the setCarControls function, so only the first vehicle was responding to API commands.
This is the proper notation for setting the controls for a second vehicle and possible more.
client.setCarControls(car_controls_2, "Car2")
Now at least both of them can move! Thank you @buribae for the help!