How to move robot X positions with variables

So there’s a couple options here. First off, moving your TCP along a Feature’s reference frame by an arbitrary offset is NOT (in my opinion) a very simple process. I have this link bookmarked, and used it again just today, actually.

His solution works perfectly. The only thing to note is that the “get_actual_tcp_pose()” function can be substituted for any pose you wish to shift along the given feature. So if you wanted to shift, say, some arbitrary point out in space, you’d put that pose there instead of the get_actual_tcp_pose().

(I think he also has one too many closing parenthesis on the second line but no big deal)

You can condense it all into one function call if you’d like. I use this function/script pretty often actually:

def getOffsetRelativeToFeature(x_offset, y_offset, z_offset, feature, poseToShift):
  return pose_trans(feature, pose_add(pose_trans(pose_inv(feature), poseToShift), p[x_offset, y_offset, z_offset, 0,0,0]))
end

If you look at that and think “what the heck is going on”, welcome to the club. I won’t pretend I actually know what’s going on there, all credit goes to the guy in the link. But it will shift x_offset in the x direction, y_offset in the y direction, and z_offset in the z direction of the provided feature’s frame.

Then to call this function from polyscope, be sure to pass whatever offsets you want for x y and z, and pass the CONST version of the feature (found in the Pose dropdown), and then pass whatever pose you want to shift. In your case I think you’d pass “get_actual_tcp_pose().” In your case I would pass your x_offset * loop_counter into the function for your x_offset.

However, all this is to say you might want to check out the Palletizing node built in to polyscope. It is supposed to help make it easier to move your robot to a grid of positions.(I confess I find it somewhat difficult to get right, and tend to avoid it)

Lastly, you can actually just change your feature programmatically at run time and your moves will shift along with it. You can try using an Assignment node, choose the feature from the VARIABLE dropdown (not the Pose dropdown), and just assign it pose_add(feature, p[offset, 0,0,0,0,0]. Just be sure to reassign it to feature_const if your program needs to reset back to the start.

Not exactly sure of your situation. From your post I think you actually want the first method, since you mention specifically wanting to move along your Feature’s reference frame. If that orientation is different than base, that’s definitely the way to go. If it shares the same orientation as base, just shifting the feature is likely an easy alternative.

1 Like