So I have developed a python script to arm a quadrotor, fly a guided mission, return to launch and disarm. However, I am interested in getting back control of the rotor while the script is in progress incase something goes wrong. Can I put a failsafe case for this in python script or do I have to look into mavlink framework to achieve this.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Developer

    you are in control of the python script, so you can do whatever you need to do.

    • Hey Michael, thanks for your reply. Can you tell me what command is used to restore control back to RC?

      • Developer

        are you using the rc override in the script?

        if so just set all the pwm's to 0, and send a packet, that will remove the rc override

        • It worked. Thank you !!

          • Michael, I tried to do that, and I was able to regain control. But my I fail to go into guided mode after that. The copter just drops to the ground after I execute the sequence to remove rc override.

            Here is my code

            import sys
            import clr
            import time
            from math import *
            import MissionPlanner #import *

            clr.AddReference("MissionPlanner.Utilities") # includes the Utilities class

            def set_RC():
            print "Setting RCs to Neutral"
            for i in range(1,9):
            Script.SendRC(i,1500,False)
            Script.SendRC(3,Script.GetParam('RC3_MIN'),True)
            Script.ChangeMode("Stabilize")

            return True

            def arm_motors():
            Script.ChangeMode("Stabilize")
            Script.SendRC(3,Script.GetParam('RC3_MIN'),True)
            Script.SendRC(4,Script.GetParam('RC4_MAX'),True)
            print "Arming Motors !!"
            Script.WaitFor('ARMING MOTORS',10000)
            print "Armed"
            Script.SendRC(4,(Script.GetParam('RC4_MIN')+Script.GetParam('RC4_MAX'))/2,True)
            Script.Sleep(5)
            Script.SendRC(3,2000,True)
            time.sleep(1)
            Script.ChangeMode("AltHold")
            #Script.SendRC(3,(Script.GetParam('RC3_MIN')+Script.GetParam('RC3_MAX'))/2,True)
            Script.SendRC(3,(Script.GetParam('TRIM_THROTTLE')),True)

            return True

            def disarm_motors():
            Script.ChangeMode("Stabilize")
            Script.SendRC(3,Script.GetParam('RC3_MIN'),True)
            Script.SendRC(4,Script.GetParam('RC4_MIN'),True)
            print "Disarming motors ...."
            Script.WaitFor('DISARMING MOTORS',10000)
            print "Disarmed"
            Script.SendRC(4,(Script.GetParam('RC4_MIN')+Script.GetParam('RC4_MAX'))/2,True)

            return True

            def Return_To_Launch(user_alt):
            if user_alt==0:
            Script.ChangeParam("RTL_ALT",2000)
            print "Default RTL altitude set"
            else:
            Script.ChangeParam("RTL_ALT",cs.alt*100)
            print "User RTL altitude set"
            Script.ChangeMode("RTL")
            print "Returning to Launch"

            return True

            #MAIN

            set_RC();
            arm_motors();
            time.sleep(20);

            for i in range(1,9):
            Script.SendRC(i,0,True) #fails after this


            Script.ChangeMode("Guided")

            item = MissionPlanner.Utilities.Locationwp()

            lat = 37.871460
            lng = -122.317564
            alt = 5

            MissionPlanner.Utilities.Locationwp.lat.SetValue(item,lat)
            MissionPlanner.Utilities.Locationwp.lng.SetValue(item,lng)
            MissionPlanner.Utilities.Locationwp.alt.SetValue(item,alt)
            print 'WP 1 set'
            MAV.setGuidedModeWP(item)
            print 'Going to WP 1'

            time.sleep(30)

            print 'Ready for next WP'

            lat = lat
            lng = lng
            alt = alt+2
            MissionPlanner.Utilities.Locationwp.lat.SetValue(item,lat)
            MissionPlanner.Utilities.Locationwp.lng.SetValue(item,lng)
            MissionPlanner.Utilities.Locationwp.alt.SetValue(item,alt)
            print 'WP 2 set'
            MAV.setGuidedModeWP(item)
            print 'Going to WP 2'

            time.sleep(30)

            print "Reached WP 2"

            Return_To_Launch(1);
            time.sleep(30);
            disarm_motors();
            set_RC();

This reply was deleted.

Activity

DIY Drones via Twitter
RT @MarvelmindMaxim: Extreme precision for 60 swarming robots. #marvelmind #autonomousrobotics #robotics #swarmrobotics #rtls #ips #indoor…
yesterday
DIY Drones via Twitter
RT @MarvelmindMaxim: Precise (±2cm) tracking for racing boats and autonomous boats. Works outdoor and indoor. #autonomous #AutonomousVehic…
yesterday
DIY Drones via Twitter
RT @MarvelmindMaxim: Helping PixHawk folks to fly autonomous quadcopters using PX4 and ArduPilot. https://marvelmind.com/drones/ Equally suitab…
yesterday
DIY Robocars via Twitter
RT @chr1sa: The @DIYRobocars @donkey_car virtual AI car race is starting in 15 minutes! Watch it live on Twitch https://www.twitch.tv/mossmann3333 htt…
Saturday
DIY Robocars via Twitter
RT @chr1sa: Don't miss our monthly @DIYRobocars @donkey_car virtual AI car race tomorrow at 10:00am PT live on Twitch. Head-to-head racing…
Friday
DIY Robocars via Twitter
RT @sparkfun: Our completed tutorial on building an @NVIDIA Jetson Nano-powered @Sphero RVR gets your bot up and running via teleoperation…
Thursday
DIY Robocars via Twitter
RT @SmallpixelCar: Freeway test https://t.co/4V5tV9lhIP
Jul 29
DIY Robocars via Twitter
Very small autonomous cars racing, thanks to an overhead camera: https://control.ee.ethz.ch/research/team-projects/autonomous-rc-car-racing.html
Jul 29
DIY Robocars via Twitter
Jul 29
DIY Robocars via Twitter
Jul 29
DIY Robocars via Twitter
RT @chr1sa: Don't miss our virtual AI car race this Saturday! Real developers + virtual cars =🏎️🏎️🏎️ Head-to-head battles with thrills, sp…
Jul 28
DIY Robocars via Twitter
Jul 27
DIY Robocars via Twitter
RT @usashirou1: Jetson nano by Isaac Kaya #jetson https://t.co/Mu1N0CyQkN
Jul 23
DIY Robocars via Twitter
RT @GPUsolution: JetRacer mady by Iflytek company #JetsonNANO #Nvidia https://t.co/MimTymIwge
Jul 23
DIY Robocars via Twitter
RT @openmvcam: I love this: Mega or Mini? Image Classification on the 1MB OpenMV Cam H7 by Ish Ot Jr. in OpenMV, Edge Impulse, Internet of…
Jul 23
DIY Robocars via Twitter
RT @RoboticMasters: This is looking pretty good... but still needs a bit more refinement. Pure OpenCV Turning Sign Detection. No Tensorfl…
Jul 23
More…