I am running pythong 2.7.14 with arducopter 3.6.11 on a navio2 RPi 3B + combo
The quadcopter is supposed to run python scripts and the RC is disabled. I got the script to work, but due to obvious safety concerns I would like to have an interrupt that forces the drone to land or turn off. Right now I am running an excpetion that forces the drone into LAND mode but the drone does not land. To further try to bring the vehicle down I go into a loop to force the drone to disarm. I am completely new to dronekit and I think it is cool, but could somebody give me a pointer on my code as to why this is not disarming?
from dronekit import connect, VehicleMode, LocationGlobalRelative
from modules import *
# Connect to drone through telmetry vehicle = connectDrone() # System status display and arm decision systemBoot(vehicle) # Arm and Takeoff at altitude in meters armAndTakeoff(vehicle, 1) # Have drone hover for a few seconds vehicle.mode = VehicleMode("LOITER") print "Drone is hovering....." time.sleep(25)
# Force drone to land while vehicle.mode != "LAND": vehicle.mode = VehicleMode("LAND") print "Drone is making an emergency landing...." while vehicle.armed == True: vehicle.disarm
while vehicle.mode != "LAND":
vehicle.mode = VehicleMode("LAND")
print "Drone is landing...."
print "End of mission..."
msg = vehicle.message_factory.mount_configure_encode(
0, 1, # target system, target component mavutil.mavlink.MAV_MOUNT_MODE_MAVLINK_TARGETING, #mount_mode 1, # stabilize roll 1, # stabilize pitch 1, # stabilize yaw )
msg = vehicle.message_factory.mount_control_encode(
0, 1, # target system, target component -90*100, # pitch is in centidegrees 0.0, # roll 0, # yaw is in centidegrees 0 # save position )
I wanted to observe MISSION_ITEM_REACHED message using add_attribute_listener() but does not seem to work:
def wp_observer(self, vehicle_obj, attr_name, value): print vehicle_obj, attr_name, value