Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
External Rail programmation with the Python API
#1
Hi,

I experience issue while programming a path with robodk. 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)

   # Define a reference pose
   targetname = 'Target Home'
   target_home = RDK.AddTarget(targetname, reference, robot)
   target_home.setJoints(robot.SolveFK(robot.JointsHome()))
   program.MoveJ(target_home)

   targetname = 'Target 0'
   target = RDK.AddTarget(targetname, reference, robot)
   target.setAsCartesianTarget()
   target.setPose(htm[0])
   program.MoveJ(target)

   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.

Thank you


Attached Files Thumbnail(s)
       
#2
I believe you are providing numpy matrices to the RoboDK API. RoboDK expects 4x4 matrices to be Mat objects. This Matrix object is defined in the robodk module:
https://robodk.com/doc/en/PythonAPI/robo...robodk.Mat

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.
#3
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.


Attached Files Thumbnail(s)
   
#4
Can you share the RoboDK project (RDK file)?
You may need to set a value for the external axis so targets can be reached.
#5
Actually, I answered my question by myself. I solved it this way :
Code:
target_name = 'Target %i' % (i + 1)
robot.MoveJ(robot.SolveIK(KUKA_2_Pose(Pose_2_KUKA(htm[i+1])), tool=RDK.Item('Tool 1', ITEM_TYPE_TOOL).PoseTool()))
target = RDK.AddTarget(target_name, reference, robot)
program.setSpeed(speed[i])
program.MoveL(target)
RDK.Update()

Thank you

Marc
  




Users browsing this thread:
1 Guest(s)