Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

意想不到的行为:在机器人运行程序(Python)

#1
Hi,
I have generated a program using a python script and I would now like to run it on the robot.
To do that, I am using

Code:
run_mode=6
RDK.setRunMode(run_mode)
and excecute the program with

Code:
RDK.RunCode('prog',True)
which does not seem to work. I also tried RunProgram, both options work fine for RunMode=1 but not for RunMode=6. With RunMode=6 nothing happens at all.
I checked if setRunMode is actually working by putting

Code:
RDK.RunMode()
directly after setRunMode() and it seems to be fine. What seems odd to me is that, when I check the settings directly in RoboDK (see attachment RoboDK_01), the option 'Run on robot' is not active.
The other way round, if I activate 'Run on robot' (see attachment RoboDK_02) manually in RoboDK and then use a script to start the program, it is excecuted on the real robot as it is supposed to.
I am not sure what is wrong. Is RunMode=6 not equivalent to 'Run on robot' and I am therefore using it the wrong way or is it maybe a bug?
(In the latter case, please feel free to move the thread to the bug section)
Please let me know if I left anything unclear.


Attached Files Thumbnail(s)

#2
Hi DavidG,

The way you use RunMode applies to robot commands using the API (such as robot.MoveJ and robot.MoveL).

Since you want to operate on existing programs in the RoboDK project you should do the following instead:

Code:
prog = RDK.Item('MainProgram', ITEM_TYPE_PROGRAM)
prog.setRunType(PROGRAM_RUN_ON_ROBOT) # Activate the Run on robot option
# prog.setRunType(PROGRAM_RUN_ON_SIMULATOR) # Run on simulator (default)
prog.RunProgram()
while prog.Busy():
print("Waiting for the program to complete")
pause(1)

More information here:
//www.sinclairbody.com/doc/en/PythonAPI/exam...rogramming

Albert
#3
Hi Albert,
thanks for the clarification. I was already wondering why I would use setRunMode since it applies to the robot item and not the program. I simply overlooked the setRunType command, so thanks a lot.




Users browsing this thread:
1 Guest(s)