Skip to main content
Compatibility This interface applies to Kinatric D2 and D2W on RK3576. See the Kinatric deployment repository for published source and deployment instructions. Use SDK versions compatible with the installed gateway, which reports RPC API version 1.0.0.1. The Kinatric C++ SDK provides D2 and D2W examples.

Introduction

The Kinatric D2 motion service provides two high-level interfaces over DDS.
  • High-level control sends posture and velocity requests with SportClient. MotionSwitcherClient handles the controller handover, and RobotStateClient reports service availability.
  • High-level status uses rt/sportmodestate for motion phase and available IMU data. Kinatric D2 also provides topics for control state, actuator feedback, and measurement validity.

High-Level Control Interface

Calling the High-Level Control Interface

Use the same external DDS domain on the board and client. The external default is 0. The board uses a separate internal domain, 71 by default. The external and internal domain IDs must differ. Set the board interface with KINATRIC_DDS_INTERFACE and the external domain with KINATRIC_DDS_DOMAIN. For unicast discovery, set KINATRIC_DDS_PEER on the board to the client IP and pass the board IP as --peer to the Python probe. Multicast discovery can omit the peer on a compatible network. Initialize ChannelFactory before creating an SDK client. The C++ example queries the gateway version and assumes DDS discovery is configured for the selected interface. For an explicit discovery peer in C++, configure it in Cyclone DDS.
The Python examples require the interface-test helper scripts supplied with the matching gateway deployment. Check that those scripts and their dependencies are available before running them; they are not included in the current published deployment source. Set D2_DOMAIN to the external domain, PC_IFACE to the client interface name or IPv4 address, and D2_IP to the board IPv4 address. The read-only probe reports the API version, service list, CheckMode result, control state, and available feedback. In standby, version and service queries can succeed while live joint feedback is unavailable and CheckMode reports 4202.
Before sending motion commands, start a local session with an Xbox Select press and release or a LiteRadio 4 SA off-to-on transition. Wait for the board to complete its startup checks and report Passive in the active session.

High-Level Motion Control Functions

SportClient

Requests use rt/api/sport/request and replies use rt/api/sport/response. A locomotion-enabled session accepts fresh Move targets from Stand, a ready StandFallback, or an active locomotion phase, subject to its policy and transition checks. A stand-only session returns 3203.

MotionSwitcherClient

Requests use rt/api/motion_switcher/request and replies use rt/api/motion_switcher/response.

RobotStateClient and Version Query

The robot state service uses rt/api/robot_state/request and rt/api/robot_state/response.

Error Codes

For a synchronous motion RPC, 0 means that the board accepted the request. Observe control_state.state to confirm motion completion. The pinned Python SportClient.Move() uses noreply, so its 0 means the client sent the request. Use rt/kinatric/operation_state to see the board’s acceptance or rejection. The gateway honors noreply for all supported calls. Direct RPC clients use the pinned SDK’s Request_ and Response_ types. For methods without arguments, leave the parameter string empty or send {}. Send {"name":"normal"} for mode selection. Leave the lease ID at 0 and the binary payload empty. Within its retry cache, the gateway reuses an identical request’s result for the same service, DDS writer, API ID, nonzero request ID, and ownership epoch.

Example

These commands move Kinatric D2. Start a local session with locomotion enabled. Set VX, VY, and VYAW to targets approved for the test setup, and MOVE_SECONDS to a positive duration. Run the example in Bash from the same deployment checkout as the status probe.
The example uses one DDS participant for all three actions, waits for Stand and Passive, and checks the Move results in operation_state. The timed move refreshes the target about every 50 ms and calls StopMove() on exit. The helper’s move subcommand sends a single target if --seconds is omitted. End the local session using the corresponding Select or SA exit gesture when finished.

Control Ownership and Timeouts

The first eligible SDK DDS participant can acquire control automatically. The gateway releases the high-level DDS holder after 1 s of no new admitted activity by default, or when it detects that the client has left. Commands accepted by the motion backend renew effective control authority. If the robot is already in Stand, it holds that posture when SDK ownership expires. Use control_state.authorization to inspect the SDK holder, the ownership epoch, and the bound low-level writer. Use control_state.hardware to inspect the HAL result during a fault or session exit.

High-Level Status Interface

Subscribing to High-Level Status

