Am getting this warning message every time I try to run my python code.
This is my script on my raspberry pi:
from dronekit import connect, VehicleMode, LocationGlobalRelative, APIException
parser = argparse.ArgumentParser(description="commands")
vehicle = connect(connection_string,baud_rate,wait_ready=True)
while vehicle.is_armable == False:
vehicle.armed = True
while vehicle.armed == False:
print("Waiting to become armed")
print("Vehicle is now armed")
vehicle = connectMyCopter()
print("End of Script")
Then I run the command:
python arm_test.py --connect=/dev/ttyAMA0
and this is what I get on the terminal:
WARNING:dronekit:Link timeout, no heartbeat in last 5 seconds
ERROR:dronekit.mavlink:Exception in MAVLink input loop
and then a traceback showing that a
dronekit.APIException('Timeout in initializing connection')
I have tested my pixhawk on the mission planner simulator and it was working fine.
I also tried running the following command on the raspberry pi terminal
and it works! it allows me to connect to the pixhawk and run commands through the command line
Can anyone help me please
Does the below work?
vehicle = dronekit.connect(ip="/dev/ttyAMA0", baud=921600, wait_ready=True)
Still same warning message
I’ve looked at this code and they also have the same warning log, but on their example, the exception is not raised and the code somehow still works at the end.
This should work. It is bare minimum.
Probably it is about serial device permissions or you’re setting the baud rate or connection string wrong.
Take a close look.
You are using python 2 or python 3? Try the latter and remove ‘Exceptions’.
ok, I’ll look into that thank you!
I was using python 2, should I use python 3? It says on the dronekit guide that python3 is not supported
at the end of this page ^
I’m not really certain why it is not working if you set it up for python 2 , but I’ve moved on to a python 3 configuration. Perhaps you can try an earlier version of ardupilot (eg, 4.07).
As mentioned by @Mustafa_Gokce, there are a number of reasons that can account for a bad link, but mavproxy seems to work for you.
I’ve written a blog on this subject.
On the raspberry:
Go in /boot/config.txt and add the following near the end of the file. There should be some other dtoverlays, just put it under those.
go into raspi-config and enable uart
The first disables bluetooth that uses uart channel the second enables uart and disables serial console.
Thank you, guys! it worked! What did was I rebooted my raspberry pi, reinstalled all the libraries (this time I used python 3 instead of python 2. I also changed the variable SERIAL2_BAUD to 921 using the mission planner, just as depicted here Communicating with Raspberry Pi via MAVLink — Dev documentation. I also did what @Corrado_Steri just said about the disable-bt
I do have another problem now (same error message) but this time it is related to the dronekit-sitl so I am just gonna open another discussion.
Thank you, guys! it also worked! I have the same issue with you. however for me I can not use python 3 instead of python 2. I just changed the variable SERIAL2_BAUD to 921 using the mission planner, just as depicted at Communicating with Raspberry Pi via MAVLink — Dev documentation , and thank for jack douglas for sending recommended tecniques to me.
Thank you so much for @jax200