Skip to content

DKPY2: Exiting script does not send last command and may report exception #325

Closed

Description

@hamishwillee

I've updated simple_goto.py (see branch tmp_getting_started_dkpy2 which will be merged in #320).

The last action in the script is RTL:

print "Returning to Launch"
vehicle.mode    = VehicleMode("RTL")
vehicle.flush()

However the RTL does not occur (the command is probably not sent - certainly the MAVProxy prompt was still reporting "guided".

I ran this a few times. In one case I got an exception reported:

 Altitude:  18.9200000763
Reached target altitude
Going to first point...
Going to second point...
Returning to Launch
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
E:\deleteme\dronekit-python\examples\simple_goto>

Is there any way to ensure that the last command is fully completed (ie flush completes) before the thread exits?

Otherwise, what is the best way to deal with this? I'd prefer not to add documentation that scripts should wait a second before completing.

Activity

  1. tcr3dr commented on Oct 14, 2015

    @tcr3dr
    Contributor

    We need an explicit vehicle.close() command. This also addresses the "how do you properly terminate a script?" question.

  2. modified the milestone: v2.0.0 on Oct 14, 2015
  3. hamishwillee commented on Oct 15, 2015

    @hamishwillee
    ContributorAuthor

    Looks like that went in - see #347. Needs to be documented (#348. )

  4. hamishwillee commented on Oct 15, 2015

    @hamishwillee
    ContributorAuthor

    @tcr3dr I added vehicle.close() to end of simple_goto.py. The last sent RTL now completes, but I still get exception.

    Last few lines of simple_goto.py:

    # sleep so we can see the change in map
    time.sleep(20)
    
    print "Returning to Launch"
    vehicle.mode    = VehicleMode("RTL")
    vehicle.flush()
    
    #Close vehicle object before exiting script
    print "\nClose vehicle object"
    vehicle.close()
    

    Output is:

    Returning to Launch
    
    Close vehicle object
    Exception in thread Thread-1 (most likely raised during interpreter shutdown):
    
  5. tcr3dr commented on Nov 7, 2015

    @tcr3dr
    Contributor

    @hamishwillee Can you check that this issue still occurs on rc8?

  6. hamishwillee commented on Nov 9, 2015

    @hamishwillee
    ContributorAuthor

    I can't replicate now after two or three tries. Lets "hope" this is fixed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions