Welcome to JetCobot repository
8. Calibrate the robot gripper
Calibrate the gripper of the robot arm
Note: The Jetcobot robot arm has been calibrated before leaving the factory. Please do not calibrate it unless necessary. If you confirm that you need to calibrate the robot arm, please follow the content of this tutorial.
This course only calibrates the gripper, not the joints of the robot arm.
1. API Introduction
release_servo(id)
Function explanation: Release the torque of a joint of the robot arm. After release, the corresponding servo can be moved by hand.
Parameter explanation:
[id]: Robot arm joint ID number, the value range is 1~7, where the value 7 represents the gripper.
Return value: None
set_gripper_calibration()
Function explanation: Set the current gripper angle to the maximum value of 100.
Parameter explanation:
Return value: None
2. Important code explanation
Code path: ~/jetcobot_ws/src/jetcobot_calibration/scripts/cali_gripper.ipynb
Create three buttons to control the release, calibration, and reading functions of the robot gripper.
x
# 读取机械臂关节角度 Readbutton_Read = widgets.Button( description='Read', button_style='info', # 'success', 'info', 'warning', 'danger' or '' tooltip='Description', icon='uncheck' )
# 校准机械臂 Calibrationbutton_Calibration = widgets.Button( description='Calibration', button_style='success', # 'success', 'info', 'warning', 'danger' or '' tooltip='Description', icon='uncheck' )
# 松开机械臂 Releasebutton_Release = widgets.Button( description='Release', button_style='danger', # 'success', 'info', 'warning', 'danger' or '' tooltip='Description', icon='uncheck' )
# 按键按下事件处理 Key press event processingdef on_button_clicked(b): with output: print("Button clicked:", b.description) if b.description == 'Read': with output: print("read gripper:", mc.get_gripper_value())
elif b.description == 'Calibration': mc.set_gripper_calibration() with output: print("calibration complete") elif b.description == 'Release': mc.release_servo(7) # 关联按键事件回调 Button event callbacksbutton_Read.on_click(on_button_clicked) button_Calibration.on_click(on_button_clicked) button_Release.on_click(on_button_clicked)
3. Run the program
Click the Run the entire program button on the jupyterlab toolbar, and then pull it to the bottom.

You can see three buttons displayed.

Click the [Release] button to release the torque of the gripper, let the gripper be in a free twisting state, and then push the gripper to the maximum angle.

Then click the [Calibration] button to start calibration, which takes about 1 second. Do not change the angle of the gripper before receiving the [calibration complete] prompt. After the calibration is completed, the prompt [calibration complete] will be printed, and the robot arm will be powered on and fixed.

At this time, click [Read] to read the value of the gripper. If the read value is 100 or 99, it means that the calibration is complete.