Skip to content

C++ SDK - Revo 2 Dexterous Hand

System Requirements

  • Linux: Ubuntu 20.04/22.04 LTS (x86_64/aarch64), glibc ≥ 2.31
  • macOS: 10.15+
  • Windows: 10/11

Quick Start

Clone Repository

shell
git clone https://github.com/BrainCoTech/brainco-hand-sdk.git
shell
git clone git@github.com:BrainCoTech/brainco-hand-sdk.git

Installation & Configuration

shell
# Install dependencies
# Required: build-essential, cmake, make, gcc, g++, etc.

# Install SDK dependencies
./download-lib.sh

# Configure device permissions
# In Linux, serial devices (e.g., /dev/ttyUSB0) typically belong to dialout or tty group
# Only group members can access the device, for example:
# crw-rw---- 1 root dialout 188, 0 Aug 14 12:00 /dev/ttyUSB0

# Add current user to dialout group
sudo usermod -aG dialout $USER
# Note: You need to log out and log back in for this to take effect

# Build and run example (unified cross-platform directory)
cd c && make
cd demo && ./hand_demo.exe    # Auto-detect device and run
shell
# Install Xcode or Xcode Command Line Tools
xcode-select --install

# Install SDK dependencies
./download-lib.sh

# Build and run example (unified cross-platform directory)
cd c && make
cd demo && ./hand_demo.exe    # Auto-detect device and run
shell
# Requires MinGW or MSVC build environment

# Install SDK dependencies
./download-lib.sh

# Build and run example (unified cross-platform directory)
cd c && make
cd demo && hand_demo.exe      # Auto-detect device and run

Example Code

The SDK provides comprehensive example code covering different communication protocols and application scenarios.

Unified cross-platform examples with auto-detection and multi-protocol support.

shell
cd c
make
cd demo
./hand_demo.exe       # Auto-detect device and run demo
ExampleDescription
hand_demo.cppComprehensive demo (8 modes: position/speed/current control, action sequences, touch sensors, etc.)
hand_monitor.cppReal-time data monitor (motor status, touch data)
hand_dfu.cppFirmware upgrade
auto_detect.cppDevice auto-detection

Supported initialization methods:

shell
./hand_demo.exe                                          # Auto-detect (recommended)
./hand_demo.exe -m /dev/ttyUSB0 460800 127               # Modbus
./hand_demo.exe -c /dev/cu.usbmodem14201 1000000 1       # CAN 2.0 (ZQWL)
./hand_demo.exe -f /dev/cu.usbmodem14201 1000000 5000000 127  # CANFD (ZQWL)
./hand_demo.exe -s can0 1                                # SocketCAN CAN 2.0 (external adapter)
./hand_demo.exe -S can0 127                              # SocketCAN CANFD (external adapter)
./hand_demo.exe -b can0 1                                # SocketCAN CAN 2.0 (SDK built-in)
./hand_demo.exe -B can0 127                              # SocketCAN CANFD (SDK built-in)
./hand_demo.exe -z 2                                     # ZLG CAN 2.0
./hand_demo.exe -Z 127                                   # ZLG CANFD

Legacy Protocol Examples (Archived)

⚠️ The following examples have been archived to archive/. We recommend using the Cross-Platform Examples (c/demo/) above, which support auto-detection of all protocols and devices.

Modbus-RTU Protocol

CANFD Protocol

EtherCAT Protocol

API Reference

For C/C++ API lookup, use the complete C ABI header bundled with the bc-stark-sdk (v2.x) package: Download stark-sdk.h. The quick reference below covers the most commonly used APIs.

API Quick Reference

Initialization and Configuration

APIDescription
init_logging()Initialize SDK logging
APIDescription
stark_auto_detect()Auto-detect devices (all protocols) ⭐
init_from_detected()Initialize from detected device ⭐
close_device_handler()Close device connection (unified) ⭐
list_zqwl_devices()List ZQWL CAN/CANFD devices ⭐
init_zqwl_canfd()Initialize ZQWL CANFD device
init_zqwl_can()Initialize ZQWL CAN 2.0 device
close_zqwl()Close ZQWL device
list_socketcan_devices()List available SocketCAN interfaces (Linux) ⭐
init_socketcan_canfd()Initialize SocketCAN CANFD interface (Linux)
init_socketcan_can()Initialize SocketCAN CAN 2.0 interface (Linux)
close_socketcan()Close SocketCAN interface (Linux)
scan_can_devices()Scan CAN bus for devices

Connection Management (Legacy)

APIDescription
modbus_open()Open Modbus connection
modbus_close()Close Modbus connection
init_device_handler()Create device handler (CAN/CANFD/EtherCAT, manual adapter management)
init_device_handler_with_hw_type()Create device handler with pre-set hardware type (skip get_device_info) ⭐
auto_detect_device()Auto-detect device (Modbus only)
auto_detect_modbus_revo2()Auto-detect Revo 2 device (Modbus only)
list_available_ports()List available serial ports

Device Information

APIDescription
stark_get_device_info()Get complete device information
stark_is_touch_device()Check if touch-enabled ⭐
stark_uses_revo1_motor_api()Check if uses Revo 1 Motor API ⭐
stark_uses_pressure_touch_api()Check if uses Pressure Touch API ⭐
stark_get_touch_vendor()Get touch sensor type ⭐
stark_get_voltage()Get device voltage
stark_get_rs485_baudrate()Get RS485 baud rate
stark_set_rs485_baudrate()Set RS485 baud rate
stark_get_canfd_baudrate()Get CANFD baud rate
stark_set_canfd_baudrate()Set CANFD baud rate
stark_set_slave_id()Set slave ID

Device Configuration

APIDescription
stark_get_force_level()Get force level
stark_set_force_level()Set force level
stark_get_auto_calibration_enabled()Get auto-calibration status
stark_set_auto_calibration()Set auto-calibration
stark_calibrate_position()Manual position calibration
stark_get_turbo_mode_enabled()Get turbo mode status
stark_set_turbo_mode_enabled()Set turbo mode
stark_get_turbo_config()Get turbo configuration
stark_set_turbo_config()Set turbo configuration
stark_reboot()Reboot device

Motor Control - Position (Unified Range 0-1000)

APIDescription
stark_set_finger_position()Set single finger position
stark_set_finger_position_with_millis()Set position with duration ⭐
stark_set_finger_position_with_speed()Set position with speed ⭐
stark_set_finger_positions()Set all finger positions
stark_set_finger_positions_and_durations()Set positions with durations ⭐
stark_set_finger_positions_and_speeds()Set positions with speeds ⭐
stark_get_finger_positions()Get all finger positions

Motor Control - Speed (Unified Range -1000~+1000)

APIDescription
stark_set_finger_speed()Set single finger speed
stark_set_finger_speeds()Set all finger speeds
stark_get_finger_speeds()Get all finger speeds

Motor Control - Current (Unified Range -1000~+1000)

APIDescription
stark_set_finger_current()Set single finger current
stark_set_finger_currents()Set all finger currents
stark_get_finger_currents()Get all finger currents

Motor Control - PWM (Unified Range -1000~+1000) ⭐

APIDescription
stark_set_finger_pwm()Set single finger PWM
stark_set_finger_pwms()Set all finger PWMs

Motor Status

APIDescription
stark_get_motor_status()Get comprehensive motor status
stark_get_motor_state()Get motor running state

Motor Settings ⭐

APIDescription
stark_get_finger_unit_mode()Get unit mode
stark_set_finger_unit_mode()Set unit mode
stark_get_finger_min_position()Get minimum position limit
stark_set_finger_min_position()Set minimum position limit
stark_get_finger_max_position()Get maximum position limit
stark_set_finger_max_position()Set maximum position limit
stark_get_finger_max_speed()Get maximum speed limit
stark_set_finger_max_speed()Set maximum speed limit
stark_get_finger_max_current()Get maximum current limit
stark_set_finger_max_current()Set maximum current limit
stark_get_finger_protected_current()Get protected current
stark_set_finger_protected_current()Set protected current
stark_get_thumb_aux_lock_current()Get thumb aux lock current
stark_set_thumb_aux_lock_current()Set thumb aux lock current

Touch Sensors

APIDescription
stark_get_touch_sensor_enabled()Get touch sensor enabled status
stark_get_touch_sensor_fw_versions()Get touch sensor firmware versions
stark_get_touch_sensor_raw_data()Get touch raw data
stark_get_touch_sensor_status()Get touch sensor status
stark_touch_sensor_setup()Setup touch sensors
stark_touch_sensor_reset()Reset touch sensors
stark_touch_sensor_calibrate()Calibrate touch sensors

Force3D Touch Sensors ⭐

APIDescription
stark_get_force3d_touch_summary()Get 4-finger force summary (FxFyFz)
stark_get_force3d_finger_array()Get full array data for single finger (31 channels)

ArrayPressure Sensors ⭐

APIDescription
stark_get_array_pressure_touch_data()Get full array pressure data
stark_set_array_pressure_sleep()Set array sensor sleep status

High-Performance Data Collection ⭐

APIDescription
motor_buffer_new()Create motor status buffer
motor_buffer_free()Free motor status buffer
motor_buffer_pop_all()Get all motor data
touch_buffer_new()Create touch status buffer
touch_buffer_free()Free touch status buffer
pressure_summary_buffer_new()Create pressure summary buffer
pressure_detailed_buffer_new()Create pressure detailed buffer
data_collector_new_basic()Create basic collector
data_collector_new_capacitive()Create capacitive touch collector
data_collector_new_pressure_summary()Create pressure summary collector
data_collector_new_pressure_detailed()Create pressure detailed collector
data_collector_new_pressure_hybrid()Create hybrid mode collector
data_collector_new_force3d()Create Force3D collector
data_collector_new_array_pressure()Create ArrayPressure collector
data_collector_new_v3_basic()Create Revo3 basic collector
data_collector_new_v3_full()Create Revo3 full collector
data_collector_start()Start data collection
data_collector_stop()Stop data collection
data_collector_wait()Wait for collection thread
data_collector_free()Free data collector

LED, Buzzer, Vibration ⭐

APIDescription
stark_get_led_enabled()Get LED enabled status
stark_set_led_enabled()Set LED enabled status
stark_get_buzzer_enabled()Get buzzer enabled status
stark_set_buzzer_enabled()Set buzzer enabled status
stark_get_vibration_enabled()Get vibration enabled status
stark_set_vibration_enabled()Set vibration enabled status

Action Sequences

APIDescription
stark_get_action_sequence()Get action sequence
stark_transfer_action_sequence()Upload action sequence
stark_run_action_sequence()Execute action sequence

EtherCAT Specific ⭐

APIDescription
stark_ec_setup_sdo()Setup SDO
stark_ec_start_loop()Start cyclic loop
stark_ec_stop_loop()Stop cyclic loop
stark_ec_start_dfu()Start firmware upgrade

Firmware Upgrade

APIDescription
stark_start_dfu()Start firmware upgrade

⭐ Indicates Revo2-specific or enhanced features

Help