Connect() Link timeout, no heartbeat in last 5 seconds


#1

I am new to drone programming, I try running takeoff-and-land.py and method connect(connect-string, wait_ready=True, baud=57600) give me warning
Link timeout, no heartbeat in last 5 seconds following with dronekit.APIException: No heartbeat in 30 seconds, aborting.

the command is python3 takeoff-and-land.py --connect=’/dev/ttyAMA0’

I am using raspberry pi 3 B and Navio2. Mission Planer is able to connect to drone using com3.

I installed python3.5 and dronekit-2.9.1.

thanks a lot in advance!


#2

Try replacing “ttyAMA0” with “Serial0” and see if it helps.


#3

replacing’ ttyAMA0’ with ‘serial0’ same problem, thanks.


#4

Hi there Amy!

Try running the takeoff_and_land.py with python instead of python3. I believe most of the dronekit side dependencies still operate with python2 primarily.


#5

thanks, I will try. Is there any other drone SDK available which is frequently released and compatible with new version of python? thanks.


#6

Hey Amy, did you end up solving this problem by running it with python2?


#7

I’m having this connect() link timeout problem too when I try to run even the simplest dronekit example on my real drone. I assume there is something simple that I’m not understanding. This is what I’m trying to do:

  • SSH into the drone
  • execute python connection_template.py --connect 127.0.0.1:14550

This is a screen capture of this after increasing the time out to 180 seconds

python connection_template.py --connect 127.0.0.1:14550

Link timeout, no heartbeat in last 5 seconds
…link restored.
Link timeout, no heartbeat in last 5 seconds
…link restored.
Link timeout, no heartbeat in last 5 seconds
…link restored.
Link timeout, no heartbeat in last 5 seconds
…link restored.
Link timeout, no heartbeat in last 5 seconds
Traceback (most recent call last):
File “connection_template.py”, line 29, in
vehicle = connectMyCopter()
File “connection_template.py”, line 23, in connectMyCopter
vehicle = connect(connection_string, wait_ready=True, heartbeat_timeout=180)
File “/home/pi/.local/lib/python2.7/site-packages/dronekit/init.py”, line 2849, in connect
vehicle.wait_ready(True)
File “/home/pi/.local/lib/python2.7/site-packages/dronekit/init.py”, line 2199, in wait_ready
timeout)
dronekit.APIException: wait_ready experienced a timeout after 30 seconds.

For what it’s worth:
This drone flies fine using the RC control and Mission planner
it’s a Pi 4 running the latest Emlid build
All the examples stall in the connect call but run fine in the SITL development environment.
It’s setup as a remote AP and connected over wifi

Initially I thought I was using the wrong ip address and port combo but by increasing the heartbeat timeout to 180 seconds in the Dronekit connect method resulted in a series of “link restored.” messages.

Any help would be appreciated.
Thanks,
Dave


#8

Problem Solved – Ok, I solved this problem by pulling the master branch from the repository and building it locally. I then set my locally built arducopter image to be ardupilot firmware controlled by the service as described in the Emlid documentation. Dronekit Vehicle.connect methods no longer timeout. Life is good.


#9

Would you be able to go more in depth on how you accomplished this? I’m pretty new to this and I’m not sure what all of that means exactly. Glad to hear you got it solved!!


#10

Are you running into a timeout problem in your Dronecode python scripts? Not all folks seem to be experiencing this problem. I am running on a Raspberry Pi 4 and that may be a factor. In any case the folks at Emlid indicated that they were in the process of updating their preconfigured release from the mainline source. If this has been completed this would be the best way to go as you would probably pick up other fixes made since last fall.


#11

If you find that the Emlid folks are still distributing a binary from last fall here are my notes of the steps needed to build your own. This assumes you Pi is set up correctly. I’ve been able to do all this with the Pi running off the external power without the battery. Obviously the Pi will need to be able to access the internet to retrieve the source from the git repository. The good news is you don’t need to make ANY software changes and more details on how to do this can be found in the docs in much greater detail. I would suggest you use one of the python scripts that only retrieve attributes to test if you end up using the correct build that doesn’t timeout. This approach doesn’t remove the previously installed service “firmware” it just builds another in your chosen directory and systemctl will start that instead. Once you have the modified service being used, your test python script will successfully retrieve the attributes without timing out. Then disable the original to prevent systemctl reverting to using the original “arducopter” service after a reboot. I found it confusing the new service is called “ardupilot”. To check type, sudo systemctl is-enabled arducopter if it returns true type sudo systemctl diable arducopter. You will need to learn about the systemctl commands.

