GripDirection pick up and drop issue

Video of the issue: https://drive.google.com/file/d/1nN9PxvPva5eXTUpjw0r6JCUN0eJv8Lyg/view?usp=sharing

Code that caused the issue:
await lh.move_plate(init_beads, magnet_stack, pickup_direction=GripDirection.FRONT, drop_direction=GripDirection.BACK)

When the GripDirection argument for pick up and drop do not match, it seems like the robot has the wrong orientation (maybe around 90 degrees). In the video, the robot successfully picks up the plate but fails to drop it down in the correct spot (should be the same rail, just 1 in front). There doesn’t seem to be an issue when both arguments match (i.e. FRONT for both pickup and drop)

2 Likes

this is because the resource is being rotated during the move. The destination of the move is a Coordinate where the left-front-bottom (LFB) of the plate will go. Note that the LFB is wrt the plate, in its own local space. Imagine painting a dot on the plate LFB when it’s defined, that’s the location the coordinate refers to.

This means that when a plate is rotated and moved, the LFB of the plate is not necessarily on top of the LFB of the destination. You have to apply an offset. See diagram:

the location is computed using the utility function get_child_location. This is important when passing a coordinate as the destination. You have to apply the offset when resources are rotated.

(The rationale is that when dropping resources in a non-90 degree rotation, it’s not clear what the LFB is exactly. The LFB in plate local space is the only thing that’s consistent.)

In your case, you’re passing a ResourceStack as the destination. In cases where you pass a Resource, PLR should figure out automatically where the resource goes. In this case we didn’t which is a bug. This PR might fix it: fix moving rotated resource to ResourceStack by rickwierenga · Pull Request #557 · PyLabRobot/pylabrobot · GitHub. Please test & lmk

2 Likes

@ericguan04 @marielle please let me know if this fixes your issue & i can merge

@rickwierenga sorry for the delay - your code changes fixes the issue we had before. Here is a video of what it looks like now: https://drive.google.com/file/d/196SgzqADP_QotBp0pw0pmNX2vEkQ_TmT/view?usp=sharing

as a side note, the initial code we tested last week had pickup FRONT, drop BACK, however this wasn’t actually what we wanted, so the video above shows pickup BACK, drop FRONT - both work either way.

I think the grip direction documentation should be updated with what FRONT, BACK, LEFT, RIGHT means for grip direction. In hindsight, it makes sense that BACK refers to the arm pointing towards the back of the robot, but for someone new a nice visual would be very helpful

2 Likes

thanks! merged

1 Like