The script command get_actual_tcp_pose() defaults to base feature coordinates. I want to get TCP coordinates inside a plane feature that I have defined (I need the x and y coordinates as offsets for a variable waypoint calculation for movement inside that feature plane). How can I do this using script commands?
Edit: I’d like to provide a bit more detail…I’ve read a few posts and attempted to use pose_trans() but it’s not giving me the results I expect. This is probably basic, but I’m relatively new to this and I can’t figure out what I’m doing wrong.
The description I’ve read of pose_trans() shows me this:
What I want to do is this:
So far I can’t get this to work…any ideas would be greatly appreciated!
I’ve answered my own question. So for anyone else who runs into this,
result=pose_trans(pose_inv(pose2),pose1)
x offset = result[0]
y offset = result[1]
Assuming, of course, that your x and y axes of the feature plane and your tool are pointing the same direction. If not, it should be a simple 2D coordinate transformation if you know the angle of rotation.
get_actual_tcp_pose() will give you “Base to TCP” pose_inv( get_actual_tcp_pose() ) will give you “TCP to Base”.
The “pose1” is the vector “Base to Feature”.
pose_trans( "TCP to Base", "Base to Feature" ) will give you “TCP to Feature”.
Hence you might want to call the pose_inv() to get “Feature to TCP”
From your description, it sounds like you are on track, but you can check by going to the move tab, then under “feature” in the upper right-hand corner, choose the feature you want in the drop-down menu. Just below that, it shows the x,y,z and Rx, Ry, Rz of your tool center point. The x and y values displayed there should match the x and y value of your current_to_feature (make sure the tool center point shown is the one you are using).
Are the axes of your feature pointing the same direction as the axes of the base feature? If not, you will also have to perform a coordinate rotation to get the correct values, since get_actual_tcp_pose() returns only base coordinates. We worked out coordinate rotation here: