Ardupilot connection with RPi fail

Raspberrypi running ubuntu 22.04, connected with CUAVv5 Nano running Ardupilot 4.5.5 (lastest stable).
While connecting the RPi with Pix the mavproxy worked in both Serial and UDP while on the same comm link, I executed the file attached here too. Any help to execute on quad?
Also previously it displayed as waiting for arming.

Heres the code

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=baud_rate, wait_ready=True)
return vehicle

def arm():
#vehicle.channels.overrides[‘4’] = 1500
while vehicle.is_armable == False:
print(“Waiting for arming”)
time.sleep(1)

vehicle.armed = True
while vehicle.armed == False:
    print("Waiting for drone to arm")
    time.sleep(1) 

return None

vehicle = connectMyCopter()
arm()


I am not sure if I understand you in detail. Do you have the mavproxy still running, when you execute your Python code? That would mean, both try to connect the ttyAMA0 com port (which would not work).

No I just wanted to show that’s its getting connected, while the script execution doesn’t work.

Have you try specifying the baud rate? For example.
/dev/xxxx:921600

Also, hope this helps you also.

I tried both 57600 and 115200 bus didn’t work. Ardupilot guide they mentioned about using 57600 by default. Both didn’t work. It connected to mav commands but didnt respond to script.

which SERIALx_BAUD port are you using, confirm it with the Mission planner parameter setting. double check your serial/Uart wiring, RX (Pi) to TX (Ardupilot), TX (Pi) to RX (Ardupilot). Dronekit seems to have stopped maintenance since 2020. give Mavsdk-python a try to see if it is the issue.

How do you verify your connection is healthy? try a print after connection to see.
try this and make sure you know which RPi dev port number you are using.

from dronekit import connect

# Connect to the Vehicle (in this case a serial endpoint)
vehicle = connect('/dev/ttyAMA0', wait_ready=True, baud=57600)
print(" Autopilot Firmware version: %s" % vehicle.version)

Im using the telemetry 2 port, Telemetry 1 was used for the wifi telemetry and currently for the MTF-01 sensor. I configured those correctly. Will check with the print function and see. Earlier also we tried all the possible connections, but signals are sent and received but no actions. Do you have like any other turotial or guide for this ?

Your problem does not seem to be on a serial or UART connection. you connected and printed the Arducopter version. Is your drone healthy for a normal pilot flying in the first place? you must change to GPS GUIDE Mode to use a companion computer to arm.
you can try Google search for Dronekit arming example, what is needed to check on the drone before sending an arming command.

Yes it performed normal for both manual and mission modes. We are trying to use it with the optical flow sensor but before that the gps was attached and even then same thing happened. Will check with some other codes maybe.

Arh, you are using python3, I think dronekit is still on python2. That’s why I moved to Mavsdk-python to minimize incompatibility issue.

1 Like

Now this was tried using the pymavlink, No idea whats wrong now…

I checked with some other github repos and guides, theyve mentioned that dronekit is supporting python 3+ so there cant be any issue i guess

Not sure, 5-7 years old library.

See if this site helpful to you.

Post your code maybe, others can review and make suggestion.