Project files
16 KB
Machine-translated by Robotheca from the original in Chinese (opens in a new tab). License: GPL-3.0-only (opens in a new tab).
RhinoV2.0 Gripper Control System
This project is an intelligent gripper control system based on DMM motors and pressure sensors, supporting both manual control and PID closed-loop control modes.
Bill of Materials
Required Hardware
1. DMM Motor
- Model: DM4310 (or DM4340, DM6006, etc.)
- Rated Torque: 4.3 N·m (DM4310)
- Control Modes: MIT mode, position-speed mode, speed mode
- Communication Interface: CAN bus
- Power Supply: 24 V DC
- Manufacturer: DMM Technology
- Purpose: Gripper drive actuator
2. USB-CAN Adapter
- Model: DM-FDCAN
- Interface: USB 2.0
- CAN Protocol: CAN 2.0 / CAN-FD
- Baud Rate: Configurable (default 1 Mbps)
- Manufacturer: Damiao Technology
- Purpose: PC-to-motor CAN bus communication
3. 6×6 array pressure sensor (for reference only)
- Model: 6×6 array pressure sensor (36 points)
- Manufacturer: Shenzhen Ligan Technology
- Type: Resistive force-sensitive tactile sensor (FSR)
- Array specification: 6×6 = 36 sensing points
- Single-point size: 2.5 mm × 2.5 mm
- Single-point area: 6.25 mm²
- Communication interface: Serial port (UART)
- Baud rate: 460800
- Data format: Custom protocol (frame header 0xFF66, 78 bytes/frame)
- Application scenarios: Robotic finger grip force identification, tactile feedback
- Purchase link: [Taobao] Return freight insurance https://e.tb.cn/h.7qFeOVKt2sKIyvf?tk=kPtyU7QJ8po (opens in a new tab) MF937 「Original manufacturer humanoid robot finger grip force size resistive force-sensitive multi-point tactile sensor FSR」 Click the link to open directly or search on Taobao
Optional Hardware
- Power supply: 24 V DC power adapter (for motor power)
- CAN bus termination resistor: 120 Ω (at both ends of the CAN bus)
- Connection cables:
- USB data cable (to connect USB-CAN adapter)
- CAN bus cable
- Serial cable (to connect pressure sensor)
Hardware Connection Diagram
Computer ──USB── USB-CAN Adapter ──CAN Bus── DMM Motor
│
└──Serial Port── Pressure Sensor
Environment Installation
System Requirements
- Operating System: Linux (recommended: Ubuntu 18.04+)
- Python Version: Python 3.8+
- Hardware Requirements:
- USB-CAN adapter (Dynamixel DM-FDCAN)
- Dynamixel motor (DM4310 or other models)
- 6×6 array pressure sensor (Shenzhen Ligans Technology)
Installation Steps
1. Clone or download the project
cd /home/wech1ng/Project/
# Skip this step if the project already exists
2. Installing Python Dependencies
cd RhinoV2.0_Gripper_control
# Method 1: Using requirements.txt (recommended)
pip3 install -r requirements.txt
# Method 2: Manual installation
pip3 install PyQt5>=5.15.0
pip3 install numpy>=1.19.0
pip3 install matplotlib>=3.3.0
pip3 install pyserial>=3.5
pip3 install pyusb>=1.2.0
3. Configure USB device permissions
# Add the current user to the dialout group (serial port permissions)
sudo usermod -a -G dialout $USER
# Set USB device permissions (USB-CAN adapter)
sudo chmod 666 /dev/bus/usb/*/*
# Note: Requires re-login or reboot to take effect
4. Verify Installation
# Check Python version
python3 --version
# Check dependency libraries
python3 -c "import PyQt5, numpy, matplotlib, serial, usb; print('All dependency libraries are installed')"
# Check USB-CAN device
python3 dev_sn.py
Expected Output:
Found DM-FDCAN, device-id: device:3,21 SN: 818F9E6ACF42F4147B2EE0FE9382AF11
Quick Start
1. Hardware Connection
Motor Connection
- Connect the USB-CAN adapter to the computer's USB port
- Connect the DMM motor to the CAN bus
- Ensure the motor is powered correctly (24 V)
Sensor Connection
- Connect the pressure sensor to the serial port (usually
/dev/ttyUSB1or/dev/ttyACM0) - Confirm the baud rate is 460800
Sensor Specifications:
- Model: 6×6 array pressure sensor (36 points)
- Manufacturer: Shenzhen Ligan Technology
- Type: Resistive force-sensitive tactile sensor (FSR)
- Single-point size: 2.5 mm × 2.5 mm
- Communication Interface: Serial port (UART)
- Baud Rate: 460800
- Application Scenarios: Robotic finger grip force recognition, tactile feedback
Purchase Reference: Search "humanoid robot finger grip force size resistive force-sensitive multi-point tactile sensor FSR" on Taobao
2. Read the device serial number (important)
Each USB-CAN adapter has a unique device serial number (SN), which must be read and configured in the program first.
# Run the device serial number reading tool
python3 dev_sn.py
Output example:
Found DM-FDCAN, device-id: device:3,21 SN: 818F9E6ACF42F4147B2EE0FE9382AF11
Record this SN code: 818F9E6ACF42F4147B2EE0FE9382AF11
3. Modify the device code in the program
Find this line in the program (usually in the main function or initialization section):
self.control = Motor_Control(1000000, 5000000,
"818F9E6ACF42F4147B2EE0FE9382AF11", # ← Modify here
init_data)
Replace the SN code with your device code.
Files to be modified:
-
gripper_ui_integrated.py (recommended)
- Location: In the
init_hardware()function, around line 667 - Search for:
Motor_Control(1000000, 5000000,
- Location: In the
-
motor_control_pyqt.py
- Location: In the
init_motor()function, around line 295
- Location: In the
-
gripper_control_with_visualization.py
- Location: In the
if __name__ == "__main__":section
- Location: In the
Modification example:
Before modification:
with Motor_Control(1000000, 5000000, "818F9E6ACF42F4147B2EE0FE9382AF11", init_data1) as control:
After modification (assuming your SN is AA96DF2EC013B46B1BE4613798544085):
with Motor_Control(1000000, 5000000, "AA96DF2EC013B46B1BE4613798544085", init_data1) as control:
4. Check serial port devices
# View available serial ports
ls -l /dev/ttyUSB* /dev/ttyACM*
Output example:
/dev/ttyUSB1 # Pressure sensor
/dev/ttyACM0 # Other devices
If the sensor is not on /dev/ttyUSB1, you need to modify the serial port configuration in the program:
# Find this line at the beginning of the program (around line 33)
SERIAL_PORT = '/dev/ttyUSB1' # Change to the actual serial port
5. Running the Program
Recommended: Use the integrated UI program
python3 gripper_ui_integrated.py
Operation steps:
- The program starts and automatically initializes the motor and sensors
- Click the "Enable Motor" button
- Select the control mode:
- Manual control: Switch to the "Manual Control" tab, and click "Open" or "Close"
- PID control: Switch to the "PID Control + Visualization" tab, set the parameters, and click "Start PID Control"
- After use, click "Disable Motor" or simply close the window
Other Programs
# Manual control UI
python3 motor_control_pyqt.py
# Pressure sensor test (with visualization)
python3 test_pressure.py
# PID control + visualization (press 'q' to exit)
python3 gripper_control_with_visualization.py
File Structure
RhinoV2.0_Gripper_control/
├── README.md # This document
├── requirements.txt # Python dependency list
├── dm_README.md # Original Damiao motor documentation
├── dev_sn.py # Device serial number reading tool
│
├── Core Library
│ ├── damiao.py # Damiao motor control library (core)
│ └── src/ # Damiao motor low-level driver
│ ├── __init__.py
│ └── usb_class.*.so # USB-CAN communication library (compiled binary)
│
├── Pressure Sensor Program
│ └── test_pressure.py # Pressure sensor test program (with visualization)
│
├── Single-Function Program
│ └── motor_control_pyqt.py # Motor manual control UI
│
├── Integrated Program (recommended)
│ └── gripper_ui_integrated.py # Integrated UI (recommended) ★
│
└── docs/ # Documentation image resources
├── catkin.png
├── dev.png
└── motor_control.png
Main Program Description
Core Library
damiao.py
- Purpose: Core library for controlling DM (DAMIAO) motors
- Features:
- Motor initialization and configuration
- Control in MIT mode, position-velocity mode, and velocity mode
- Motor enable/disable
- Parameter read/write
- CAN communication management
dev_sn.py
- Purpose: Reads the USB-CAN adapter device serial number
- Function: Enumerates USB devices and displays the device SN code
- Usage:
python3 dev_sn.py
src/usb_class.*.so
- Purpose: USB-CAN adapter communication library (compiled binary file)
- Functions: USB device enumeration, CAN frame transmission/reception, baud rate configuration
- Note: Precompiled libraries for different platforms and Python versions
Pressure Sensor Program
test_pressure.py
- Purpose: Pressure sensor data collection, parsing, and visualization
- Features:
- Serial communication
- Data frame parsing
- Pressure calibration
- Conversion of AD values to pressure/force
- 6×6 sensor array heatmap display
- Real-time data visualization
- Statistical information display
Single-function Programs
motor_control_pyqt.py
- Purpose: Motor manual control GUI program
- Features:
- Open/close button control
- Torque value setting
- Enable/disable management
- Use case: Manual operation of the gripper
Integration Program (Recommended)
gripper_ui_integrated.py ★★★
- Purpose: Complete gripper control system (recommended for use)
- Features:
- Tab 1: Manual Control
- Open/Close buttons
- Torque value adjustment
- Tab 2: PID Control + Visualization
- Left side: PID parameter settings, status display, control buttons
- Right side: Real-time 6×6 sensor heatmap display
- Enable/Disable management
- Automatic resource cleanup
- Tab 1: Manual Control
- Advantages:
- User-friendly interface
- Complete functionality
- Optimized performance, no lag
- Suitable for practical use
Configuration Description
Motor Configuration
Locate the motor initialization section in the program:
init_data1 = []
canid1 = 0x01 # CAN ID of the motor
mstid1 = 0x11 # Master station ID
init_data1.append(DmActData(
motorType=DM_Motor_Type.DM4310, # Motor model
mode=Control_Mode.MIT_MODE, # Control mode
can_id=canid1,
mst_id=mstid1))
Configurable items:
canid1: CAN ID of the motor (default: 0x01)mstid1: Master station ID (default: 0x11)motorType: Motor model (e.g., DM4310, DM4340, DM6006)mode: Control mode (MIT_MODE, POS_VEL_MODE, VEL_MODE)
Sensor Configuration
Basic Configuration
SERIAL_PORT = '/dev/ttyUSB1' # Serial port device
BAUDRATE = 460800 # Baud rate (fixed, cannot be modified)
Sensor Parameters
# Sensor array specifications
SENSOR_COUNT = 36 # Number of sensor points (6x6)
GRID_SIZE = 6 # Grid size
SENSOR_AREA_MM2 = 2.5 * 2.5 # Single-point area (mm²)
SENSOR_AREA_M2 = 6.25e-6 # Single-point area (m²)
# Data frame format
HEADER = b'\xFF\x66' # Frame header
FRAME_SIZE = 78 # Frame size (bytes)
# Frame structure: header(2) + reserved(2) + AD values(72) + checksum(2)
Calibration Parameters
Each sensor point has independent calibration parameters (slope k and intercept b) for converting AD values to pressure:
# Pressure calculation formula
pressure_kPa = k * ad_value + b
# Force calculation formula
pressure_N = pressure_kPa * 1000 * sensor_area_m2
The calibration parameters are built into the program (PressureSensorCalibration class) and do not require manual configuration.
Offset Calibration
In PID control mode, the program will automatically perform offset calibration (zero-point calibration):
- Collect 10 frames of no-load data
- Calculate the average offset value for each sensor
- Subtract the offset value from subsequent measurements
Note: Before starting PID control, ensure that no external force is applied to the sensor surface.
PID Parameters
These can be adjusted in real time in the UI or modified in the code by changing the default values:
self.target_force = 0.15 # Target gripping force (N)
kp = 2.0 # Proportional coefficient
ki = 0.1 # Integral coefficient
kd = 0.0 # Derivative coefficient
FAQ
1. USB-CAN device not found
Error message:
No DM-FDCAN device found
Solution:
- Check if the USB-CAN adapter is connected
- Check the USB cable
- Run
lsusbto see if the device is recognized - Check device permissions:
sudo chmod 666 /dev/bus/usb/*/*
2. Device serial number mismatch
Error message:
Device SN mismatch
Solution:
- Use
python3 dev_sn.pyto read the correct SN code - Modify the SN code in the program to match the actual device's SN code
3. Serial port connection failure
Error message:
could not open port /dev/ttyUSB0: [Errno 2] No such file or directory
Solution:
- Run
ls -l /dev/ttyUSB* /dev/ttyACM*to check available serial ports - Modify
SERIAL_PORTin the program to the actual serial port - Check serial port permissions:
sudo chmod 666 /dev/ttyUSB1 - Add the user to the dialout group:
sudo usermod -a -G dialout $USER(requires re-login)
4. Motor does not respond
Possible causes:
- Motor not enabled: Click the "Enable Motor" button
- Incorrect CAN ID configuration: Check the actual motor ID
- Motor power supply issue: Check the power supply
- CAN bus connection issue: Check cables and terminal resistors
5. Sensor data anomalies
Possible causes:
- Baud rate mismatch: confirm it is 460800
- Serial port device error: check the actual serial port
- Sensor power supply issues
- Loose data cable connection
6. Program cannot exit
Solution:
- Press the 'q' key in the visualization window
- Close the visualization window
- Press Ctrl+C in the terminal
- If stuck, use
kill -9 <pid>
7. Failed to install dependency libraries
PyQt5 installation failed:
# Ubuntu/Debian
sudo apt-get install python3-pyqt5
# Or use a mirror in China
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple PyQt5
pyusb permission issues:
# Create udev rules
sudo nano /etc/udev/rules.d/99-usb.rules
# Add the following content:
SUBSYSTEM=="usb", MODE="0666"
# Reload rules
sudo udevadm control --reload-rules
Development Notes
Dependency Libraries
| Library | Version Requirement | Purpose |
|---|---|---|
| PyQt5 | >=5.15.0 | GUI framework |
| numpy | >=1.19.0 | Numerical computation |
| matplotlib | >=3.3.0 | Data visualization |
| pyserial | >=3.5 | Serial communication |
| pyusb | >=1.2.0 | USB device communication |
Adding a New Motor
Add the motor configuration in damiao.py:
init_data.append(DmActData(
motorType=DM_Motor_Type.DM4310,
mode=Control_Mode.MIT_MODE,
can_id=0x02, # New motor ID
mst_id=0x12))
Modifying the Control Cycle
cycle_time = 0.01 # 10 ms control cycle (100 Hz)
Debug Mode
Add debug output in the program:
print(f"Current force: {current_force:.3f}N")
print(f"Motor output: {motor_output:.3f}N·m")
Safety Precautions
1. First Use
- First test under no-load conditions
- Start testing with a small torque (recommended starting at 0.05 N·m)
- Ensure emergency stop measures are available
- Familiarize yourself with the location of the "Disable Motor" button
2. During Operation
- Ensure there are no obstacles around the gripper
- Do not exceed the motor's rated torque (DM4310: 4.3 N·m)
- Monitor the motor temperature closely
- In case of abnormalities, immediately click "Disable Motor"
3. Exiting the Program
- Prioritize using the "Disable Motor" button
- Ensure the motor has stopped before powering off
- Do not forcefully terminate the process (to avoid the motor remaining in the enabled state)
4. Maintenance
- Regularly inspect cable connections
- Clean sensor surfaces
- Check CAN bus termination resistors
- Record abnormal conditions and parameters
Technical Support
- Dynamixel Motor Documentation: See
dm_README.md - Issue Feedback: Submit an Issue
- Project Maintenance: wech1ng
Changelog
2026-01-30
- Added
requirements.txtfor dependency management - Reorganized README structure
- Moved environment installation instructions to the top
- Added a hardware list section
- Detailed sensor specifications (Shenzhen Ligan Technology 6×6 array pressure sensor)
- Updated sensor configuration instructions (calibration parameters, offset calibration)
- Updated file structure description
- Added a more detailed troubleshooting guide
2026-01-29
- Created integrated UI program
- Fixed visualization stuttering issues
- Optimized interface layout
- Added detailed documentation
2026-01-28
- Initial version
- Implemented basic control functions
License
This project is for educational and research purposes only.
Acknowledgments
Thanks to DMM Technology for providing the motor control library and technical support.
Files by @Ragtime-LAB, at commit 099a3cd, read from GitHub in your browser. Hardware license: GPL-3.0-only; software license: GPL-3.0-only. Robotheca doesn't review code: read it before running it.