👉SDK C/C++
This SDK development kit aims to provide convenient C/C++ interfaces and accompanying sample code for the secondary development of the OYMotion dexterous hand. Through the sample demos, users can easily implement a series of core functions such as precise control of the dexterous hand's fingers, device status monitoring, and flexible parameter configuration, helping developers quickly build applications and shorten the development cycle.
👉Download the SDK
-
Method 1: Click this link ohand_serial_sdk to directly download the development kit
-
Method 2: Visit ohand_serial_sdk_python Github page to download the latest SDK.
-
Method 3: Obtain via clone:
git clone https://github.com/oymotion/ohand_serial_sdk
👉Introduction to the demos
The following example demos are designed around the core functional development needs of the OYMotion dexterous hand, covering full-scenario applications from basic control to advanced configuration. Each example provides complete and runnable C/C++ code, including clear interface calling logic and process comments. Developers can directly compile and run to verify functions, and can also quickly adapt to their own application scenarios based on the example code.
1. custom_cmd_test
This example program supports UART and CAN ports for device communication, and also supports customized interfaces to achieve high-speed reading and writing of dexterous hand-related control parameters. It is suitable for scenarios that require fine-tuning of device operating parameters and real-time acquisition of core control data, providing underlying parameter operation support for personalized function development.
2.grip_exec
This example program implements control of the dexterous hand based on predefined gestures and includes complete functions such as communication establishment and status checking.
3.set_id
This example program allows users to set the ID of the dexterous hand by entering an ID number, enabling flexible device management.
4.simple_control
This example program supports UART and CAN ports for device communication, achieving simple control of the dexterous hand through cyclic gesture actions via both protocols. The code is lightweight and easy to understand, suitable for developers to quickly familiarize themselves with the dual-protocol communication process and build a basic framework for complex control scenarios.
👉Instructions for Using the Development Kit
Windows Enviroment for Using Instructions
1. Supported Compilers
-
MSVC version: MSVC 2019/2022, featuring good compatibility with Windows systems and support for the latest C language standards, which can meet the compilation requirements in development.
-
CMake version: 3.5 or higher
-
C++ version: C++11 or higher
2. Development Kit Description
- header files: C/C++ language development kit includes the following header files:
- log.h: Log header file, provides log level control functions
-
OHandGripExec.h: Defines multiple gestures and provides execution functions for the defined gesture controls
-
OHandSerialAPI.h: Dexterous hand interface header file, defines related functions for dexterous hand operations
-
Dynamic Link Library(DLLs): Contains the functions and interfaces required to control the dexterous hand, includes the following two versions:
- debug: Debug version for Windows 64-bit compilers, includes debug information, suitable for development phase
- release: Release version for Windows 64-bit compilers, optimized without debug information, suitable for deployment and execution
Linux Enviroment for Using Instructions
1. Supported Architectures
- x86: Standard Intel and AMD processor architectures
- ARM: Suitable for ARM architecture processors
2. Compiler
- GCC: GNU Compiler Collection(GCC)is a widely used open-source compiler collection for Linux. The compiler requires GCC version 11.4 or higher to ensure optimal performance and compatibility.
3. System Version
- Ubuntu 22.04: Based on Ubuntu 22.04 Linux system, includes GCC version 11 or higher compilers
4. Development Kit Description
- Header files: Same as Windows header files, for details please refer to the Windows environment development kit documentation
- 库文件(.a文件): Contains the functions and interfaces required to control the dexterous hand
👉Usage Example-MSVC
Example Project: simple_control, environment preparation:
-
The project path is located under the D: drive partition
-
Visual Studio community 2022 version:
- During installation, select "Desktop development with C++"
- MSVC 2022 version
1. Explanation
This sample project is developed using Microsoft Visual Studio C/C++, aiming to demonstrate the simple implementation process of programmatically controlling a dexterous hand.
2. Install serial Library
Click serial(github) or serial(Offline compressed package) to download the open-source project, open visual_studio/visual_studio.sln in the directory, and compile it. Place the compiled folder in the same partition as this project. Your serial folder structure should look like the following:
d:\serial
├─include
│ └─serial
│ │ serial.h
│ │ v8stdint.h
│ │
│ └─impl
│ unix.h
│ win.h
│
└─lib
├─Debug
│ serial.idb
│ serial.lib
│ serial.pdb
│
└─Release
serial.lib
serial.pdb
3. Install PCAN-USB Driver
Click PCAN-USB(Official Website) to download and install PCAN-USB driver.
4. Install PCAN-Basic Library
Click PCAN-Basic to download and extract the PCAN-Basic library. Place it in the same partition as this project, the path should be as follows: d:\PCAN-Basic
5. Compile
In main.cpp, the protocol type can be modified through the macro definition PORT_TYPE, for example:
- RS485:
PORT_TYPE = PORT_TYPE_UART - CAN:
PORT_TYPE = PORT_TYPE_CAN
Open the command line window and perform the following operations:
- Enter the project directory and compile
cd path\to\project
md build
cd build
cmake ..
- Compile Debug version
cmake --build . --config Debug
- Compile Release version
cmake --build . --config Release
6. Run
Open the command line window and perform the following operations:
- Enter the Debug or Release directory
cd path\to\project\build\Debug
- run program(serial), Replace COMx with the actual serial port number
simple_control COMx
- run program(can), Replace x with the actual serial port number
simple_control x
👉Interface Description
Header File Protection and External Declarations
防止头文件被重复包含,同时支持 C++ 编译器对 C 代码的兼容处理
#ifndef __HAND_SERIAL_API_H__
#define __HAND_SERIAL_API_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif //__HAND_SERIAL_API_H__
Basic Type Definitions
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef BOOL
#define BOOL uint8_t
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
Constant Definitions
#define MAX_THUMB_ROOT_POS 3
#define MAX_MOTOR_CNT 6
#define MAX_FORCE_ENTRIES 12 * 5
- MAX_THUMB_ROOT_POS: Maximum gear position corresponding to thumb base rotation
- MAX_MOTOR_CNT: Maximum number of motors
- MAX_FORCE_ENTRIES: Maximum number of force sensor data entries per single finger
Protocol Version
Protocol Major Version Number
#define PROTOCOL_VERSION_MAJOR 3
Enum Definitions
typedef enum
{
HAND_PROTOCOL_UART,
HAND_PROTOCOL_I2C
} HAND_PROTOCOL;
- Defines the communication protocol types supported by the Hand device , including both UART and I2C
Error Code Definitions
1. Protocol-Related Errors
#define ERR_PROTOCOL_WRONG_LRC 0x01
- ERR_PROTOCOL_WRONG_LRC: LRC Checksum Error
2. Command-Related Errors
#define ERR_COMMAND_INVALID 0x11
#define ERR_COMMAND_INVALID_BYTE_COUNT 0x12
#define ERR_COMMAND_INVALID_DATA 0x13
- ERR_COMMAND_INVALID: Invald command
- ERR_COMMAND_INVALID_BYTE_COUNT: Invalid command byte count
- ERR_COMMAND_INVALID_DATA: Invalid command data
3. Status-Related Errors
#define ERR_STATUS_INIT 0x21
#define ERR_STATUS_CALI 0x22
#define ERR_STATUS_STUCK 0x23
- ERR_STATUS_INIT: Initialization status error
- ERR_STATUS_CALI: Calibration status error
- ERR_STATUS_STUCK: Motor stuck error
4. Operation Result Related Errors
#define ERR_OP_FAILED 0x31
#define ERR_SAVE_FAILED 0x32
- ERR_OP_FAILED: Operation failed
- ERR_SAVE_FAILED: Save failed
Device Operation Return Value
#define HAND_RESP_HAND_ERROR 0xFF
#define HAND_RESP_SUCCESS 0x00
#define HAND_RESP_TIMER_FUNC_NOT_SET 0x01
#define HAND_RESP_INVALID_CONTEXT 0x02
#define HAND_RESP_TIMEOUT 0x03
#define HAND_RESP_INVALID_OUT_BUFFER_SIZE 0x04
#define HAND_RESP_UNMATCHED_ADDR 0x05
#define HAND_RESP_UNMATCHED_CMD 0x06
#define HAND_RESP_DATA_SIZE_TOO_BIG 0x07
#define HAND_RESP_DATA_INVALID 0x08
- HAND_RESP_HAND_ERROR: Device error, specific error code needs to be obtained through callback
- HAND_RESP_SUCCESS: Device response success
- HAND_RESP_TIMER_FUNC_NOT_SET: Timer function not set, need to call HAND_SetTimerFunction() to set the callback function
- HAND_RESP_INVALID_CONTEXT: Invalid context, context is NULL or send function is not set
- HAND_RESP_TIMEOUT: Timeout error, waiting for node response timeout
- HAND_RESP_INVALID_OUT_BUFFER_SIZE: Output buffer size mismatch
- HAND_RESP_UNMATCHED_ADDR: Node address mismatch
- HAND_RESP_UNMATCHED_CMD: Command mismatch
- HAND_RESP_DATA_SIZE_TOO_BIG: Data size exceeded, sent data exceeds buffer size
- HAND_RESP_DATA_INVALID: Invalid data content
Custom Command Sub-Command Definitions
Used for HAND_SetCustom() to achieve high-speed read/write functionality for dexterous hand related control parameters
#define SUB_CMD_SET_SPEED (1 << 0)
#define SUB_CMD_SET_POS (1 << 1)
#define SUB_CMD_SET_ANGLE (1 << 2)
#define SUB_CMD_GET_POS (1 << 3)
#define SUB_CMD_GET_ANGLE (1 << 4)
#define SUB_CMD_GET_CURRENT (1 << 5)
#define SUB_CMD_GET_FORCE (1 << 6)
#define SUB_CMD_GET_STATUS (1 << 7)
Create Context HAND_CreateContext()
- Method Prototype:
void *HAND_CreateContext(
const void *ctx_private_data,
HAND_PROTOCOL protocol,
uint8_t address_master,
void (*SendDataImpl)(uint8_t addr, uint8_t *data, uint8_t size, void *ctx),
void (*RecvDataImpl)(void *ctx)
)
-
Parameter Description:
Parameter Description ctx_private_dataContext private data (such as serial port instance address) protocolCommunication protocol (UART or I2C) address_masterMaster node address SendDataImplSend data function pointer RecvDataImplReceive data function pointer -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example
void* port = NULL;
void* hand_ctx = NULL;
void* init(const char* port_name, uint32_t baudrate)
{
// Serial port initialization code omitted here
return port;
}
void send_data(uint8_t addr, uint8_t* data, uint8_t len, void* hand_ctx)
{
// Data transmission logic omitted here
}
void recv_data(void* hand_ctx)
{
// Data reception logic omitted here
}
port = init(port_name, baud_rate);
hand_ctx = HAND_CreateContext(port, HAND_PROTOCOL_UART, ADDRESS_MASTER, send_data, recv_data);
Free Context HAND_FreeContext()
- Method Prototype:
void HAND_FreeContext(void *ctx)
-
Parameter Description:
Parameter Description ctxOHAND context -
Usage Example
HAND_FreeContext(hand_ctx);
Timer Settings HAND_SetTimerFunction()
- Method Prototype:
void HAND_SetTimerFunction(uint32_t (*GetMilliSecondsImpl)(void), void (*DelayMilliSecondsImpl)(uint32_t ms))
-
Parameter Description:
Parameter Description GetMilliSecondsImplFunction pointer to get milliseconds DelayMilliSecondsImplMillisecond delay function pointer -
Usage Example
uint32_t millis()
{
chrono::time_point<chrono::system_clock, chrono::milliseconds> tp = chrono::time_point_cast<chrono::milliseconds>(chrono::system_clock::now());
auto tmp = chrono::duration_cast<chrono::milliseconds>(tp.time_since_epoch());
time_t timestamp = tmp.count();
static uint64_t startTime = (uint64_t)timestamp;
return (uint32_t)(timestamp - startTime);
}
void delay(uint32_t millisecondsToWait)
{
this_thread::sleep_for(chrono::milliseconds(millisecondsToWait));
}
HAND_SetTimerFunction(millis, delay);
Get Timestamp HAND_GetTick()
- Method Prototype:
uint32_t HAND_GetTick(void)
- Usage Example
uint32_t current_tick = HAND_GetTick();
Set Timeout Command HAND_SetCommandTimeOut()
- Method Prototype:
void HAND_SetCommandTimeOut(void *ctx, uint16_t timeout)
-
Parameter Description:
Parameter Description ctxOHand context timeoutTimeout time (milliseconds) -
Usage Example
HAND_SetCommandTimeOut(hand_ctx, 255); // Set timeout time to 255 milliseconds
Data Processing HAND_OnData()
- Method Prototype:
void HAND_OnData(void *ctx, uint8_t data)
-
Purpose: Feed received data into the internal parser, should be called in the receive function (RecvDataImpl) or interrupt service routine (ISR)
-
Parameter Description:
Parameter Description ctxOHand OHand context dataReceived byte data -
Usage Example
// Assuming the port used is serial
void RecvData(void *ctx)
{
uint8_t data = 0;
auto port = *(serial::Serial**)hand_ctx;
while (port->available() != 0)
{
port->read(&data, 1);
HAND_OnData(hand_ctx, data);
}
}
Get Protocol Version HAND_GetProtocolVersion()
- Method Prototype:
uint8_t HAND_GetProtocolVersion(void *ctx, uint8_t hand_id, uint8_t *major, uint8_t *minor, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID majorDevice major version number minorDevice minor version number remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example
uint8_t major_ver, minor_ver;
uint8_t remote_err;
uint8_t used_id = 0x02;
test_err = HAND_GetProtocolVersion(hand_ctx, used_id, &major_ver, &minor_ver, &remote_err);
Get Firmware VersionGetFirmwareVersion()
- Method Prototype:
uint8_t HAND_GetFirmwareVersion(void *ctx, uint8_t hand_id, uint8_t *major, uint8_t *minor, uint16_t *revision, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID majorDevice major version number minorDevice minor version number revisionDevice revision version number remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example
uint8_t major_ver, minor_ver;
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t revision;
test_err = HAND_GetFirmwareVersion(hand_ctx, used_id, &major_ver, &minor_ver, &revision, &remote_err);
Get Hardware Version HAND_GetHardwareVersion()
- Method Prototype:
uint8_t HAND_GetHardwareVersion(void *ctx, uint8_t hand_id, uint8_t *hw_type, uint8_t *hw_ver, uint16_t *boot_version, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID hw_typeDevice hardware type hw_verDevice hardware version number boot_versionDevice bootloader version number remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example
uint8_t hw_type, hw_ver;
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t boot_version;
test_err = HAND_GetHardwareVersion(hand_ctx, used_id, &hw_type, &hw_ver, &boot_version, &remote_err);
Get Calibration Data HAND_GetCaliData()
- Method Prototype:
uint8_t HAND_GetCaliData(void *ctx, uint8_t hand_id, uint16_t *end_pos, uint16_t *start_pos, uint8_t *motor_cnt, uint16_t *thumb_root_pos, uint8_t *thumb_root_pos_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID end_posStorage of endpoint position array start_posStorage of startpoint position array motor_cntMotor count thumb_root_posGear position array for thumb base location(0, 1, 2) thumb_root_pos_cntNumber of gear positions at the thumb base location remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t end_pos[NUM_MOTORS];
uint16_t start_pos[NUM_MOTORS];
uint8_t motor_cnt = NUM_MOTORS;
uint16_t thumb_root_pos[3];
uint8_t thumb_root_pos_cnt = 3;
test_err = HAND_GetCaliData(hand_ctx, used_id, end_pos, start_pos, &motor_cnt, thumb_root_pos, &thumb_root_pos_cnt, &remote_err);
Get finger PID HAND_GetFingerPID()
- Method Prototype:
uint8_t HAND_GetFingerPID(void *ctx, uint8_t hand_id, uint8_t finger_id, float *p, float *i, float *d, float *g, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID finger_idfinger id pProportional coefficient iIntegral coefficient dDifferential coefficient gGain coefficient remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
float p, i, d, g;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerPID(hand_ctx, used_id, finger_index, &p, &i, &d, &g, &remote_err);
}
Get Finger Current Limit HAND_GetFingerCurrentLimit()
- Method Prototype:
uint8_t HAND_GetFingerCurrentLimit(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t *current_limit, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID finger_idFinger id current_limitCurrent limit remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t current_limit;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerCurrentLimit(hand_ctx, used_id, finger_index, ¤t_limit, &remote_err);
}
Get Finger Current HAND_GetFingerCurrent()
- Method Prototype:
uint8_t HAND_GetFingerCurrent(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t *current, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device ID finger_idFinger id currentFinger current remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t current;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerCurrent(hand_ctx, used_id, finger_index, ¤t, &remote_err);
}
Get Finger Force Target HAND_GetFingerForceTarget()
- Method Prototype:
uint8_t HAND_GetFingerForceTarget(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t *force_target, uint8_t *remote_err)
-
Purpose: Get the target force value setting for the specified finger, which is used for closed-loop control in force control mode (i.e., the device will automatically adjust motor output to maintain this target force)
-
Paramter Description:
Paramter Description ctxOHand context hand_idHand device ID finger_idFinger id force_targetFinger force target value remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t force_target;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerForceTarget(hand_ctx, used_id, finger_index, &force_target, &remote_err);
}
Get Finger Force Sensor Data HAND_GetFingerForce()
- Method Prototype:
uint8_t HAND_GetFingerForce(void *ctx, uint8_t hand_id, uint8_t finger_id, uint8_t *force_entry_cnt, uint8_t *force, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id force_entry_cntForce data entry count forceStorage variable address for force data, capable of storing multi-point force values, or normal force, tangential force and direction -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
#define MAX_FORCE_ENTRIES 12 * 5 /* Max force entries for one finger */
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t force[MAX_FORCE_ENTRIES] = { 0 };
uint8_t force_entry_count;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
force_entry_count = force_entries[finger_index];
delay(100);
test_err = HAND_GetFingerForce(hand_ctx, used_id, finger_index, &force_entry_count, force, &remote_err);
}
Get Finger Absolute Position Limit Values HAND_GetFingerPosLimit()
- Method Prototype:
uint8_t HAND_GetFingerPosLimit(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t *low_limit, uint16_t *high_limit, uint8_t *remote_err)
-
Purpose: Get the absolute position limit range for the specified finger, used to constrain the finger's movement range
-
Paramter Description:
Paramter Description ctxOHand context hand_idHand device id finger_idFinger id low_limitPosition lower limit value high_limitPosition upper limit value remote_errRemote error code -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t low_limit, high_limit;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerPosLimit(hand_ctx, used_id, finger_index, &low_limit, &high_limit, &remote_err);
}
Get Finger Absolute Position HAND_GetFingerPosAbs()
- Method Prototype:
uint8_t HAND_GetFingerPosAbs(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t *target_pos, uint16_t *current_pos, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id target_posTarget absolute position current_posCurrent absolute position remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t target_pos, current_pos;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerPosAbs(hand_ctx, used_id, finger_index, &target_pos, ¤t_pos, &remote_err);
}
Get Finger Logical Position HAND_GetFingerPos()
- Method Prototype:
uint8_t HAND_GetFingerPos(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t *target_pos, uint16_t *current_pos, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id target_posLogical target position current_posLogical current position remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t target_pos, current_pos;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerPos(hand_ctx, used_id, finger_index, &target_pos, ¤t_pos, &remote_err);
}
Get Finger Angle HAND_GetFingerAngle()
- Method Prototype:
uint8_t HAND_GetFingerAngle(void *ctx, uint8_t hand_id, uint8_t finger_id, int16_t *target_angle, int16_t *current_angle, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id target_angleTarget angle value, unit: actual angle * 100 current_angleCurrent angle value, unit: actual angle * 100 remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
int16_t target_angle, current_angle;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
delay(100);
test_err = HAND_GetFingerAngle(hand_ctx, used_id, finger_index, &target_angle, ¤t_angle, &remote_err);
}
Get Thumb Base Gear Position HAND_GetThumbRootPos()
- Method Prototype:
uint8_t HAND_GetThumbRootPos(void *ctx, uint8_t hand_id, uint16_t *raw_encoder, uint8_t *pos, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id raw_encoderFinger base raw encoder value, range: 0~65535 posThumb base mapped position, range: 0~2 three gear positions remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t raw_encoder;
uint8_t pos;
test_err = HAND_GetThumbRootPos(hand_ctx, used_id, &raw_encoder, &pos, &remote_err);
Get All Finger Absolute Positions HAND_GetFingerPosAbsAll()
- Method Prototype:
uint8_t HAND_GetFingerPosAbsAll(void *ctx, uint8_t hand_id, uint16_t *target_pos, uint16_t *current_pos, uint8_t *motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id target_posArray of target absolute positions for all fingers/td> current_posArray of current absolute positions for all fingers motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t motor_cnt = NUM_MOTORS;
uint16_t raw_target_pos[NUM_MOTORS], raw_current_pos[NUM_MOTORS];
test_err = HAND_GetFingerPosAbsAll(hand_ctx, used_id, raw_target_pos, raw_current_pos, &motor_cnt, &remote_err);
获取所有手指逻辑位置HAND_GetFingerPosAll()
- Method Prototype:
uint8_t HAND_GetFingerPosAll(void *ctx, uint8_t hand_id, uint16_t *target_pos, uint16_t *current_pos, uint8_t *motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id target_posArray of target logical positions for all fingers/td> current_posArray of current logical positions for all fingers motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t raw_target_pos[NUM_MOTORS], raw_current_pos[NUM_MOTORS];
uint8_t motor_cnt = NUM_MOTORS;
test_err = HAND_GetFingerPosAll(hand_ctx, used_id, raw_target_pos, raw_current_pos, &motor_cnt, &remote_err);
Get All Finger Angles HAND_GetFingerAngleAll()
- Method Prototype:
uint8_t HAND_GetFingerAngleAll(void *ctx, uint8_t hand_id, int16_t *target_angle, int16_t *current_angle, uint8_t *motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id target_angleArray of target angle values for all fingers, unit: actual angle * 100/td> current_angleArray of current angle values for all fingers, unit: actual angle * 100 motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t motor_cnt = NUM_MOTORS;
int16_t raw_target_angle[NUM_MOTORS], raw_current_angle[NUM_MOTORS];
test_err = HAND_GetFingerAngleAll(hand_ctx, used_id, raw_target_angle, raw_current_angle, &motor_cnt, &remote_err);
Get Self-test Level HAND_GetSelfTestLevel()
- Method Prototype:
uint8_t HAND_GetSelfTestLevel(void *ctx, uint8_t hand_id, uint8_t *self_test_level, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id self_test_levelSelf-test level: 0.No automatic self-test, 1.Automatic partial self-test, 2.Automatic comprehensive self-test remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t self_test_level;
test_err = HAND_GetSelfTestLevel(hand_ctx, used_id, &self_test_level, &remote_err);
Get Beep Switch Status HAND_GetBeepSwitch()
- Method Prototype:
uint8_t HAND_GetBeepSwitch(void *ctx, uint8_t hand_id, uint8_t *beep_switch, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id beep_switchBeep switch status: 0.Off, 1.On remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t beep_switch;
uint8_t remote_err;
uint8_t used_id = 0x02;
test_err = HAND_GetBeepSwitch(hand_ctx, used_id, &beep_switch, &remote_err);
Get UID HAND_GetUID()
- Method Prototype:
uint8_t HAND_GetUID(void *ctx, uint8_t hand_id, uint32_t *uid_w0, uint32_t *uid_w1, uint32_t *uid_w2, uint8_t *remote_err)
-
Purpose: Get the 96-bit unique identifier (UID) of the Hand device, used for device identification, uniqueness verification and other scenarios
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id uid_w0Device UID Word 0 uid_w1Device UID Word 1 uid_w0Device UID Word 2 remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint32_t uid_w0, uid_w1, uid_w2;
test_err = HAND_GetUID(hand_ctx, used_id, &uid_w0, &uid_w1, &uid_w2, &test_remote_err);
Get Manufacture DataHAND_GetManufactureData()
- Method Prototype:
uint8_t HAND_GetManufactureData(void *ctx, uint8_t hand_id, uint8_t *data, uint8_t *data_size, uint8_t *remote_err)
-
Purpose: Get the manufacturer data of the Hand device, typically containing production-related information (such as production batch, verification information, etc.)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id dataManufacturer Data data_sizeActual length of manufacturer data remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t data_size = 26;
uint8_t* data = (uint8_t*)malloc(data_size * sizeof(uint8_t));
test_err = HAND_GetManufactureData(hand_ctx, used_id, data, &data_size, &test_remote_err);
GetVendor IDHAND_GetVendorID()
- Method Prototype:
uint8_t HAND_GetVendorID(void *ctx, uint8_t hand_id, uint16_t *vendor_id, uint8_t *remote_err)
-
Purpose: Get the Vendor ID of the Hand device, used to identify the device manufacturer, typically a unique identifier exclusive to the manufacturer
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id vendor_id厂商ID remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint16_t vendor_id;
test_err = HAND_GetVendorID(hand_ctx, used_id, &vendor_id, &test_remote_err);
Get Finger Force PID ParameterHAND_GetForcePID()
- Method Prototype:
uint8_t HAND_GetForcePID(void *ctx, uint8_t hand_id, uint8_t finger_id, float *p, float *i, float *d, float *g, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id pProportional coefficient iIntegral coefficient dDerivative coefficient gGain coefficient -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_FINGERS 5
uint8_t remote_err;
uint8_t used_id = 0x02;
float p, i, d, g;
for (int fingerIndex = 0; fingerIndex < NUM_FINGERS; fingerIndex++) {
delay(100);
test_err = HAND_GetForcePID(hand_ctx, used_id, fingerIndex, &p, &i, &d, &g, &remote_err);
}
Reset device HAND_Reset()
- Method Prototype:
uint8_t HAND_Reset(void *ctx, uint8_t hand_id, uint8_t mode, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id modeReset mode (0: Boot to user code; 1: Boot to DFU mode) remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t mode = 0;
test_err = HAND_Reset(hand_ctx, used_id, 0, &remote_err);
Set id HAND_SetID()
- Method Prototype:
uint8_t HAND_SetID(void *ctx, uint8_t hand_id, uint8_t new_id, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id new_idNew device ID remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t new_id = 0x03;
test_err = HAND_SetID(hand_ctx, used_id, new_id, &remote_err);
Enter calibration mode HAND_Calibrate()
- Method Prototype:
uint8_t HAND_Calibrate(void *ctx, uint8_t hand_id, uint16_t key, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id keyCalibration Key remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This feature is currently not publicly available. Please contact technical support if you need to use this function.
Get Battery VoltageHAND_GetBatteryVoltage()
- Method Prototype:
uint8_t HAND_GetBatteryVoltage(void *ctx, uint8_t hand_id, uint16_t *voltage, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id voltageBattery voltage remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This function is only available for bionic hands, not supported for dexterous hands.
Get usage status HAND_GetUsageStat()
- Method Prototype:
uint8_t HAND_GetUsageStat(void *ctx, uint8_t hand_id, uint32_t *total_use_time, uint32_t *total_open_times, uint8_t motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id total_use_timeTotal usage time of the device total_open_timesTotal open count of each motor motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This function is only available for bionic hands, not supported for dexterous hands.
Power off HAND_PowerOff()
- Method Prototype:
uint8_t HAND_PowerOff(void *ctx, uint8_t hand_id, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This function is only available for bionic hands, not supported for dexterous hands.
Set Calibration Data HAND_SetCaliData()
- Method Prototype:
uint8_t HAND_SetCaliData(void *ctx, uint8_t hand_id, uint16_t *end_pos, uint16_t *start_pos, uint8_t motor_cnt, uint16_t *thumb_root_pos, uint8_t thumb_root_pos_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id end_posEndpoint position calibration data for each motor start_posStart point position calibration data for each motor motor_cntMotor count thumb_root_posPreset position calibration data for the thumb base thumb_root_pos_cntNumber of preset positions for the thumb base remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This feature is currently not publicly available. Please contact technical support if you need to use this function.
Set finger PID Parameter HAND_SetFingerPID()
- Method Prototype:
uint8_t HAND_SetFingerPID(void *ctx, uint8_t hand_id, uint8_t finger_id, float p, float i, float d, float g, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id pProportional coefficient iIntegral coefficient dDerivative coefficient gGain coefficient remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
static const float _pidGains[][4] = {
{250.00, 2.00, 250.00, 1.00},
{250.00, 2.00, 250.00, 1.00},
{250.00, 2.00, 250.00, 1.00},
{250.00, 2.00, 250.00, 1.00},
{250.00, 2.00, 250.00, 1.00},
{250.00, 2.00, 250.00, 1.00}
};
for (int i = 0; i < NUM_MOTORS; i++){
err = HAND_SetFingerPID(hand_ctx, used_id, i, _pidGains[i][0], _pidGains[i][1], _pidGains[i][2], _pidGains[i][3], &remote_err);
}
Set Finger Current Limit Value HAND_SetFingerCurrentLimit()
- Method Prototype:
uint8_t HAND_SetFingerCurrentLimit(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t current_limit, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id current_limitCurrent limit value remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t current_limit_set = 200;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
test_err = HAND_SetFingerCurrentLimit(hand_ctx, used_id, finger_index, current_limit_set, &remote_err);
}
Set Finger Force Feedback Target Value HAND_SetFingerForceTarget()
- Method Prototype:
uint8_t HAND_SetFingerForceTarget(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t force_target, uint8_t *remote_err)
-
Purpose: Set the target force value for the specified finger, which is used for closed-loop control in force control mode (i.e., the device will automatically adjust motor output to maintain this target force)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id force_targetTarget force value, unit: mN remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t force_target_set = 200;
for (int finger_index = 0; finger_index < NUM_FINGERS; finger_index++) {
test_err = HAND_SetFingerForceTarget(hand_ctx, used_id, finger_index, force_target_set, &remote_err);
}
Set Finger Absolute position Limit Value HAND_SetFingerPosLimit()
- Method Prototype:
uint8_t HAND_SetFingerPosLimit(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t low_limit, uint16_t high_limit, uint8_t *remote_err)
-
Purpose: Set the absolute position limit range for the specified finger, used to constrain the finger's movement range
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id low_limitAbsolute position lower limit value high_limitAbsolute position upper limit value remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t low_limit_set = 3800, high_limit_set = 16000;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
test_err = HAND_SetFingerPosLimit(hand_ctx, used_id, finger_index, low_limit_set, high_limit_set, &remote_err);
}
Activate finger (when stuck) HAND_FingerStart()
- Method Prototype:
uint8_t HAND_FingerStart(void *ctx, uint8_t hand_id, uint8_t finger_id_bits, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_id_bitsFinger corresponding bitmask remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
const uint8_t finger_ids[NUM_MOTORS] = { 1, 2, 4, 6, 8, 10 };
for (int i = 0; i < NUM_MOTORS; i++) {
test_err = HAND_FingerStart(hand_ctx, used_id, finger_index, &remote_err);
}
Stop finger HAND_FingerStop()
- Method Prototype:
uint8_t HAND_FingerStop(void *ctx, uint8_t hand_id, uint8_t finger_id_bits, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_id_bitsFinger corresponding bitmask remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
const uint8_t finger_ids[NUM_MOTORS] = { 1, 2, 4, 6, 8, 10 };
for (int i = 0; i < NUM_MOTORS; i++) {
test_err = HAND_FingerStop(hand_ctx, used_id, finger_index, &remote_err);
}
Set Finger Absolute Position HAND_SetFingerPosAbs()
- Method Prototype:
uint8_t HAND_SetFingerPosAbs(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t raw_pos, uint8_t speed, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id raw_posFinger absolute position speedFinger movement speed remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t speed = 255;
uint16_t abs_pos_set = 16000;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
test_err = HAND_SetFingerPosAbs(hand_ctx, used_id, finger_index, abs_pos_set, speed, &remote_err);
}
Set Finger Logical Position HAND_SetFingerPos()
- Method Prototype:
uint8_t HAND_SetFingerPos(void *ctx, uint8_t hand_id, uint8_t finger_id, uint16_t pos, uint8_t speed, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id pos目标逻辑位置 speedFinger movement speed remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t speed = 255;
uint16_t pos_set = 58000;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
test_err = HAND_SetFingerPos(hand_ctx, used_id, finger_index, pos_set, speed, &remote_err);
}
Set Finger Angle HAND_SetFingerAngle()
- Method Prototype:
uint8_t HAND_SetFingerAngle(void *ctx, uint8_t hand_id, uint8_t finger_id, int16_t angle, uint8_t speed, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id angleTarget angle value, value is actual angle * 100 speedFinger movement speed remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t speed = 255;
uint16_t four_finger_angle_set = 12000;
uint16_t thumb_angle_set = 1500;
uint16_t thumb_root_angle_set = 6000;
for (int finger_index = 0; finger_index < NUM_MOTORS; finger_index++) {
if (finger_index >= 1 && finger_index <= 4) {
test_err = HAND_SetFingerAngle(hand_ctx, used_id, finger_index, four_finger_angle_set, speed, &remote_err);
}
else if (finger_index == 0) {
test_err = HAND_SetFingerAngle(hand_ctx, used_id, finger_index, thumb_angle_set, speed, &remote_err);
}
else {
test_err = HAND_SetFingerAngle(hand_ctx, used_id, finger_index, thumb_root_angle_set, speed, &remote_err);
}
}
Set Thumb Base Position HAND_SetThumbRootPos()
- Method Prototype:
uint8_t HAND_SetThumbRootPos(void *ctx, uint8_t hand_id, uint8_t pos, uint8_t speed, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id posTarget position of thumb base, can only be 0, 1, or 2 speedFinger movement speed remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t speed = 255;
uint8_t pos_set = 1
test_err = HAND_SetThumbRootPos(hand_ctx, used_id, pos_set, speed, &remote_err);
Set All Finger Absolute Positions HAND_SetFingerPosAbsAll()
- Method Prototype:
uint8_t HAND_SetFingerPosAbsAll(void *ctx, uint8_t hand_id, uint16_t *raw_pos, uint8_t *speed, uint8_t motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id raw_posAll finger absolute position array speedAll Finger movement speed array motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t raw_speed[NUM_MOTORS] = { 100,100,100,100,100,100 };
uint16_t raw_pos_abs[NUM_MOTORS] = { 13000, 13000, 13000, 13000, 13000, 5000 };
uint8_t motor_cnt = NUM_MOTORS;
test_err = HAND_SetFingerPosAbsAll(hand_ctx, used_id, raw_pos_abs, raw_speed, NUM_MOTORS, &remote_err);
Set All Finger Logical Positions HAND_SetFingerPosAll()
- Method Prototype:
uint8_t HAND_SetFingerPosAll(void *ctx, uint8_t hand_id, uint16_t *pos, uint8_t *speed, uint8_t motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id posArray of target logical positions for all fingers speedAll Finger movement speed array motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t motor_cnt = NUM_MOTORS;
uint16_t raw_pos[NUM_MOTORS] = { 18000, 33000, 33000, 33000, 33000, 38000 };
test_err = HAND_SetFingerPosAll(hand_ctx, used_id, raw_pos, raw_speed, NUM_MOTORS, &remote_err);
Set All Finger Angles HAND_SetFingerAngleAll()
- Method Prototype:
uint8_t HAND_SetFingerAngleAll(void *ctx, uint8_t hand_id, int16_t *angle, uint8_t *speed, uint8_t motor_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id angleArray of target angles for all fingers speedAll Finger movement speed array motor_cntMotor count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_MOTORS 6
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t motor_cnt = NUM_MOTORS;
int16_t raw_angle[NUM_MOTORS] = { 2000,12000,12000,12000,12000,5000 };
test_err = HAND_SetFingerAngleAll(hand_ctx, used_id, raw_angle, raw_speed, NUM_MOTORS, &remote_err);
Custom Command, High-speed Read/Write HAND_SetCustom()
- Method Prototype:
uint8_t HAND_SetCustom(void *ctx, uint8_t hand_id, uint8_t* data, uint8_t send_data_size, uint8_t *recv_data_size, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id dataSpecific content data of custom command send_data_sizeLength of data to be sent recv_data_sizeLength of data to be received remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
For details, please refer to the example project in this SDK custom_cmd_test
Set Self-test Level HAND_SetSelfTestLevel()
- Method Prototype:
uint8_t HAND_SetSelfTestLevel(void *ctx, uint8_t hand_id, uint8_t self_test_level, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id self_test_levelSelf-test level, 0: No automatic self-test, 1: Partial self-test, 2: Full self-test remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t self_test_level_set = 2;
test_err = HAND_SetSelfTestLevel(hand_ctx, used_id, self_test_level_set, &remote_err);
Set Beep Switch HAND_SetBeepSwitch()
- Method Prototype:
uint8_t HAND_SetBeepSwitch(void *ctx, uint8_t hand_id, uint8_t beep_on, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id beep_onBeep switch status, 0: Off, 1: On remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint8_t beep_on = 1;
test_err = HAND_SetBeepSwitch(hand_ctx, used_id, beep_on, &remote_err);
Beep HAND_Beep()
- Method Prototype:
uint8_t HAND_Beep(void *ctx, uint8_t hand_id, uint16_t duration, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id durationDuration, unit: ms remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
uint16_t duration = 200;
test_err = HAND_Beep(hand_ctx, used_id, duration, &remote_err);
Set Button Press Count HAND_SetButtonPressedCnt()
- Method Prototype:
uint8_t HAND_SetButtonPressedCnt(void *ctx, uint8_t hand_id, uint8_t pressed_cnt, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id pressed_cntButton press count remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This function is only available for bionic hands, not supported for dexterous hands.
Trigger initialization (condition: self-test mode is 0) HAND_StartInit()
- Method Prototype:
uint8_t HAND_StartInit(void *ctx, uint8_t hand_id, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
HAND_SetSelfTestLevel(hand_ctx, used_id, 0, &remote_err);
test_err = HAND_StartInit(hand_ctx, used_id, &remote_err);
Set Manufacture Data HAND_SetManufactureData()
- Method Prototype:
uint8_t HAND_SetManufactureData(void *ctx, uint8_t hand_id, uint8_t *data, uint8_t data_size, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id dataManufacture Data data_sizeManufacturer data size remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Note: This feature is currently not publicly available. Please contact technical support if you need to use this function.
设置手指力控PIDParameterHAND_SetFingerForcePID()
- Method Prototype:
uint8_t HAND_SetFingerForcePID(void *ctx, uint8_t hand_id, uint8_t finger_id, float p, float i, float d, float g, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id finger_idFinger id pProportional coefficient iIntegral coefficient dDerivative coefficient gGain coefficient remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
#define NUM_FINGERS 5
uint8_t remote_err;
uint8_t used_id = 0x02;
float force_pid[][4] = {
{200.00, 2.00, 98.00, 0.07},
{200.00, 2.00, 98.00, 0.07},
{200.00, 2.00, 98.00, 0.07},
{200.00, 2.00, 98.00, 0.07},
{200.00, 2.00, 98.00, 0.07},
};
for (int finger_index = 0; finger_index < NUM_FINGERS; finger_index++){
test_err = HAND_SetFingerForcePID(hand_ctx, used_id, finger_index, force_pid[finger_index][0], force_pid[finger_index][1],force_pid[finger_index][2], force_pid[finger_index][3], &remote_err);
}
Reset Force Sensor Data HAND_ResetForce()
- Method Prototype:
uint8_t HAND_ResetForce(void *ctx, uint8_t hand_id, uint8_t *remote_err)
-
Parameter Description:
Parameter Description ctxOHand context hand_idHand device id remote_errRemote error cod -
Return Value:
Success: Returns context pointer
Failure: Returns NULL -
Usage Example:
uint8_t remote_err;
uint8_t used_id = 0x02;
test_err = HAND_ResetForce(hand_ctx, used_id, &remote_err);