我的经验问题而与r编程的道路obodk. My station looks like instation png. My code looks like this :
Code:
""" Control the robot via the RoboDK Python API
Parameters ---------- htm = (n,4,4) Homogeneous Transformation Matrices from the base to the tool holder of every positions speed : (n-1) float speed between each position """
RDK = Robolink() copyfile("..\Ressources\RDKFiles\CTTLab.rdk", "..\Ressources\RDKFiles\Test.rdk") RDK.AddFile("..\Ressources\RDKFiles\Test.rdk") robot = RDK.Item('KUKA KR 100-2 P', ITEM_TYPE_ROBOT) if not robot.Valid(): raise Exception('No robot selected or available')
reference = robot.Parent().Parent()
# Create a new program program = RDK.AddProgram("Test", robot)
# Turn off automatic rendering RDK.Render(False)
# Specify the reference frame you want to use program.setPoseFrame(reference)
for i in range(htm.shape[0] - 1): targetname = 'Target %i' % (i + 1) target = RDK.AddTarget(targetname, reference, robot) target.setPose(htm[i+1]) program.setSpeed(speed[i]) program.MoveJ(target)
program.RunProgram()
I get a error : AttributeError: 'numpy.ndarray' object has no attribute 'isHomogeneous' I overcome this by remplacing htm[i] by KUKA_2_Pose(Pose_2_KUKA(htm[i+1])). But it doesn`t seems to be the proper way. When running the corrected program, i get an error that the target is out of reach. as shown in the picture enclosed.
Do you have an idea of where it can come from ?
I tried another solution. Indeed, I added the following : target.setAsJointTarget() The rail finally move to reach the target but it doens't reach the proper target.
You could do something like: reference = KUKA_2_Pose(list(xyzabc))
Where xyzabc is a 1D numpy array given X,Y,Z,A,B,C values. The list function will convert it to a list of 6 values and the KUKA_2_Pose will create a Mat pose that you can provide to RoboDK as a pose.
09-13-2019, 04:11 PM(This post was last modified: 09-13-2019, 04:16 PM byMarcGondran.)
Hi, Thank you for your answer. Unfortunately, it doesn't solve the "target out of reach" issue. What about it ? I should precise that I acheive placing the targets. It just says that they are out of reach while obviously they are not.
12-02-2019, 07:24 PM(This post was last modified: 12-02-2019, 07:40 PM byMarcGondran.)
Hi,
I will reply to this subject again.
Indeed I did kind of solve the issue using the previous code however. I have a lot of point and it takes very long to generate using this mean. I use the MacOS version of RoboDK and the straight forward method to create target using the API works. However when back to the windows version, it still doesn't work.
The straight forward code I use is this one :
Code:
RDK = Robolink()
robot = RDK.Item('KUKA KR 100 HA', ITEM_TYPE_ROBOT) if not robot.Valid(): raise Exception('No robot selected or available')
# Specify the reference frame you want to use program = RDK.AddProgram("{} Picture Analysis".format(name_prog), robot) program.setPoseFrame(camera_base) program.setPoseTool(tool)
12-02-2019, 09:48 PM(This post was last modified: 04-20-2020, 11:38 AM byAlbert.)
Hi Marc,
When you use external axes you need to provide the position of the external axes in your target (using setJoints). If the target is Cartesian you don't need to worry about the robot axes. Alternatively, you can load a robot machining file such as Gcode or APT and use a curve follow project or robot machining project. You'll then be able to optimization tools for external axes.
I was unable to test your file as it requires additional input data but this small script will allow you to update the position of the external axes to all targets in a station (for example, 5000 mm):
Code:
from robolink import * # RoboDK API from robodk import * # Robot toolbox RDK = Robolink()
targets = RDK.ItemList(ITEM_TYPE_TARGET)
RDK.Render(False) for t in targets: # Set the value of the external axis e1 = 5000 # in mm t.setJoints([0,0,0,0,0,0, e1])
# Recalculate the joint position based on the new position of the external axis # Robot joints are updated but not external axis t.setAsCartesianTarget () t.Joints()
If you are looking for faster speed (I noticed you already disabled Render) I would recommend you to use the C++ API (slightly faster) or the plugin interface to create a plugin (much faster). The API's are almost the same in both cases.
12-03-2019, 04:14 PM(This post was last modified: 12-03-2019, 05:07 PM byMarcGondran.)
Thank you for your answer Albert. Actually, I don't know the external rail position, I want robodk to optimize this parameter. How can I manage it ? Plus what's weird is that it totally works on MacOS this way.
You can wrap the update of the external axis inside another loop to test different positions for the rail (programmatically).
The command program.Update will quickly tell you if the program is feasible so you can keep searching until you find a valid solution.
I updated your sample project to do so.
Albert
Code:
from robolink import * # RoboDK API from robodk import * # Robot toolbox RDK = Robolink()
# Retrieve all targets targets = RDK.ItemList(ITEM_TYPE_TARGET)
# Select a program (automatic selection if you only have one program) program = RDK.ItemUserPick('Select a program to check and update targets', ITEM_TYPE_PROGRAM)
# Turn off rendering (faster) RDK.Render(False)
# List some candidates for the external axis (E1, in mm): Test_E1 = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500] #test_E1 = range(500, 5000, 500)
for e1 in Test_E1: print("Testing program feasibility for E1:" + str(e1))
# Update all targets to desired e1 for t in targets: # Set the value of the external axis # e1 = 5000 # in mm t.setJoints([0,0,0,0,0,0, e1])
# Recalculate the joint position based on the new position of the external axis # Robot joints are updated but not external axis t.setAsCartesianTarget () t.Joints()
# Test the program and make sure it is 100% feasible valid_ins, prog_time, prog_len, valid_ratio, error_msg = program.Update() if valid_ratio < 1.0: print(" Unable to complete the program") print(" " + error_msg)
else: print(" Program feasible!") # stop looking break