Jan-28-2020, 01:27 PM
Hey, I recently bought a dobot magician and have been playing around with controlling it using python. However, I
I also want the script to run endlessly, meaning that once it has checked for i=1 once, it should go back and do this over and over again. How do I go about this?
m very new to this programming language, and I don
t know whether my syntax is off base, or if its the script, or maybe (probably) both. My plan is to control the robot coordinate inputs from an external component, and in the meantime I just want to leave a placeholder for i=input, where i simply just write the number 1 to run the if-loop. However whenever I type 1, nothing happens. Is this because the if-loop does not wait for a command, and the script just moves along with its life? I also want the script to run endlessly, meaning that once it has checked for i=1 once, it should go back and do this over and over again. How do I go about this?
import threading import DobotDllType as dType CON_STR = { dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError", dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound", dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"} # Load Dll api = dType.load() # Loader biblioteket som gjør at det er mulig å bruke dobot sine funksjoner i python # Connect state = dType.ConnectDobot(api, "", 115200)[0] print("Connect status:", CON_STR[state]) if (state == dType.DobotConnect.DobotConnect_NoError): # Clean Command Queued dType.SetQueuedCmdClear(api) # code i = input("Enter a number ") while (i ==1): dType.SetPTPCmdEx(api, 0, 250, 0, 60, 0, 1) dType.SetPTPCmdEx(api, 0, 20, 285, 30, 0, 1) dType.SetPTPCmdEx(api, 0, 20, 299, (-26), 0, 1) dType.SetEndEffectorParamsEx(api, 59.7, 0, 0, 1) dType.SetEndEffectorGripperEx(api, 1, 1) dType.SetWAITCmdEx(api, 0.4, 1) dType.SetPTPCmdEx(api, 0, 200, (-200), 30, 0, 1) current_pose = dType.GetPose(api) dType.SetPTPCmdEx(api, 2, 0, (-250), (-26), current_pose[3], 1) dType.SetEndEffectorGripperEx(api, 1, 0) dType.SetPTPCmdEx(api, 0, 250, 0, 60, 0, 1) dType.SetPTPCmdEx(api, 0, 0, (-250), (-26), 0, 1) dType.SetEndEffectorGripperEx(api, 1, 1) dType.SetWAITCmdEx(api, 0.4, 1) dType.SetPTPCmdEx(api, 0, 20, 299, 50, 0, 1) dType.SetPTPCmdEx(api, 7, 0, 0, (-76), 0, 1) dType.SetEndEffectorGripperEx(api, 1, 0) dType.SetPTPCmdEx(api, 0, 250, 0, 60, 0, 1) dType.SetEndEffectorGripperEx(api, 0, 1) else: dType.SetPTPCmdEx(api, 0, 250, 0, 60, 0, 1) dType.SetEndEffectorGripperEx(api, 0, 1)