Drone will not leave initial armed mode


#1

I am currently copying the drone dojo python script for a simple takeoff and land function. The drone follows through on the program and becomes armed. However, the motors only spin at the rotation of the basic, throttle down, spin. There is no acceleration and the drone does not actually take off. I am able to use an rc controller to move my drone, so I know the motors work and can achieve takeoff. Any ideas as to why it would no longer work? Or why it does not adjust the speed whatsoever? Here is the cod ejust in case.

####Dependencies###################

from dronekit import connect, VehicleMode, LocationGlobalRelative
import time
import socket
import exceptions
import argparse

###Function definitions for mission####

##Function to connect script to drone
def connectMyCopter():
    parser = argparse.ArgumentParser(description='commands')
    parser.add_argument('--connect')
    args = parser.parse_args()

    connection_string = args.connect

    vehicle = connect(connection_string, wait_ready=True)

    return vehicle

##Function to arm the drone and takeoff into the air##
def arm_and_takeoff(aTargetAltitude):
   # while not vehicle.is_armable:
   #    print("Waiting for vehicle to become armable")
    #    time.sleep(1)

    #Switch vehicle to GUIDED mode and wait for change
    vehicle.mode = VehicleMode("GUIDED_NOGPS")
    while vehicle.mode!="GUIDED_NOGPS":
        print("Waiting for vehicle to enter GUIDED mode")
        time.sleep(1)

    #Arm vehicle once GUIDED mode is confirmed
    vehicle.armed=True
    while vehicle.armed==False:
        print("Waiting for vehicle to become armed.")
        time.sleep(1)

    vehicle.simple_takeoff(aTargetAltitude)

    while True:
        print("Current Altitude: %d"%vehicle.location.global_relative_frame.alt)
        if vehicle.location.global_relative_frame.alt>=aTargetAltitude*.95:
            break
        time.sleep(1)

    print("Target altitude reached")
    return None

#### Mission################################

vehicle=connectMyCopter()
print("About to takeoff..")

vehicle.mode=VehicleMode("GUIDED_NOGPS")
arm_and_takeoff(2) ##Tell drone to fly 2 meters in the sky
vehicle.mode=VehicleMode("LAND") ##Once drone reaches altitude, tell it to land

time.sleep(2)

print("End of function")
print("Arducopter version: %s"%vehicle.version)

while True: 
    time.sleep(2)

vehicle.close()
### End of script


#2

Just curious, this section is intended to be commented ?

#while not vehicle.is_armable:
#    print("Waiting for vehicle to become armable")
#    time.sleep(1)

#3

Was this ever fixed?? Having the same problem…


#4

Hi there @Jarrod

Couple questions:

Are you using a pixhawk or navio drone?
What version of arducopter are you using?
What version of Dronekit and pymavlink are you using?

It is possible there is a version inconsistency. Are you able to fly the drone around manually like the OP?


#5

i m using the same code and even in the same guided_nogps mode ,mine is not even arming even when all the parameters are same as recommended


#6

same here when i run the script, the drone do not arm. I am using a pixhawk.


#7

Look in the mission planner < messages tab for clues. There is likely some failsafe or some sensor that isn’t ready yet and preventing arming.

Of note, it can take the EKF up to 5 minutes after powering on before getting stable. It usually doesn’t take this long but it can.

But definitely look into the messages tab of MP, it will help. Not arming can be due to 100’s of reasons.


#8

For some strange reason, i could arm the drone after i commented out the arm mode at the script.


#9

Did you guys find out what was wrong?