02-05-2019, 11:25 PM
To reproduce, load a new Station, import any Kuka robot. Then create a new python program.
In the body of the program I am using this example:
//www.sinclairbody.com/doc/en/PythonAPI/robo...AddProgram
After fixing the missing 'program_name' and 'robot' variables, I then run the program. I immediately get this error:
Python script failed returning 1
Traceback (most recent call last):
File "/var/folders/z7/12j9__qs7v93kxmjhrs0x2dsww4_55/T/Prog21.py", line 39, in
prog.MoveL (ti)
File "/Users/michael.staub/RoboDK/RoboDK.app/Contents/Python/robolink.py", line 3978, in MoveL
raise Exception("Adding a movement instruction to a program given joints or a pose is not supported. Use a target item instead, for example, add a target as with RDK.AddTarget(...) and set the pose or joints.")
Exception: Adding a movement instruction to a program given joints or a pose is not supported. Use a target item instead, for example, add a target as with RDK.AddTarget(...) and set the pose or joints.
It looks like the MoveL method is checking that the target is type 'Item', which it should be. This appears to be a bug in the python API. Can you link me to an example of a working python script that can successfully generate a program that moves the robot?
Here is my full python program:
from robolink import * # RoboDK API
from robodk import * # Robot toolbox
RDK = Robolink()
RDK.Render(False)
prog = RDK.AddProgram('AutoProgram')
robot= RDK.Item('', ITEM_TYPE_ROBOT)
POINTS = [ [ 1, 2, 3], [4, 5, 6] ]
# Retrieve the current robot position:
pose_ref = robot.Pose()
# Iterate through a number of points
for i in range(len(POINTS)):
# add a new target
ti = RDK.AddTarget('Auto Target %i' % (i+1))
# use the reference pose and update the XYZ position
pose_ref.setPos(POINTS[i])
ti.setPose(pose_ref)
# force to use the target as a Cartesian target (default)
ti.setAsCartesianTarget()
# Add the target as a Linear/Joint move in the new program
prog.MoveL (ti)
In the body of the program I am using this example:
//www.sinclairbody.com/doc/en/PythonAPI/robo...AddProgram
After fixing the missing 'program_name' and 'robot' variables, I then run the program. I immediately get this error:
Python script failed returning 1
Traceback (most recent call last):
File "/var/folders/z7/12j9__qs7v93kxmjhrs0x2dsww4_55/T/Prog21.py", line 39, in
prog.MoveL (ti)
File "/Users/michael.staub/RoboDK/RoboDK.app/Contents/Python/robolink.py", line 3978, in MoveL
raise Exception("Adding a movement instruction to a program given joints or a pose is not supported. Use a target item instead, for example, add a target as with RDK.AddTarget(...) and set the pose or joints.")
Exception: Adding a movement instruction to a program given joints or a pose is not supported. Use a target item instead, for example, add a target as with RDK.AddTarget(...) and set the pose or joints.
It looks like the MoveL method is checking that the target is type 'Item', which it should be. This appears to be a bug in the python API. Can you link me to an example of a working python script that can successfully generate a program that moves the robot?
Here is my full python program:
from robolink import * # RoboDK API
from robodk import * # Robot toolbox
RDK = Robolink()
RDK.Render(False)
prog = RDK.AddProgram('AutoProgram')
robot= RDK.Item('', ITEM_TYPE_ROBOT)
POINTS = [ [ 1, 2, 3], [4, 5, 6] ]
# Retrieve the current robot position:
pose_ref = robot.Pose()
# Iterate through a number of points
for i in range(len(POINTS)):
# add a new target
ti = RDK.AddTarget('Auto Target %i' % (i+1))
# use the reference pose and update the XYZ position
pose_ref.setPos(POINTS[i])
ti.setPose(pose_ref)
# force to use the target as a Cartesian target (default)
ti.setAsCartesianTarget()
# Add the target as a Linear/Joint move in the new program
prog.MoveL (ti)