MAVSDK icon indicating copy to clipboard operation
MAVSDK copied to clipboard

Getting "timeout" issue while uploading mission on PixHawk (PX4) via MAVSDK

Open bb17pugc opened this issue 4 years ago • 24 comments

Hi, I am using MAVSDK to upload mission from terminal to my PixHawk 4 (PX4) via telemetry. Sometimes it works like a charm and sometime it give the "timout" error and stops.

Can someone please tell the fix for this issue? I tired to go into the file and updated the timeout value from "none" to "50" but it didn't worked. Same issue, sometimes it work and sometimes not work.

Complete code file is attached here. (due to editor restriction, changed the extension from ".py" to ".txt"). I am using Ubuntu 20.04

image

mission.txt

bb17pugc avatar Feb 10 '21 09:02 bb17pugc

Your code looks all fine to me.

I'm suspecting a problem with the connection. Are you using a radio or a direct FTDI cable? And which PX4 version are you using?

Maybe we could resolve this by just increasing the timeout or making it configurable.

julianoes avatar Feb 10 '21 09:02 julianoes

I am using the FTDI Cable to connect the Telemetry with my laptop. Telemetry: RFD900+

PX4 Version: 1.11 Where we can increase that time and what is the unit (sec/msec) of time to increase?

bb17pugc avatar Feb 10 '21 15:02 bb17pugc

Ok, and is the upload working when the drone is close, and presumably the connection is good?

julianoes avatar Feb 10 '21 17:02 julianoes

The timeout is set in https://github.com/mavlink/MAVSDK/blob/855a4b5d1e7c13a601781792f25dc5fe08ff5ae3/src/core/mavlink_mission_transfer.h#L248 so you would have to rebuild mavsdk_server yourself.

julianoes avatar Feb 10 '21 17:02 julianoes

Ok, and is the upload working when the drone is close, and presumably the connection is good?

Drone is at about 3-4 feet from the GCS telemetry. Even then the problem is coming. Sometime it works with the 200+ mission items, and sometimes it didn't work even with the 5 mission items.

I will try the change in timeout and then let you know the feedback. Thank you. What is the unit of time we are giving? Is this seconds or something else?

bb17pugc avatar Feb 11 '21 07:02 bb17pugc

It's seconds there. Are you rebuilding mavsdk_server yourself already?

julianoes avatar Feb 11 '21 08:02 julianoes

It's seconds there. Are you rebuilding mavsdk_server yourself already?

Yes, I am on it as you directed, but not doing anything before. But getting problems while building that. I am using this guide to build that with our timeout changes.

bb17pugc avatar Feb 11 '21 11:02 bb17pugc

What architecture are you on? I can build a binary and upload that for you.

julianoes avatar Feb 12 '21 09:02 julianoes

What architecture are you on? I can build a binary and upload that for you.

That will be great if you can please do this favour.

I am using Ubuntu 20.04 for doing all this.

MuhammadBilal1 avatar Feb 12 '21 10:02 MuhammadBilal1

That's x86-64? That should actually be fairly straightforward to build then, just do:

cmake -Bbuild/default -DBUILD_MAVSDK_SERVER=ON -DSUPERBUILD=ON .
cmake --build build/default -j8

julianoes avatar Feb 12 '21 12:02 julianoes

I am using x64.

MuhammadBilal1 avatar Feb 12 '21 12:02 MuhammadBilal1

mavsdk_server.zip

try this

julianoes avatar Feb 12 '21 13:02 julianoes

Where I put this file?

mavsdk_server.zip

try this

Where I put this file?

MuhammadBilal1 avatar Feb 12 '21 14:02 MuhammadBilal1

You have to run it with:

./mavsdk_server -p 50051 serial:///dev/ttyUSB0:57600

And then in your script you have to use:

drone = System(mavsdk_server_address="localhost", port=50051)
await drone.connect()

The script and the binary have to run on the same machine.

Basically, you are manually starting the mavsdk_server instead of having it auto-started by the Python script.

