Skip to main content

Overview

Enable the hand, send joint 0 a fixed cosine position sequence, then disable and disconnect. The whole run takes 2 seconds. This is the smaller of the two motion examples, meant to verify the command path works rather than to watch fingers move. The cosine amplitude on joint 0 is only 0.02 rad, about 1.15 degrees, and static friction leaves it with almost no visible displacement. How much actually moves, though, depends on the hand’s starting posture. Each frame carries a complete 20-element command where all 19 joints other than joint 0 target position 0. If the hand starts curled, the very first frame pulls those 19 joints toward zero, and without any interpolation. In one run, nid 19 went from 0.6498 rad to 0.0143 rad, about 36 degrees of real motion, far beyond joint 0’s 1.15 degrees. Matching examples: examples/python/wuji_hand_2/7.mit_sweep.py and examples/c/wuji_hand_2/7_mit_sweep.c. For MIT control mode and parameter safety bounds, see Control Guide, and for the torque and MIT parameter APIs, see Effort and MIT Parameters. This page covers only how to run it and what the measurements show.
This example enables the motors. Clear people, cables, and desk objects from around the hand before starting, keep someone watching throughout, and stay ready to cut power.When the hand doesn’t start at zero, the first frame pulls all 20 joints toward zero with no interpolation. For a gentle return to zero, run the smooth homing routine in Publishing Control Commands first.

Prerequisites

Hardware

Software

This example takes no command-line arguments.

Before You Start

Confirm the device’s MIT parameters and effort limit sit at factory values:
Lowering kp erases what little displacement there is, and raising it goes beyond this example’s safety envelope.

Data Flow

The sequence is generated locally in full, then sent frame by frame with no interpolation and no replanning. Each JointCommand is a position, velocity, and torque triple, and this example fills only position, leaving velocity and torque at 0. Note that every frame is a complete 20-element command. The 19 positions other than joint 0 are hard-coded to 0, which continuously commands them home, and that motion isn’t bounded by the 0.02 rad amplitude.

Runtime Handling

Whichever path it takes, cleanup disables the motors, closes the publisher, and disconnects. Neither errors nor interrupts add any recovery motion, so the hand never returns to its starting posture on its own.

Integration Steps

The order matters. Gate before enabling, and disable before closing the publisher.

Running It

A normal run prints nothing to standard output and exits 0. Only errors go to standard error. Two quiet seconds mean success.

Measurements

On a right-hand Wuji Hand 2 with all 20 joints online, subscribing to joint_states alongside to record joint 0’s response: Joint 0 barely moves, and that’s expected. Torque tracks the command’s rise and fall precisely, showing the command went out and the motor responded under MIT impedance. A 0.02 rad target error at kp=3 produces only about 0.06 of torque, which doesn’t overcome the joint’s static friction, leaving an actual displacement of 0.0004 rad, roughly 0.023 degrees and invisible to the eye. The table above comes from a hand already near zero. From a contrasting run: starting with the hand curled, the same example pulled the other 19 joints toward zero with the displacements below. nid 19 moved 0.6355 rad, about 36 degrees. So “smallest amplitude” holds only when the hand already sits at zero. Success here means the process exits quietly with code 0, plus a torque response visible on a joint_states subscription, not fingers you can see move. To watch real motion, see Replaying a Thumb Opposition.

Adapting It

Name an SN on a Shared Network

auto_connect() means “connect to the one device found on the bus.” With more than one present it refuses and lists every serial number rather than guessing:
That design avoids disturbing someone else’s device, at the cost of the example not running as-is on a shared network. Replace step 1:

To Actually See a Joint Move

This example isn’t built for observing motion. For visible range, use the complete motion sequence in Replaying a Thumb Opposition. Raising this example’s amplitude yourself exceeds its safety envelope and isn’t advised.

How to Read Joint State

joint_states is a subscription resource and has no get() method. To read actual positions while commanding, call subscribe_with_callback() to receive continuously and take values from the latest frame. Calling hand.joint_states().get() directly raises AttributeError.

Changing the Command Rate

The interval is hard-coded at 20 ms. A shorter interval raises the command rate, but the fixed 101-frame sequence simply finishes sooner without changing the trajectory’s shape.