Overview
Configure MIT_V2 impedance parameters and publish control commands to WUJI Hand 2. The Python example moves the hand smoothly from its measured posture to zero and holds there. The C example uses the same smooth homing and hold sequence. The samepublisher.send() path can carry teleoperation commands and trajectories from a higher-level controller.
The matching examples are Python 2_publish.py and C 2_publish.c. For command fields, see JointCommand. For control parameters, see MitParam.
This example enables the motors and drives all 20 joints. Clear people, cables, and desk objects from around the hand before starting, keep someone watching throughout, and stay ready to cut power.
Interpolation
MIT impedance control combines position error, velocity error, and feedforward torque. Sending a zero-position target from a nonzero posture can create a large initial position error and an abrupt motion. The Python example first reads the measured posture, then interpolates the target to zero frame by frame to reduce each target-position step. Smooth homing comes from the target trajectory rather than reducingkp or kd.
Prerequisites
Hardware
When multiple devices share the network, use
--sn <SN> to select the target device.
Software
Control Parameters
The examples use physical gainskp = 1.0 N·m/rad and kd = 0.02 N·m·s/rad, and explicit per-joint effort limits (N·m). These are example settings, not factory defaults or universal maximums. See MIT_V2 parameter configuration.
Data Flow
Integration Steps
1. Connect and Configure Control Parameters
Disable, selectControlMode.MitV2 in Python or WUJI_CONTROL_MODE_MIT_V2 in C, then configure per-joint effort limits (N·m) and physical gains. The example checks parameter readback and exits before enabling if a value is missing or mismatched. Use the configuration excerpt when adapting your program.
2. Enable and Wait for Motor Readiness
Before sending motion commands, read the latest joint diagnostics frame and confirm that it contains all 20 joints in theEnabled state. Wait up to five seconds, then stop if it times out. Close the diagnostics subscription on exit. The complete example handles disabling and connection cleanup after a failure.
- Python
- C
3. Create a Publisher and Send a Trajectory
Python example and C example demonstrate the same motion sequence. Both move smoothly from the measured posture to zero over 1.5 seconds, then hold zero for five seconds. Both send 20-joint command frames at 200 Hz.- Python
- C
read_positions() and publish_home() are helpers in the Python example. They read a complete posture and publish an interpolated trajectory. The C example follows the same sequence. Both stop and clean up on read timeouts, send failures, or stop requests.
4. Stop Sending and Release Resources
After sending stops, close the publisher, disable the hand, and disconnect. The example attempts the remaining cleanup steps even if one fails and reports each error. Cleanup failures return exit code1. See the Python example and C example for complete cleanup handling.
The torque limits set by the example remain after exit and also affect subsequent Position control mode. See Save and Restore Limits for restoration steps.
Running It
- Python
- C
Notes
The example checks that every command frame contains all 20 joints and cleans up resources after an error. For parameter readback and motion requirements, see the migration procedure. For completion, interruption, and cleanup exit codes, see Stop Motion and Clean Up.Adapting It
Tune How Gentle Homing Is
ChangeHOME_SECONDS. A longer duration makes each frame’s position step smaller and the motion gentler. Don’t chase gentleness by lowering kp, which sacrifices tracking accuracy overall.
Feed Your Own Trajectory
Replace the interpolation in step 5 with your own trajectory source, leaving thepublisher.send() call unchanged. Each send() carries a complete 20-element frame, which the SDK serializes and transmits without waiting for a response, so it sustains a high-rate loop.
Choosing a Publish Rate
The example uses 200 Hz. Higher rates make trajectories smoother, provided generating one frame stays reliably faster than the period. Check the timing under your application load.Controlling Only Some Joints
Every frame still carries the full 20-element array. For joints you don’t want to move, fill in their current measured positions rather than 0. Filling 0 commands them home, which is the trap the MIT joint sweep ran into.Related
- Running an MIT Joint Sweep: the minimal command-path check, and a warning that it pulls other joints toward zero
- Replaying a Thumb Opposition: high-rate playback of a complete recorded trajectory
- Subscribing With Callbacks: how to read joint state
- Common Data Types:
JointCommandand diagnostic structures