• On Raspberry Pi in pi user home directory
• Create a directory
• git clone -b Copter-4.0.3 https://github.com/ardupilot/ardupilot
	○ Or use a different branch
• cd ardupilot
• git submodule update --init --recursive
• ./waf list_boards
• ./waf configure --board=navio2 --debug
	○ --debug optional
• ./waf --targets bin/arducopter
• Executable arducopter in ~/src/???/ardupilot/build/navio2/bin/arducopter
• To use this custom binary
• Note this doesn't remove the existing/installed verson but I suppose you could take that route too
	○ modify /etc/systemd/system/ardupilot.service to point to the version you've built (uncomment execution)
	○ Add options to /etc/default/ardupilot for ARDUPILOT_OPTS
	○ Use systemctl to start the modified ardupilot service
		§ pi@navio: ~ sudo systemctl start ardupilot && sudo systemctl enable ardupilot

#12

Wow thank you so much for the response! I’ve finished the ./waf --targets bin/arducopter part of the process but I’m not seeing an executeable there. Is there something you want me to make with the file title ‘ap_config.h’?


#13

I tried following these steps, but I still get a no heartbeat error. Occasionally the script sort of runs with the heartbeat error, but it never gets armed. Can someone help me fix my error? I am using a rpi4 with a navio2 autopilot for a copter build. Thanks


#14

Hi there Ankith!

I am working with the Emlid team and they have said they are working on a fix and hope to be releasing it soon.

If pulling the latest AC-4* does not work, it appears that AC version “Copter-3.5.5” works great on the Navio2 still. Timeout issues are gone. Timeout issues seemed to exist on every ArduCopter in the 3.6’s

Could you try:

  1. Cloning this from ArduPilot github with
    git clone -b Copter-3.5.5 https://github.com/ardupilot/ardupilot

  2. and then following the ardupilot firmware installation instruction on Emlid at this link
    under the header “Launching a custom ArduPilot binary”

If it does not compile for you, let me know. I can make the AC-3.5.5 available on a google drive so that it may be downloaded and setup on your raspberry pi.


#15

I’m having a problem replacing this firmware as it’s telling me it already exists. What should I do to override this? Thanks for the tip, by the way, I’m hoping it works!


#16

It is giving me this error if this helps:

fatal: destination path ‘ardupilot’ already exists and is not an empty directory


#17

Nevermind I just figured out how to empty the whole thing and clone the version you had listed. Thanks again!


#18

Awesome, good to hear! Let me know if it works!


#19

Is anyone still having issues with dronekit connections? Just purchased the navio2 and have absolutely no issues. I just want to make sure a connection issue wouldn’t occur after x minutes of flying. I’ve run a few dronekit scripts in the field and haven’t had any issues, but found multiple threads on dronekit connection issues.

In the latest course, the following is mentionned:

"AC-3.6.*

Any arducopter version in the 3.6’s (EX: 3.6.9) does not at this point allow dronekit communication. Occasional connections may arise for a few seconds, but most of the time you will experience timeout errors.

This is unfortunate as the current image of Navio2 comes pre-compiled with AC-3.6.*

So you will have to compile your own ardupilot code regardless if you intend to fly the drone with dronekit."

With the latest version of dronkit (2.9.2) and Arducopter 3.6.11, I’m not experiencing any issues. Is the course material misleading, or have I simply not reproduced the error yet?

Thanks!


#20

Hi there @PhotonJon!

Can you confirm that dronekit scripts are working on your build with 3.6.11? If so, really glad to hear you can connect!

I previously thought the dronekit timeout/communication issue occurs on all builds with AC-3.6.*, but if you can connect it appears there is a set of unknown pre-conditions that produces the dronekit timeout error. Perhaps there was a bad batch of Navio2 boards? I am not sure.

The connection/timeout issue has come up quite often, and goes away when switching to AC-4.0.* (there appears to be other issues with AC-4.0.) or AC 3.5..

I will keep closely monitoring this issue and change the authoritative verbiage on this course note on AC-3.6*, from it “will not work” to “it may work”.