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
import time
import socket
import exceptions
import math
import argparse
def connectMyCopter():
parser = argparse.ArgumentParser(description="commands")
parser.add_argument("--connect")
args=parser.parse_args()
connection_string=args.connect
baud_rate=921600
vehicle = connect(connection_string,baud_rate,wait_ready=True)
return vehicle
def arm():
while vehicle.is_armable == False:
print("Waiting")
timer.sleep(1)
vehicle.armed = True
while vehicle.armed == False:
print("Waiting to become armed")
print("Vehicle is now armed")
vehicle = connectMyCopter()
arm()
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')
was raised.
Note:
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
mavproxy.py --master=/dev/ttyAMA0
and it works! it allows me to connect to the pixhawk and run commands through the command line
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.
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.
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
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.