Skip to main content

Overview

Switch Wuji Hand 2 to Position control mode, adjust per-joint output limits and position-command filtering, then transition from the current posture into a whole-hand open/close sequence. Use this practice to check the position-control command path or connect an application-generated trajectory. The matching Python example is 8.position_mode.py. For API definitions, see Position Control Interface Reference. For mode selection, see Position Control Mode.
This example enables all 20 joints and sends the same open/close angle to every joint. Mount the device securely, clear people, cables, and obstacles from its surroundings, keep someone watching throughout, and stay ready to cut power.

Prerequisites

Hardware

Software

Before You Start

Confirm the target serial number. If several Wuji Hand 2 devices are found, the example lists their serial numbers and prompts for a selection. Pressing Enter, or running without standard input, selects the first hand in the list.

Data Flow

Integration Steps

The snippets below come from the example. See the complete source for helper definitions.

1. Connect and Check the Joints

connect_hand() scans for devices and connects the selected Wuji Hand 2. If fewer than 20 joints are online, the example reports an error and exits without starting motion.

2. Switch Modes and Read the Original Parameters

Disable the hand before switching to Position control mode. Read limits only after the switch succeeds, so the saved, adjusted, and restored values all belong to this mode, in N·m.
The read limits are the values in effect, not necessarily the defaults. read_effort_limits() requires 20 valid values. A failed check stops configuration and enabling.

3. Adjust Per-Joint Limits and Set the Cutoff

Multiply each joint’s own read limit by EFFORT_LIMIT_SCALE instead of applying one fixed torque value to every joint.
write_effort_limits() reads all joints after writing. A mismatch raises an error that lists the affected joints. The example registers each restoration before the corresponding write, so it attempts to restore saved parameters even after a write error. For API rules, see Output Limits.

4. Enable and Transition from the Current Posture

After enable(), wait_enabled() waits until the newest diagnostics frame reports all 20 joints as Enabled. The example then reads a complete posture, arranges it by joint index, and uses a 1-second cosine transition to the sequence start.
An enable timeout or incomplete starting posture enters cleanup without sending the open/close sequence.

5. Send the Open/Close Sequence

Every joint follows a cosine target from 0 to 0.35 rad, with two cycles of 4 seconds each. send_sweep() sends 20 JointCommand entries per frame, with velocity and effort both set to 0.
The target command interval is 1 / 120 seconds. Host scheduling affects the actual rate.

6. Stop and Restore Parameters

Normal completion, errors, and Ctrl+C enter cleanup: attempt to disable, close the publisher, restore the original cutoff and limits, and disconnect. A cleanup failure doesn’t prevent later cleanup actions. Limit restoration also reads back every joint. The hand stays in Position control mode after exit. For details on saving and restoring limits, see Save and Restore Limits.

Running and Output

Run the Example

From the wuji-sdk repository root, run:

Check the Output and Result

The terminal shows the selected device, control mode, original limits, scale, written values read back from the hand, and cutoff frequency. Limits are grouped by four joints per finger, in thumb, index, middle, ring, and pinky order. Check completion as follows:
  • Normal completion returns exit code 0. Runtime or cleanup failures return 1. Ctrl+C returns 130
  • The hand is disabled after the sequence, with no cleanup error output. If restoration fails, check device state and parameters before continuing
  • To assess tracking, record joint_states separately and compare target and feedback positions. Printed parameter values aren’t a motion-completion check

Notes

Extensions

Use Another Position Trajectory

Replace the 20-joint position sequence from generate_sweep(). Keep parameter snapshots, readback checks, enable waiting, the starting transition, and cleanup. Sending the same angle to all joints is specific to this example, not a general grasping posture.