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

G code coordinates and vector to robot

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:

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

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

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:
pose_n1 = pose_i.Offset(i.x,i.y,i.z).RelTool(i.rx, i.ry, i.rz)

With the first G Code line:

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.
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.
Hi Jeremy,

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

Thank you.
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.
Hi rett,

 You must take care that a code like Gmm Xxx Yxx Zzz Aaa B.0 Ccc linked to a Comau robot will move tool as respect to a plane perpendicular to 5'th joint and paralell to an imaginary plane passing wrist <->4'th joint center axis and 0-deg 6'th rotation joint axis, therefore : command B.0 cannot be executed.
  I try myself in C++ to get same approach but all values must be computed from base plane and compensate every angle  of joints 1..3 in joints 4..6. So far I am stuck at 5'th joint calculation.
  I accept that Euler angles, specified before, put lot of [if statements in program ] specially after 3'rd joint . Your single-man-job is quite hard to end.

Users browsing this thread:
1 Guest(s)