Menu

Python script gets stuck during e.g. startup(), waiting forever

2016-07-17
2016-08-09
  • Mike Richter

    Mike Richter - 2016-07-17

    Hi Philipp!

    First of all, good job making that Interface :) I am currently trying to control the drone (ARDrone 2) with a Raspberry Pi 3. Therefore i am using ps_drone, however things do not seem to work. My goal is to make the drone record stuff and save it on a USB attached to the drone.

    Looking at your tutorial files such as firstVideo, i have made my own Code as following:

    import ps_drone
    import cwiid
    import time
    import os
    import types
    
    def main():
    
    
        drone = ps_drone.Drone()
        drone.startup()
        time.sleep(0.5)
        drone.getConfig()
        time.sleep(1)
        print drone.ConfigData
        drone.setConfigAllID()
        time.sleep(4)
        print "lets hope it starts recording now..."
        drone.hdrecVideo()
        drone.frontCam()
        drone.USBrecVideo()
        CDC = drone.ConfigDataCount
        while CDC == drone.ConfigDataCount:    time.sleep(0.0001)
        print "And action!"
        stop = False
        while not stop:
            key = drone.getKey()
            if key == " ":
                stop = True
            elif key == "f":
                drone.frontCam()
                print "film the front!"
            elif key == "g":
                drone.groundCam()
                print "film the floor!"
        print "okay, we are done."
        #i added these two functions to use USB recording 
        drone.hdrecVideo(False)
        drone.USBrecVideo(False)
        print "shutting down..."
        drone.shutdown()
        print "done."
    
    
       main()
    

    Now to run this script, i usually plug in the drone's battery, wait for it to be ready for the usb stick, and then i run the script. However, i face difficulties during startup(): The program gets stuck in line 158 of ps_drone.py, most likely because the ConfigQueue does not clear (i found out that both if's are executed only once).

    Stuff i have tried so far:
    remove len(ConfigQueue) from while-condition: Program continued, then got stuck waiting for ConfigDataCount to change

    remove all weird pollings where the program waits for things to happen inside the drone (and replace it with e.g. time.sleep(4)): No errors, no being stuck, no successful records or interactions... I highly doubt that my functions USBrecVideo() and hdrecVideo() are the problem, but if you want i can post them as well.

    set sendConfigSaveMode to True: no difference towards false.

    With that, i am at my wit's end, but maybe you still have some input for me to work on?

    Regards,
    Mike

     

    Last edit: Mike Richter 2016-07-18
  • PS-Drone

    PS-Drone - 2016-07-18

    Hi Mike,

    I must to give you a short answer this time, but I think I have to take a closer look at your problem anyway.

    My first guesses:
    The configuration-part of the drone uses TCP, which blocks, if no connection could be established. startup() just does try to connect to the drone and also blocks if there is no response. Are you sure, the drone uses 192.168.1.1 and does not switch its IP or port ? Does it respond if you ping it ?

    Am I right that you edit/forked the code of PS-Drone? That's OK of cause, I am sure your new functions are well done, but maybe you forgot a symbol or accidentally messed up something somewhere else. If you like, I can take a look at your code.

    You are welcome to mail me directly.

    cu,
    Philipp

     
  • Andreas H.

    Andreas H. - 2016-08-05

    Hi Phillip,

    I've Found out that the problem most likely lies in Mike's IDE. PS-Drone creates several threads, but IDLE seems to have trouble with these. Also, CTRL-Cing a multithreaded script seems not to have any effects on the other threads. My solution is using e.g. SPE, everything works well there.

    cu,
    Andreas

     
  • PS-Drone

    PS-Drone - 2016-08-09

    Hello Andreas,
    yes, your guess was absolutely right. We found out, that there was something wrong with the python-installation. Mike was able to ping the drone, but not to connect anything python. He switched to an other Linux (Ubuntu on VirtualBox) and everything was fine.
    cu,
    Philipp

     

Log in to post a comment.

MongoDB Logo MongoDB