Drone Client not working for multiple drones in Matlab #32
-
I want to move two drones, but it seems that only the second drone (the later for which client is defined) responds to any API calls. Here's my Matlab code: % Define client for Evader and Pursuer drones % Create instances of AirSimClient for both drone % Take off both drones % Set initial positions (example coordinates) % Land both drones after chase is complete This is settings.json: { "Vehicles": { Only Drone2 responds to any API calls, Drone1 does not even takes off or enters hover mode. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I will look into this for a future release. Thank you. |
Beta Was this translation helpful? Give feedback.
-
I got it to work now (see commit) with some slightly updated and fixed matlab code as well. I will look into implementing some form of .join() as well for matlab and make a new release client for matlab once that is implemented and let you know. evader_name = "Drone1"; % Evader
pursuer_name = "Drone2"; % Pursuer
airSimClient = AirSimClient(IsDrone=true, IP="127.0.0.1", port=41451);
airSimClient.setEnableApiControl("Drone1");
airSimClient.setEnableApiControl("Drone2");
airSimClient.takeoffAsync("Drone1");
airSimClient.takeoffAsync("Drone2");
airSimClient.moveToPositionAsync(10, 10, -10, 5, 3e+38, AirSimDrivetrainTypes.MaxDegreeOfFreedom, true, 0, -1, 1, "Drone1"); % Evader moves to (0, 0, -10)
airSimClient.moveToPositionAsync(10, 14, -10, 5, 3e+38, AirSimDrivetrainTypes.MaxDegreeOfFreedom, true, 0, -1, 1, "Drone2"); % Pursuer starts at (5, 5, -10)
airSimClient.landAsync("Drone1", 360);
airSimClient.landAsync("Drone2", 360); |
Beta Was this translation helpful? Give feedback.
That is expected as you would need to use the matlab toolbox from source to see the changes reflected, I had not updated the toolbox itself at that time, just the code.
I have now pushed a new toolbox build 3.1.0 to file exchange.
This includes the previous mentioned fixes as well as the option to do something similar as .join() in Python by setting the join of the async functions to true to wait for function completion.
This new build also updates the example code and adds a new example for two drones: