Skip to main content

Attempt of Drone Swarm

· 2 min read

Configure settings.json file

Microsoft's documentation on Multi Vehicles

Configure the following fields in settings.json

  "Vehicles": {
"UAV1": {
"VehicleType": "SimpleFlight",
"X": 0,
"Y": 0,
"Z": 0,
"Yaw": 0
},
"UAV2": {
"VehicleType": "SimpleFlight",
"X": 2,
"Y": 0,
"Z": 0,
"Yaw": 0
},
"UAV3": {
"VehicleType": "SimpleFlight",
"X": -2,
"Y": 0,
"Z": 0,
"Yaw": 0
}
}

Get the list of drones in Python

drones = client.listVehicles()

As the drone swarm needs to operate collaboratively, we cannot use .join() method on all actions as in the previous sections. If we do so, the drones will perform actions one by one. However, if none of the drones have the .join() method, the subsequent actions will not run properly.

Here is the solution I came up with:

Check if it is the last drone, then add it to the Future class, so that all subsequent actions will wait for it to finish before proceeding.

for i in drones:
print(drones)
if i == drones[-1]:
client.takeoffAsync(vehicle_name=i).join()
else:
client.takeoffAsync(vehicle_name=i)

Now it's moving

Let's dive into the passion of NieR: Automata and make a thrilling purchase directly.

info

This Content is generated by ChatGPT and might be wrong / incomplete, refer to Chinese version if you find something wrong.

Loading Comments...