I seem to be having a hard time grasping the concepts of argument passing and returning variables from a function. I am working on a project involving issuing commands to a robot through a python gui that I made using rest protocol. I am currently in the process of writing failsafe code to prohibit a user accidentally pressing the load mission button multiple times and loading a bunch of the same mission. Below is my code:
demo = 'e1af13ba-4f38-11e7-9626-f44d3061db09'
mission = 1
def compMissionQueue():
getMissionQueue = robot.get_mission_queue()[1][0]
#print(getMissionQueue)
missionID = getMissionQueue['id']
#print(missionID)
missionGUID = robot.get_mission_GUID_from_queue(missionID)[1]['mission_id']
print(missionGUID)
if missionGUID != mission:
print('Mission successfully added to queue')
else:
print('Mission already in queue. Add again?')
def techDemo():
def loadMission():
#runDemo = robot.load_mission(demo)
#robot.continue_robot()
#robot.pause_robot()
#robot.delete_from_mission_queue(demo)
mission = demo
return mission
loadMission()
compMissionQueue()
print(mission)
return mission
The function techDemo is 'triggered' by a button press in the gui. What I was trying to do was to use the compMissionQueue function to check if a mission had already been loaded to the queue and if so, print some message to the user. I tried checking if the value for 'mission' is being returned by running multiple print calls on it and it is not returning mission=demo from what I can tell, it always prints '1' from the first time I set mission. If you could point me in the right direction, it would be much appreciated.
compMissionQueue()not definedtechDemoknows nothing aboutmissionas it as a local variable in the scope ofloadMission. You should domission = loadMission()then yu will be able to return it fromtechDemo.