Hello,
I have having trouble connecting my RPi 4b flight computer to my flight controller (Durandal).
I have the two hooked up, USB to telem2.
I am able to connect with mavproxy.py, the result below:
mavproxy.py --master=/dev/ttyUSB0
WARNING: You should uninstall ModemManager as it conflicts with APM and Pixhawk
Connect /dev/ttyUSB0 source_system=255
Log Directory:
Telemetry log: mav.tlog
Waiting for heartbeat from /dev/ttyUSB0
MAV> Detected vehicle 1:1 on link 0
online system 1
STABILIZE> Mode STABILIZE
But I am unable to connect via the script, shown below w/ the two results i get when i run it. I am following this tutorial: https://youtu.be/kB9YyG2V-nA?si=yLeRNNe18kvbsmEs
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 = 57600
vehicle = connect(connection_string, baud_rate, wait_ready = True)
return vehicle
def arm():
while vehicle.is_armable == false:
print("waiting for vehicle to be able to be armed")
time.sleep(1)
print("yayyy arming ready!!!!")
print(" ")
vehicle.armed = True
while vehicle.armed == false:
print("gimme a sec...")
time.sleep(5)
print("vehicle is now armed lol")
print("lol move before you get hit haha")
return None
############################
vehicle = connectMyCopter()
arm()
print("end of script :3")
team2026@raspberrypi:~/Desktop $ python testConnect.py --connect /dev/ttyUSB0
Traceback (most recent call last):
File "/home/team2026/Desktop/testConnect.py", line 43, in <module>
vehicle = connectMyCopter()
File "/home/team2026/Desktop/testConnect.py", line 19, in connectMyCopter
vehicle = connect(connection_string, baud_rate, wait_ready = True)
File "/home/team2026/.local/lib/python3.9/site-packages/dronekit/__init__.py", line 3166, in connect
vehicle.initialize(rate=rate, heartbeat_timeout=heartbeat_timeout)
File "/home/team2026/.local/lib/python3.9/site-packages/dronekit/__init__.py", line 2275, in initialize
raise APIException('Timeout in initializing connection.')
dronekit.APIException: Timeout in initializing connection.
team2026@raspberrypi:~/Desktop $ python testConnect.py --connect /dev/ttyUSB0
WARNING:dronekit:Link timeout, no heartbeat in last 5 seconds
Traceback (most recent call last):
File "/home/team2026/Desktop/testConnect.py", line 43, in <module>
vehicle = connectMyCopter()
File "/home/team2026/Desktop/testConnect.py", line 19, in connectMyCopter
vehicle = connect(connection_string, baud_rate, wait_ready = True)
File "/home/team2026/.local/lib/python3.9/site-packages/dronekit/__init__.py", line 3166, in connect
vehicle.initialize(rate=rate, heartbeat_timeout=heartbeat_timeout)
File "/home/team2026/.local/lib/python3.9/site-packages/dronekit/__init__.py", line 2275, in initialize
raise APIException('Timeout in initializing connection.')
dronekit.APIException: Timeout in initializing connection.
I’m not sure what I’m doing wrong, any ideas?