RoboDK Forum
Python -> Robodk -> Robot - Run on robot, wont work- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Python -> Robodk -> Robot - Run on robot, wont work (/Thread-Python-Robodk-Robot-Run-on-robot-wont-work)



Python -> Robodk -> Robot - Run on robot, wont work-Mnejmann-05-02-2023

Hey, i cant seem to figure out how to run my python program on the robot, it only works when i use the feauture inside robodk, where i execute an existing program inside robodk, but it wont do the movements when i manually moves the robot from the MoveL and MoveJ commands in python.


Code example:
Code:
# Type help("robodk.robolink") or help("robodk.robomath") for more information
# Press F5 to run the script
# Documentation: //www.sinclairbody.com/doc/en/RoboDK-API.html
# Reference: //www.sinclairbody.com/doc/en/PythonAPI/robodk.html
# Note: It is not required to keep a copy of this file, your Python script is saved with your RDK project

# You can also use the new version of the API:
from robodk import robolink # RoboDK API
从robodk进口robomath # Robot toolbox
RDK = robolink.Robolink()
robot = RDK.Item('UR5')

# Forward and backwards compatible use of the RoboDK API:
# Remove these 2 lines to follow python programming guidelines
from robodk import * # RoboDK API
from robolink import * # Robot toolbox
# Link to RoboDK
# RDK = Robolink()

#kører et program ved navnet "reset pos"
#RDK.Item("Reset Pos").RunProgram()

#gripper TBD
#from wsg50 import *
#wsg50.grasp_part() #Will be used to grip the part
#wsg50.release_part() #will be used to release the part


RDK.setSimulationSpeed(5)
###

def Robot_reset(): #Robot goes to "Home" position, and all the parts go back to the dipensers
"""Resets the position of the robot, and the parts"""
RDK.Item("Reset Pos").RunProgram()

#main
robot.Connect()

RDK.setRunMode(1)

robot.MoveJ(RDK.Item("Home"))



RE: Python -> Robodk -> Robot - Run on robot, wont work-Alex-05-02-2023

Did you try a different argument for SetRunMode?
  • RDK.setRunMode(1) controls the virtual robot
  • RDK.setRunMode(5) controls the real robot



RE: Python -> Robodk -> Robot - Run on robot, wont work-Mnejmann-05-02-2023

Thank you, that solves everything! completely overlooked the values above 1 and 2 in the setRunMode() command.