Subscribe to rt/sportmodestate on the external DDS domain to read the Kinatric D2 motion mode, phase progress, and available IMU data. The example reads one sample from an active session. Run it in Bash from the same deployment checkout as the status probe, with the same network variables.

High-Level Status Types

The C++ SportModeState_ accessors below expose the fields published by the Kinatric D2 runtime. progress depends on the current phase.
When the IMU is valid, the orientation is in w, x, y, z order, angular velocity is in rad/s, and roll, pitch, and yaw are in rad. state_validity.tick identifies a LowState_ sample. To read linear acceleration in m/s² with per-sample validation, match the LowState_ tick and check state_validity.acceleration as described below.
The motion state machine uses SportModeState_.mode as shown below. The locomotion runtime pauses this stream once ReleaseMode() has taken effect. The JSON field control_state.mode maps Stand to 0, RL to 3, Passive to 7, and other FSM states to -1. Use control_state.state for the exact FSM state. In control_state.controller, internal means the onboard controller, waiting means high-level control is released and no low-level writer has been selected by the HAL, and external means a low-level writer is selected.

Additional Status Topics

The gateway publishes its JSON status messages as std_msgs::msg::dds_::String_ on the external DDS domain. For each LowState_ sample, check the SDK CRC, match LowState_.tick to state_validity.tick, and require joints=true before consuming actuator measurements. Check imu, acceleration, and temperature before using those fields. The validity worker targets a 20 ms loop. LowState_ itself is forwarded from the HAL as it arrives and has its own cadence. Foot forces, body position, and measured body velocity are unavailable in this interface. Other unpopulated SDK fields carry their IDL defaults. The Nano ROS 2 bridge converts /cmd_vel to Move, publishes matched joint and IMU feedback to /joint_states and /imu/data, and uses base_link for IMU messages.

Joint Feedback Example

This read-only example prints one validity report and its matching 12-leg-axis feedback sample when available. Run it in Bash from the same deployment checkout as the status probe, with the same network variables. The feedback_report helper checks the tick and CRC before returning joint data.

Low-Level Control Interface

Publish LowCmd_ on rt/lowcmd. Both LowCmd_ and LowState_ contain 20 motor slots. Within each leg, the slots are hip, thigh, and calf. Use the motion command header 0xFE, 0xEF, level flag 0xFF, and SDK CRC. Use mode 0 or 1 and finite values. For unused slots or slots in mode 0, set kp, kd, and tau to zero, and set q and dq to zero or their respective sentinels. PosStopF = 2.146e9f clears q and kp, and VelStopF = 16000.0f clears dq and kd. Both leave tau unchanged. Hardware STOP uses a separate path. D2W wheel slots require kp = 0. Read the actuator limits from rt/kinatric/robot_description before building targets and use gains calibrated for the deployed robot.
  1. Call ReleaseMode() from the SDK participant that will publish the low-level stream. Poll CheckMode() until name is empty.
  2. Start the valid LowCmd_ stream from a single writer. Confirm controller=external, the matching authorization.participant, and a populated authorization.low_writer in control_state.
  3. To return control, keep the stream running during SelectMode("normal") and verify CheckMode() reports name="normal". Stop publishing when the handover succeeds.
The deployment repository’s test helper tests/sdk/support/d2_client.py hold is a 12-leg-axis hold. It takes position targets from the first CRC-checked LowState_ sample it receives, accepts caller-supplied --kp, --kd, and --seconds, and publishes about every 5 ms. For D2W, use the robot description and a wheel-aware publisher when commanding the wheel axes.

Motor Command Receipts

rt/kinatric/lowcmd_receipt carries kinatric::LowCmdReceiptV1. Join it with rt/kinatric/external_lowcmd_origin (kinatric::ExternalLowCmdOriginV1) on owner, session_id, and tick to trace an external command selected by the HAL. Origin data includes the participant, writer, grant epoch, and relay source timestamp. Use matching Kinatric generated types on the client and board. requested_mask, accepted_mask, and the applied array use the Kinatric D2 motor slot order shown above. Inspect the corresponding accepted_mask bit before reading applied[i]. Compare completed_ns with deadline_ns to check timing, and use joint feedback to verify the resulting motion. Both HAL timestamps use the board’s monotonic clock, while the origin’s relay_source_ns is a board DDS timestamp.