More info here: http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/

Running it separate like that should also give you a bit more debug output.

julianoes avatar Feb 12 '21 14:02 julianoes

so give you a bit more debug output

I tried to follow the instructions you gave, and attached are the results. So far no success in running the operation.

Screenshot from 2021-02-16 19-12-49 Screenshot from 2021-02-16 19-14-08 Screenshot from 2021-02-16 19-14-48

MuhammadBilal1 avatar Feb 16 '21 14:02 MuhammadBilal1

Hm, I can see how it looks busy because it's trying to get several parameters, etc. all at startup. Does it work better if you wait a couple of seconds until these things have stabilized before trying to upload a mission?

julianoes avatar Feb 16 '21 16:02 julianoes

@MuhammadBilal1 @bb17pugc were you able to resolve this?

I'm planning to add a parameter for overall mavsdk to set the timeout.

julianoes avatar Mar 17 '21 08:03 julianoes

@MuhammadBilal1 @bb17pugc were you able to resolve this?

I'm planning to add a parameter for overall mavsdk to set the timeout.

No, I wasn't able to resolve this issue. Adding the parameter will be helpful. Thank you. I will be waiting :-)

MuhammadBilal1 avatar Mar 17 '21 16:03 MuhammadBilal1

@MuhammadBilal1 see #1362

julianoes avatar Mar 18 '21 09:03 julianoes

Hi, I'm getting the same issue while connecting with a USB antenna (serial connection). When uploading a mission with more than two mission items, it times out almost immediately. I tried setting the timeout value to "2" or "5" but I get the same result. I also tried using the MAVSDK-Python project example mission.py and it times out (however, if I send only one or two mission items, it works).
I also tried connecting to the drone using a wifi hotspot and uploading a mission (using tcp). Using that setup, the timeout issue does not occur.

MAVSDK-Python: 0.19.0 PX4: 1.11.3 Python: 3.8.10 Drone connection: USB Antenna Ubuntu: 20.04

    await drone.connect(system_address="serial:///dev/ttyUSB0:57600")
    await drone.core.set_mavlink_timeout(2)
  File "/home/xgl-gs1/xguardlabs-uav-controller/mission_test.py", line 129, in run
    await drone.mission.upload_mission(mission_plan)
  File "/home/xgl-gs1/xguardlabs-uav-controller/venv/lib/python3.8/site-packages/mavsdk/mission.py", line 707, in upload_mission
    raise MissionError(result, "upload_mission()", mission_plan)
mavsdk.mission.MissionError: TIMEOUT: 'Timeout'; origin: upload_mission(); params: (<mavsdk.mission.MissionPlan object at 0x7f2d36405460>,)

philippecloutiermathura avatar Aug 12 '21 12:08 philippecloutiermathura

There have been some improvements in the latest version of mavsdk (coming with MAVSDK-C++ 0.42.0), and also in PX4. I think it will be worth testing again with those versions when they are out.

JonasVautherin avatar Aug 14 '21 14:08 JonasVautherin

Thank you for the suggestion, I will try again when a more recent version of MAVSDK-Python is available. Correct me if I am wrong, but I think the current MAVSDK-Python 0.19.0 (released july 23) does not contain the changes from MAVSDK-C++ 0.42.0 (released august 6) . I will also try updating my PX4 version.

philippecloutiermathura avatar Aug 20 '21 17:08 philippecloutiermathura

If you have troubles uploading missions, you might also want to try this: https://github.com/PX4/PX4-Autopilot/issues/18082

julianoes avatar Aug 30 '21 09:08 julianoes

I experienced such timeouts too, also with the RFD900 (RFD868 in Europe). What I experienced is that the link is - at least on the desk - very slow when the long antennas are used on both sides. When I started using the short antennas on one side of the link, the speed was as expected. Nothing to do with MAVSDK or so (I had similar issues with QGC)

reedev avatar Feb 14 '22 16:02 reedev