microsoft / AirSim

Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
https://microsoft.github.io/AirSim/
Other
16.41k stars 4.57k forks source link

Multiple Drones example doesnt work properly #1255

Open Edelbert opened 6 years ago

Edelbert commented 6 years ago

Python and C++ multi drones examples behave strange. Example of C++ code for 2 drones (I just modified original "hellodrone" example):

        std::cout << "Press Enter to arm the drone" << std::endl; std::cin.get();
        client.enableApiControl(true, "Drone1");
        client.armDisarm(true, "Drone1");

        client.enableApiControl(true, "Drone2");
        client.armDisarm(true, "Drone2");

        std::cout << "Press Enter to takeoff" << std::endl; std::cin.get();
        float takeoffTimeout = 5; 
        client.takeoffAsync(takeoffTimeout, "Drone2")->waitOnLastTask();
        client.takeoffAsync(takeoffTimeout, "Drone1")->waitOnLastTask();

Result:

Waiting for connection - 
Connected!

Client Ver:1 (Min Req:1), Server Ver:1 (Min Req:1)
Press Enter to get FPV image

# of images received: 2
Enter path with ending separator to save images (leave empty for no save)

Image uint8 size: 41733
Image float size: 0
Image uint8 size: 0
Image float size: 36864
Press Enter to arm the drone

Press Enter to takeoff

Exception raised by the API, something went wrong.
rpclib: function 'takeoff' (called with 2 arg(s)) threw an exception. The exception contained this information: Cannot perform takeoff because vehicle is already moving with velocity 0.585877 m/s.

I managed to make them taking off only one by one.

Python API sometimes works, sometimes doesnt. When it works, drones are taking off simultaneously and everything is fine, when it doesnt, the second drone doesnt take off, and program doesnt responding. Trace after interruption:

^CTraceback (most recent call last):
  File "PythonClient/multirotor/multi_agent_drone.py", line 57, in <module>
    f1.join()
  File "/anaconda3/lib/python3.6/site-packages/msgpackrpc/future.py", line 22, in join
    self._loop.start()
  File "/anaconda3/lib/python3.6/site-packages/msgpackrpc/loop.py", line 22, in start
    self._ioloop.start()
  File "/anaconda3/lib/python3.6/site-packages/tornado/ioloop.py", line 863, in start
    event_pairs = self._impl.poll(poll_timeout)
KeyboardInterrupt

But "moveToPositionAsync" works fine for both C++ and Python API. Info: UE4.19.2, ubuntu 16.04, AirSim (latest master).

AloshkaD commented 6 years ago

I'm having the same issue.