This repository implements
Eye-in-Finger: Smart Fingers for Delicate Assembly and Disassembly of LEGO.
It detects and publishes LEGO brick offsets using an endoscope camera placed inside a LEGO manipulation End-Of-Arm Tool (EOAT).
python3 detect_offset.py- Publishes detected offset to
/tool_offsetand detected tilt to/block_tilt.
python3 pub_detect_offset.pypython3 detect_offset_manual.py-
Find the Camera ID for Eye-in-Finger (EiF) for each robot:
python3 find_cam.py
- This script visualizes all the cameras connected to the computer.
- Note down the camera ID corresponding to the correct camera feed for each robot.
- Note:
find_cam.pydoes not work in headless mode.
-
Publish the Camera Feed as a CompressedImage at the rostopic
/yk_{robot_name}/gen3_image:python3 pub_camera_feed.py robot_name camera_id
robot_nameshould not include the "yk_" prefix.camera_idshould be a number.
Example:
python3 pub_camera_feed.py destroyer 1
-
Receive the Camera Feed and Publish the Calculated Offset:
python3 compressed_pub_detect_offset.py destroyer
- This publishes the offset (in the tool frame) to the topic
/yk_{robot_name}/tool_offset.
- This publishes the offset (in the tool frame) to the topic
-
Check Camera Position in EiF
- The bottom (the side with the wire) of the endoscope camera should be aligned flush with the rear (the side closer to the tool base) of the tool head of EiF.
Adjust Height:
- Loosen the screw on the tool head that's clamping down on the camera.
- Move the camera to the correct position, then tighten the screw to lock it in place.
-
Ensure Correct Camera Orientation
- Open the camera app and switch to the EiF camera feed.
- Observe the occlusion caused by the tool head:
- The side with one protrusion should appear on the right.
- The side with two protrusions should also appear on the right.
- They should line up mostly horizontally; small tilting (up to ±10 degrees) is acceptable.
Adjust Camera Orientation:
- Loosen the screw on the tool head that's clamping down on the camera.
- Rotate the camera until the correct alignment is achieved, then tighten the screw to lock it.
- It is recommended to hold the camera steady by the wire and rotate the tool head instead.
-
Calibrate Zero Position
(Do this if the offset detected by EiF is not close to zero when the tool is precisely lined up with the brick.)
- Manually go to an accurate pick position.
- Move EiF height to
$h_{peek}$ . - Adjust the global variable
TOOL_CENTERindetect_offset.pyuntil the detected offset is close to zero.
-
Calibrate Offset Magnitude
(Do this if the detected offset has the correct orientation but an incorrect magnitude, e.g., true offset = [1.0, -0.6], detected offset = [0.7, -0.4].)
- Move EiF to
$h_{peek}$ , manually move the robot until the detected offset is zero. - Jog the robot by
$dx, dy$ , record the detected offset by EiF$dex, dey$ . - Compute the error ratio of detection vs ground truth
$er = \text{avg}(dex/dx, dey/dy)$ . - In
compute_offset()indetect_offset.py, the default argumentzis set to 30mm (this is just a number and does not reflect actual height). Replacezwithnew_z = z * er. - Retry steps 1-2 to verify if the detected offset is now correct.
- Move EiF to
-
Adjust Camera Distance to Brick When Computing Offset
(Default peek height $h_{peek}$ is 17mm above pick-down height $h_{down}$. You should only need to perform this adjustment if a different camera with different focal characteristics is used.)
(The segmentation model is trained for approximately 17mm above LEGO blocks. Using a different height may cause the model to malfunction.)
- From
$h_{down}$ , move the camera upward until the image of the LEGO block is crisp and the model correctly segments the LEGO knobs. This can be checked by running:
python3 detect_offset.py
- Ensure that
show_yolo = Truewhen callingcompute_offset().
-
Record the current height of the tool
$h_{peek}$ , calculate the difference$h_{diff} = h_{peek} - h_{down}$ , and configure the robot to move to$h_{diff}$ above the LEGO block for offset detection before picking up. -
Part of the knob detection relies on the estimated knob size based on height. If the height changes (or a camera with a different focal length is used), you may notice that the green circles in the visualization are consistently larger or smaller than the actual knobs.
- If this happens, go to the
cost_function()indetect_offset.py, and modifyexpected_radiusto match the estimated radius (in pixels) of the knobs at the new camera height.
- You will likely need to perform Calibrate Zero Position and Calibrate Offset Magnitude afterwards.
- From