Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move the robot using the Python script : toolframe not aligned with target normals
I feel like this might be an obvious answer, but when moving the robot in the pythonapi over a rotating userframe from a turntable it looks like the tool aligns with the z-axis of the userframe instead of the normal of the target. 

I have included an rdk file that illustrates this. This python code will not run as it is dependent on an external library, but I have generated the program 'rep_path' to review. I currently have an arbitrary tool offset of "orient_frame2tool= roty(pi/2)*rotz(pi/2)" inserted in to force the tool in the proper orientation so I can see what is going on, but I think I shouldn't have to add this in.

The relevant function is def draw_path(rbt, uframe, utool, poses):

I believe I am declaring the userframe and toolframe correctly. 

My goal is to keep the toolhead straight as the curve rotates underneath it. From adding the curve I believe my normals are correct. Experimenting with a machining project I also believe this to be the case. 

The input data is a [x,y,z,r,p,w] list and I am converting it with xyzrpw_2_pose, and then modifying the external rotary axis with
hs_pos = atan2(trans_path[j][0], trans_path[j][1])* 180 / pi
external_axes = [rail_pos, hs_pos]
target.setJoints([0,0,0,0,0,0] + external_axes)

where trans_path[j][0], and trans_path[j][1] are the x,y coordinates respectively. This will rotate the turntable underneath the end effector as it completed the motion. However the toolframe does not seem to be aligned with the normals as the curve is rotating, however it does appear to be aligned with the rotating reference frame.

Can you explain what is going on here, and how I can fix it.

Your help is much appreciated :)



Attached Files
.py (Size: 14.56 KB / Downloads: 9)
.rdk   robodk_help_toolframe.rdk (Size: 1.28 MB / Downloads: 11)
Hi Matt,

Since you are rotating the turntable but you want the robot to remain in the same area you may want to rotate the target. Otherwise, the target moves relatively to the reference frame held by the robot.

To rotate a target with respec to the turntable coordinate system you could do something like this:

hs_pos = atan2(trans_path[j][0], trans_path[j][1])* 180 / pi
external_axes = [rail_pos, hs_pos]
target.setJoints([0,0,0,0,0,0] + external_axes)
target.setPose(rotz( -hs_pos) * p_i*orient_frame2tool)

Note the rotation around Z (rotz premultiplication) of your target pose (negative angle to compensate for the turn). This assumes the target is given with respect to a coordinate system where the Z axis is along the turning axis. You may need to invert
I'm unable to run your example as the sample scan data is missing.
So I got it to work using 

 as the curves are aligned to z-world when the turntable is at -90.
Thank you so much for you help again Albert,

You are great!

Users browsing this thread:
1 Guest(s)