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

Python -> Robodk -> Robot - Run on robot, wont work

#1
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: https://robodk.com/doc/en/RoboDK-API.html
# Reference:     https://robodk.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
from robodk import 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"))
#2
Did you try a different argument for SetRunMode?
  • RDK.setRunMode(1) controls the virtual robot
  • RDK.setRunMode(5) controls the real robot
#3
Thank you, that solves everything! completely overlooked the values above 1 and 2 in the setRunMode() command.
  




Users browsing this thread:
1 Guest(s)