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

Python Error Invalid item provided

#1
I'm trying to read a CSV file via a python script and I can't run correclty robot.setJoints command. This is my code. Do you know what's the problem?

Code:
LOAD_AS_PROGRAM = True
REFERENCE_NAME = 'Reffere to'
TARGET_NAME = 'Home'
RDK = Robolink()
path_file = r'C:/Users/giahn/OneDrive/Έγγραφα/Σχολή/ΔΙΠΛΩΜΑ/main/Test/program.csv'
data = LoadList(path_file)
program_name = getFileName(path_file)
robot = RDK.Item('Comau Smart5 NJ 110-3.0', ITEM_TYPE_ROBOT)
frame = RDK.Item(REFERENCE_NAME, ITEM_TYPE_FRAME)
if not frame.Valid():
    raise Exception("Failed to retrieve the reference frame. Check frame configuration.")
robot.setPoseFrame(frame)
target = RDK.Item(TARGET_NAME, ITEM_TYPE_TARGET)
if not target.Valid():
    raise Exception("Target not found. Ensure the name is correct.")
if not target.Valid():
    raise Exception("Home target is not valid. Set a home target named: %s" % TARGET_NAME)
# Set the robot to the home position
# Get the pose reference from the home target
robot.setJoints(target.Joints())
pose_ref = robot.Pose()
if LOAD_AS_PROGRAM:
    # Add a new program
    program = RDK.AddProgram(program_name, robot)
    # Turn off rendering (faster)
    RDK.Render(False)
    # Speed up by not showing the instruction:
    program.ShowInstructions(False)
    # Remember the speed so that we don't set it with every instruction
    current_speed = None
    target = None
    # Very important: Make sure we set the reference frame and tool frame so that the robot is aware of it
    program.setPoseFrame(frame)
    program.setPoseTool(robot.PoseTool())


Attached Files Image(s)
   
#2
Do you have the robot Comau Smart5 NJ 110-3.0 in your project?

If not, you can change this line:
Code:
robot = RDK.Item('Comau Smart5 NJ 110-3.0', ITEM_TYPE_ROBOT)

To the following, so you automatically take the first or only robot in your project:
Code:
robot = RDK.Item('', ITEM_TYPE_ROBOT)

You can also do this if you have multiple robots:
Code:
robot = RDK.ItemUserPick('Select a robot', ITEM_TYPE_ROBOT)
#3
I will post the next error in another Thread thanks for the answer it Worked!
#4
Great, thank you for your feedback.
  




Users browsing this thread:
1 Guest(s)