def readmission(aFileName):
 print ('\nReading mission from file: %s' % aFileName)
 cmds = vehicle.commands
 missionlist = []
 with open(aFileName) as f:
  for (i, line) in enumerate(f):
   if (i == 0):
    if (not line.startswith('QGC WPL 110')):
     raise Exception('File is not supported WP version')
   else:
    linearray = line.split(' DCTB ')
    ln_index = int(linearray[0])
    ln_currentwp = int(linearray[1])
    ln_frame = int(linearray[2])
    ln_command = int(linearray[3])
    ln_param1 = float(linearray[4])
    ln_param2 = float(linearray[5])
    ln_param3 = float(linearray[6])
    ln_param4 = float(linearray[7])
    ln_param5 = float(linearray[8])
    ln_param6 = float(linearray[9])
    ln_param7 = float(linearray[10])
    ln_autocontinue = int(linearray[11].strip())
    cmd = Command(0, 0, 0, ln_frame, ln_command, ln_currentwp, ln_autocontinue, ln_param1, ln_param2, ln_param3, ln_param4, ln_param5, ln_param6, ln_param7)
    missionlist.append(cmd)
 return missionlist

def readmission ( aFileName ) : print ( '\nReading mission from file: %s' % aFileName ) cmds = vehicle . commands missionlist = [ ] with open ( aFileName ) as f : for ( i , line ) in enumerate ( f ) : if ( i == 0 ) : if ( not line . startswith ( 'QGC WPL 110' ) ) : raise Exception ( 'File is not supported WP version' ) else : linearray = line . split ( ' DCTB ' ) ln_index = int ( linearray [ 0 ] ) ln_currentwp = int ( linearray [ 1 ] ) ln_frame = int ( linearray [ 2 ] ) ln_command = int ( linearray [ 3 ] ) ln_param1 = float ( linearray [ 4 ] ) ln_param2 = float ( linearray [ 5 ] ) ln_param3 = float ( linearray [ 6 ] ) ln_param4 = float ( linearray [ 7 ] ) ln_param5 = float ( linearray [ 8 ] ) ln_param6 = float ( linearray [ 9 ] ) ln_param7 = float ( linearray [ 10 ] ) ln_autocontinue = int ( linearray [ 11 ] . strip ( ) ) cmd = Command ( 0 , 0 , 0 , ln_frame , ln_command , ln_currentwp , ln_autocontinue , ln_param1 , ln_param2 , ln_param3 , ln_param4 , ln_param5 , ln_param6 , ln_param7 ) missionlist . append ( cmd ) return missionlist
load a mission from a file into a list .