Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
G code coordinates and vector to robot
#1
Hello all,

I created a program in Python that decodes a NC file posted for a 5 axis CNC machine. The NC file has X Y Z coordinates plus I J K tool vector. I'm simulating a Comau robot, but could be any robot. 

First I set Joint angles:
Code:
robot.setJoints([0,-20,-115,0,83,0])


Then I can successfully move the robot in the X Y Z plane using the offset instruction as below:
Code:
for i in vetor:

pose_n1 = pose_i.Offset(i.x, i.y, i.z)
                         
robot.MoveL(pose_n1)

But I'm not sure what how to get proper tool orientation from I J K 

I tried to convert each I value, J value and K value with ACOS() then from rad to angle and used those values in the code below:
Code:
pose_n1 = pose_i.Offset(i.x,i.y,i.z).RelTool(i.rx, i.ry, i.rz)


With the first G Code line:

Code:
G00 X100.113 Y-5.049 Z12.822 A.383 B0. C.924 F10


I get an Exception: Target cannot be reached. Executing the code without the Tool angles runs fine. 

I think I'm not doing the proper way. I appreciate if someone can point me in the right direction.

Thank you.
#2
Hi rett84,

I'm not the guy to help you with the API situation, but did you know that you can import most NC files directly in RoboDK without using the API?
Just drag and drop you NC file in RoboDK and see what happens. (You may want to already have a robot, a tool and an empty reference frame in your station.)

Have a great day.
Jeremy
#3
Hi Jeremy,

Thanks for your reply. Yes, I am aware of the import option but I want to try a different approach.


Thank you.
#4
This error message:
Exception: Target cannot be reached.
Means the robot can't reach the target.

As a test I would recommend smaller rotation movements to better understand the order of rotation. The Euler rotation applied by RelTool may not match your machine definition so you may have to calculate your rotation instead of using RelTool.
  




Users browsing this thread:
1 Guest(s)