Skip to main content

25-servo humanoid robot

Protocol boundary: vendor-specific PDO joint protocol, not CiA 402

The joint modules on this page use a vendor-specific PDO protocol (Mode / TargetPosition / Kp / Kd, position mode Mode = 1), not the CiA 402 state machine, and this is not a synchronized axis / electronic gear example. Here Mode = 1 is a module-specific byte. It is not the same encoding as the CiA 402 0x6060 mode number (PP=1 / CSV=9 / CSP=8), so do not mix them. Do not treat it as a template for the 0x6040 / 0x6041 enable sequence; for CiA 402 multi-axis coordination see Synchronized axis / electronic gear.

Hardware configuration​

  • Master: Windows x64 × 1 (the example on this page uses the Python SDK; the wheel is Windows x64 only) + RTL8309N switch chip
  • EtherCAT topology: 8 × 4-core cables (4 redundant loops)
  • Joint drives: integrated joint modules × 25 (PDO; position/torque/impedance modes)
  • Joint distribution (25 DOF):
    • Loop 1 (left arm route): waist yaw ×1 + waist pitch ×1 + left shoulder ×3 + left elbow ×1 + left wrist ×1 = 7 axes
    • Loop 2 (right arm route): neck yaw ×1 + right shoulder ×3 + right elbow ×1 + right wrist ×1 = 6 axes
    • Loop 3 (left leg): left hip ×3 + left knee ×1 + left ankle ×2 = 6 axes
    • Loop 4 (right leg): right hip ×3 + right knee ×1 + right ankle ×2 = 6 axes
  • Sensors:
    • Six-axis force/torque sensors × 2 (left foot / right foot, mounted at the end of Loop 3 / Loop 4 respectively)
    • IMU × 1 (torso, mounted on Loop 1, next to the waist joints)
  • Cable routing topology (MCU in the center of the chest cavity):
    • Loop 1: MCU → IMU → waist yaw → waist pitch → ↗ left shoulder → left elbow → left wrist → return
    • Loop 2: MCU → neck yaw → ↗ right shoulder → right elbow → right wrist → return
    • Loop 3: MCU → ↘ left hip → left knee → left ankle → left foot force/torque sensor → return
    • Loop 4: MCU → ↘ right hip → right knee → right ankle → right foot force/torque sensor → return
  • Network isolation: RTL8309N port isolation; the 4 loops do not interfere with each other
  • Algorithms: RL policy trained offline in Isaac Lab (deployed as ONNX) + composite vision model trigger

Performance figures​

  • Control cycle: 500 µs (2 kHz)
  • Total joints: 25 axes (waist 2 + left arm 5 + neck 1 + right arm 5 + left leg 6 + right leg 6)
  • Total EtherCAT nodes: 28 (25 joint modules + 2 force/torque sensors + 1 IMU)
  • Loop load: 8 / 6 / 7 / 7 nodes
  • Joint position accuracy: ±0.01°
  • Whole-body motion planning rate: 50 Hz (the RL policy inference rate)

Control cycle and the PDO callback​

  • The 500 µs cycle is set by master.config.loop_cycle = 500_000 (the same value as DC SYNC0); it is not a hard-coded loop tick. step() is attached to the SDK cyclic subscription master.events.add_pdo_cyclic_sync(...).
  • On the Python side this subscription is not the bus thread: the SDK isolates the callback onto a latest-only worker, and when the callback is slow only the last cycle is kept (coalesced, frames dropped), so do not assume the callback fires exactly once every 500 µs. The requirements are: keep step() short, write the complete command every tick, and do no inference or I/O. The bus side still sends the process image every cycle according to loop_cycle; values written to the output image take effect in the next bus cycle.
  • The two rates each own one part: the 50 Hz inference thread only updates the shared targets _targets; the cyclic subscription only reads the targets and writes the PDOs. One inference run takes milliseconds; never put it inside the callback and wait for it — that blows the 500 µs cycle straight away.
  • The cycle is defined in exactly one place: loop_cycle (ns) is the only source, and DC SYNC0 is configured to the same value with master.configure_dc(500_000); do not hard-code tick counts or thresholds elsewhere based on "2 kHz".

Application scenario​

A whole-body motion control system for a humanoid robot, built on a Windows x64 master. The controller board sits in the center of the chest cavity and drives 25 integrated joint modules through an RTL8309N nine-port switch chip (1 port to the controller, 8 ports to the transmit and receive ends of the 4 redundant loops).

The waist and neck joints do not occupy loops of their own; they are spliced into the arm loops nearby: Loop 1 passes through the waist and then goes up to the left arm (7 axes), Loop 2 passes through the neck and then goes up to the right arm (6 axes), and Loops 3 and 4 run down independently to the left and right leg (6 axes each).

Each loop carries a sensor at its end (foot force/torque sensor or torso IMU), and the cables are routed inside the limbs. The joint modules support mixed position/torque/impedance control, and the master exchanges PDO frames on a 2 kHz bus cycle.

Code description​

Overall architecture​

System architecture​

The system uses asynchronous dual-rate control: the policy inference thread is decoupled from the PDO servo callback:

The policy network is trained by Isaac Lab in a simulation environment, exported as an ONNX model and deployed to the real hardware. Deployment does not depend on Isaac Lab; only ONNX Runtime is required.

The inference thread runs independently and writes the latest target positions into the shared buffer under a lock; the cyclic subscription writes the latest targets into the output process image on the 2 kHz bus tick without blocking on inference time. The Python SDK subscription is a latest-only worker that coalesces and drops ticks when the callback is slow, so step() must be short and must write the full command every tick.

Observation space (96 dimensions): projected_gravity(3) + base_ang_vel(3) + joint_pos-default(25) + joint_vel(25) + last_actions(25) + foot_contact(6+6) + commands(3)

Custom services

The RL policy training in this case (building the Isaac Lab simulation environment, reward function design, PPO training and tuning) and the ONNX model deployment optimization, together with the underlying timing logic, are additional custom work and are not included in the EtherCAT master software license.

Darra driver optimization: bidirectional redundancy, hot-plug detection and recovery

All 4 loops use cable redundancy — the main port and the redundant port send frames at the same time, and the receiving side merges the results from both sides. When a cable breaks somewhere in the main ring, the slave at the break closes its port, the frames from both sides each travel as far as the break, and after merging all slaves that are still on the ring remain reachable; at the instant of the break there may be 1-2 cycles of WKC fluctuation, and zero frame loss is not guaranteed.

Cables at the joints of a humanoid robot are bent repeatedly, so the probability of a ring break is higher than in fixed installations. Redundancy protection requires a ring topology: with only the main port left (the secondary port link is unavailable) or with a purely linear topology there is no second path, and a single break cuts off the whole segment; once the cable is reconnected the link recovers automatically without reconfiguration.

When a joint module is powered off and reconnected (collision protection, repair or replacement), the driver detects the offline slave automatically through WKC monitoring plus per-slave probing, and distinguishes a ring break from a genuine hot-plug. After the slave comes back online it recovers automatically, and the application layer receives the online callback.

Code example​

PDO structure definitions​

import ctypes

class JointInput(ctypes.LittleEndianStructure):
"""关节模组反馈 PDO (TxPDO)""" # Joint module feedback PDO (TxPDO)
_pack_ = 1
_fields_ = [
("Mode", ctypes.c_uint8), # current mode
("ErrorCode", ctypes.c_uint8), # error code
("Position", ctypes.c_int32), # actual position (0.001°)
("Velocity", ctypes.c_int32), # actual velocity (0.01°/s)
("Torque", ctypes.c_int16), # actual torque (0.01Nm)
("Temperature", ctypes.c_uint8), # temperature (°C)
]

class JointOutput(ctypes.LittleEndianStructure):
"""关节模组指令 PDO (RxPDO)""" # Joint module command PDO (RxPDO)
_pack_ = 1
_fields_ = [
("Mode", ctypes.c_uint8), # 0=idle 1=position 2=velocity 3=torque
("TargetPosition", ctypes.c_int32), # target position (0.001°)
("FeedforwardTorque", ctypes.c_int16), # feedforward torque (0.01Nm)
("Kp", ctypes.c_uint16), # position gain
("Kd", ctypes.c_uint16), # damping gain
]

class ForceInput(ctypes.LittleEndianStructure):
"""六维力传感器反馈 PDO""" # 6-axis force sensor feedback PDO
_pack_ = 1
_fields_ = [
("Fx", ctypes.c_int32), ("Fy", ctypes.c_int32), ("Fz", ctypes.c_int32),
("Mx", ctypes.c_int32), ("My", ctypes.c_int32), ("Mz", ctypes.c_int32),
] # units: 0.001N / 0.001Nm

class ImuInput(ctypes.LittleEndianStructure):
"""IMU 反馈 PDO""" # IMU feedback PDO
_pack_ = 1
_fields_ = [
("AccX", ctypes.c_int16), ("AccY", ctypes.c_int16), ("AccZ", ctypes.c_int16),
("GyroX", ctypes.c_int16), ("GyroY", ctypes.c_int16), ("GyroZ", ctypes.c_int16),
("Roll", ctypes.c_int16), ("Pitch", ctypes.c_int16), ("Yaw", ctypes.c_int16),
]

Control code​

RL policy deployment → EtherCAT PDO asynchronous bridging (the policy is trained offline by Isaac Lab). The inference thread runs asynchronously (50 Hz); the cyclic subscription only reads the latest targets and writes them into the output process image (2 kHz bus), and inference time does not block the bus cycle.

import math
import time
import threading
import numpy as np
import onnxruntime as ort
from darra_ethercat import EtherCATMaster

NUM_JOINTS = 25
OBS_DIM = 96
INFERENCE_HZ = 50

# ── Joint module vendor protocol constants (values per the module manual) ──────────────
POSITION_MODE = 1 # feedback/command Mode: 1 = position mode
FAULT_BIT_MASK = 0x01 # ErrorCode bit0 = module fault (per the manual)
DEFAULT_KP = 600 # normal tracking gain
DEFAULT_KD = 40

# Hold state (when a joint loses its enable, faults, or inference fails): target = current actual position.
# Kp must not be set to 0 — a target equal to the measured value only guarantees "no force when the error
# is 0"; the load's gravity will still push the joint down. Only with Kp still present (reduced but not 0) can this pose be held, and a little damping prevents the whole limb from collapsing instantly. Tune per the module manual.
SAFE_KP = 200 # ≈ 1/3 of the normal gain
SAFE_KD = 20

# Logical joint index → physical slave index map (joints only; sensors are accessed through separate constants)
# The EtherCAT scan order follows the ring topology; sensors are interleaved, so the joints are not necessarily numbered contiguously from 0
# master.slaves is a 0-based list: slaves[0] is slave 1 (= the first node of Loop 1, the IMU); slave_num starts at 1
# Loop 1: [0]=IMU, [1]=waist yaw, [2]=waist pitch, [3~7]=left shoulder ×3 + left elbow + left wrist
# Loop 2: [8]=neck yaw, [9~13]=right shoulder ×3 + right elbow + right wrist
# Loop 3: [14~19]=left hip ×3 + left knee + left ankle ×2, [20]=left foot force/torque sensor
# Loop 4: [21~26]=right hip ×3 + right knee + right ankle ×2, [27]=right foot force/torque sensor
JOINT_SLAVE_MAP = [
1, 2, # waist yaw, waist pitch (Loop 1, after the IMU)
3, 4, 5, 6, 7, # left shoulder ×3, left elbow, left wrist (Loop 1)
8, # neck yaw (Loop 2)
9, 10, 11, 12, 13, # right shoulder ×3, right elbow, right wrist (Loop 2)
14, 15, 16, 17, 18, 19, # left hip ×3, left knee, left ankle ×2 (Loop 3)
21, 22, 23, 24, 25, 26, # right hip ×3, right knee, right ankle ×2 (Loop 4)
]
IMU_SLAVE_IDX = 0 # IMU slave index (first node of Loop 1)
FORCE_L_SLAVE_IDX = 20 # left foot force/torque sensor slave index
FORCE_R_SLAVE_IDX = 27 # right foot force/torque sensor slave index

# Joint limits (°) — identical to the URDF of the training environment
JOINT_MIN = np.array([
-90,-30, -180,-90,-90,0,-180, # Loop 1: waist ×2 + left arm ×5
-90, -180,-90,-90,0,-180, # Loop 2: neck ×1 + right arm ×5
-90,-45,-45,0,-45,-30, # Loop 3: left leg ×6
-90,-45,-45,0,-45,-30, # Loop 4: right leg ×6
], dtype=np.float32)

JOINT_MAX = np.array([
90,30, 180,90,90,135,180,
90, 180,90,90,135,180,
90,45,45,135,45,30,
90,45,45,135,45,30,
], dtype=np.float32)

# The policy side always uses radians (the Isaac Lab unit): convert the limits once, then convert back to degrees only just before sending
JOINT_MIN_RAD = np.radians(JOINT_MIN)
JOINT_MAX_RAD = np.radians(JOINT_MAX)


class RLPolicyBridge:
"""RL policy deployment bridge (Isaac Lab training → ONNX deployment → EtherCAT PDO)

The inference thread runs asynchronously at 50 Hz; the cyclic subscription writes the latest targets
into the output process image (2 kHz bus; the Python subscription is a latest-only worker).
PDO structures are mapped zero-copy into the process image through slave.pdo.inputs_mapping / outputs_mapping.
"""

def __init__(self, master: EtherCATMaster,
onnx_path: str, norm_path: str):
self.master = master
self.policy = ort.InferenceSession(
onnx_path, providers=['CPUExecutionProvider'])
self.input_name = self.policy.get_inputs()[0].name

# Normalization parameters are loaded in **the units used in training**: Isaac Lab joint
# positions/velocities/actions are all radians (rad, rad/s). PDO values are 0.001° / 0.01°/s —
# not the same thing. Conversion happens only in `_build_obs` / `step()`;
# never feed degrees into the policy, or the observation differs from the training
# distribution by a factor of 57.3 across the board.
norm = np.load(norm_path)
self.obs_mean = norm['obs_mean'].astype(np.float32)
self.obs_var = norm['obs_var'].astype(np.float32)
self.action_scale_rad = norm.get(
'action_scale',
np.full(NUM_JOINTS, 0.5, dtype=np.float32)).astype(np.float32) # rad / action unit
self.default_pos = norm.get(
'default_pos',
np.zeros(NUM_JOINTS, dtype=np.float32)).astype(np.float32) # rad

self.obs = np.zeros(OBS_DIM, dtype=np.float32)
self.last_actions = np.zeros(NUM_JOINTS, dtype=np.float32)
self.commands = np.zeros(3, dtype=np.float32)

# Pre-fetch all PDO mappings (the references point into the process image; the master cycle updates the data)
self._joint_inputs = [
self.master.slaves[JOINT_SLAVE_MAP[i]].pdo.inputs_mapping(JointInput)
for i in range(NUM_JOINTS)
]
self._joint_outputs = [
self.master.slaves[JOINT_SLAVE_MAP[i]].pdo.outputs_mapping(JointOutput)
for i in range(NUM_JOINTS)
]
self._imu_input = self.master.slaves[IMU_SLAVE_IDX].pdo.inputs_mapping(ImuInput)
self._force_inputs = [
self.master.slaves[s].pdo.inputs_mapping(ForceInput)
for s in (FORCE_L_SLAVE_IDX, FORCE_R_SLAVE_IDX)
]

# Shared target buffer (written by the inference thread, read by the cyclic callback)
self._lock = threading.Lock()
self._targets = self.default_pos.copy() # rad
self._running = False
self._policy_ok = True # whether inference is in the loop; False = targets not trustworthy, callback holds
self._hold = False # safety gate: True = a joint is not ready/faulted; hold only, do not chase the RL targets
self._notice = None # the callback only writes this notice; the inference thread prints it (no IO in the callback)

# ── Asynchronous inference thread (50 Hz) ──────────────────────────

def start(self):
"""启动异步推理线程""" # Start the asynchronous inference thread
self._running = True
self._thread = threading.Thread(
target=self._inference_loop, daemon=True)
self._thread.start()

def _inference_loop(self):
"""独立线程: 50 Hz 采集观测 → 推理 → 更新共享目标""" # Dedicated thread: sample observations at 50 Hz → infer → update the shared targets
interval = 1.0 / INFERENCE_HZ
while self._running:
t0 = time.monotonic()
self._build_obs()
self._infer()
if self._notice: # safety-gate notices are delivered on the non-real-time thread
print(self._notice)
self._notice = None
elapsed = time.monotonic() - t0
if elapsed < interval:
time.sleep(interval - elapsed)

def _build_obs(self):
"""构建观测向量 (与 Isaac Lab 训练环境完全一致)""" # Build the observation vector (exactly as in the Isaac Lab training environment)
idx = 0

# ① projected_gravity (3)
# The formulas assume the IMU is mounted upright, roll positive to the right, pitch positive nose-up.
# If the module is mounted upside down or the axes differ, all three components change sign and the
# observation no longer matches the training distribution (typical symptom: the robot pushes in the
# wrong direction the moment it is powered on).
# After changing the module or the mounting direction, check with a stationary pose first:
# level and at rest the result should be about (0, 0, -1).
imu = self._imu_input
roll = math.radians(imu.Roll * 0.01)
pitch = math.radians(imu.Pitch * 0.01)
self.obs[idx] = -math.sin(pitch)
self.obs[idx + 1] = math.sin(roll) * math.cos(pitch)
self.obs[idx + 2] = -math.cos(roll) * math.cos(pitch)
idx += 3

# ② base_ang_vel (3)
self.obs[idx] = math.radians(imu.GyroX * 0.01)
self.obs[idx + 1] = math.radians(imu.GyroY * 0.01)
self.obs[idx + 2] = math.radians(imu.GyroZ * 0.01)
idx += 3

# ③ joint_pos - default (25) + ④ joint_vel (25)
# PDO units: position 0.001°, velocity 0.01°/s; policy units: rad / rad/s — convert here, into the same unit as default_pos
for i in range(NUM_JOINTS):
inp = self._joint_inputs[i]
self.obs[idx + i] = \
math.radians(inp.Position * 0.001) - self.default_pos[i]
self.obs[idx + NUM_JOINTS + i] = \
math.radians(inp.Velocity * 0.01)
idx += NUM_JOINTS * 2

# ⑤ last_actions (25)
self.obs[idx:idx + NUM_JOINTS] = self.last_actions
idx += NUM_JOINTS

# ⑥ foot_contact_force (12)
for ft in self._force_inputs:
for val in [ft.Fx, ft.Fy, ft.Fz,
ft.Mx, ft.My, ft.Mz]:
self.obs[idx] = val * 0.001
idx += 1

# ⑦ commands (3)
self.obs[idx:idx + 3] = self.commands

def _infer(self):
"""ONNX 推理 → 更新共享目标""" # ONNX inference → update the shared targets
obs_norm = (self.obs - self.obs_mean) \
/ np.sqrt(self.obs_var + 1e-8)

try:
actions = self.policy.run(
None,
{self.input_name: obs_norm.reshape(1, OBS_DIM)}
)[0][0]
except Exception as e:
# A failed inference must not "keep the previous tick's target and carry on": the policy is no
# longer in the loop, and continuing with the old target is open loop.
# Set _policy_ok=False; the next cyclic callback enters hold state (target = current actual position).
self._policy_ok = False
self._notice = f"[安全门] ONNX 推理异常, 进入保持态: {e}" # [Safety gate] ONNX inference exception, entering hold state: {e}
return

actions = np.clip(actions, -1.0, 1.0).astype(np.float32)
self.last_actions = actions

# Compose the target in policy units (rad), then clip to the joint limits; convert to the drive units (degrees × 1000) only when sending
targets = self.default_pos + actions * self.action_scale_rad
np.clip(targets, JOINT_MIN_RAD, JOINT_MAX_RAD, out=targets)

with self._lock:
self._targets = targets
self._policy_ok = True

# ── Cyclic subscription callback (does not block) ──────────────────────

def step(self):
"""Driven by the PDO cyclic subscription (500 µs bus; the Python subscription is a latest-only
worker, so it is not guaranteed to run on every tick). Non-blocking, no inference.

Every write into the PDO first passes the "ready/fault gate":
① inference must be in the loop (_policy_ok), the feedback Mode of every joint must be position
mode, and ErrorCode must have no fault bit set;
② the send side checks the joint soft limits once more — the shared targets are written by another
thread, and a clip made 20 ms ago does not mean the value is legal now;
③ if any joint fails → target = current actual position, Kp/Kd reduced to the hold values, the hold
flag is set, and the RL targets are no longer followed;
④ if everything is ready → send the RL targets.
Without this gate, when a module loses its enable, enters a fault or inference dies, the PDO would
still carry the RL target position and the robot would rush toward the old target the moment it recovers.
"""
with self._lock:
targets = self._targets

# ① Ready/fault/limit check (reads the feedback process image only; no IO, no blocking)
bad_joint, bad_reason = -1, ""
policy_dead = not self._policy_ok
if policy_dead:
bad_reason = "策略推理异常, 目标不可信" # Policy inference exception, the targets are not trustworthy
else:
for i in range(NUM_JOINTS):
inp = self._joint_inputs[i]
if inp.ErrorCode & FAULT_BIT_MASK:
bad_joint, bad_reason = i, f"故障码 0x{inp.ErrorCode:02X}" # Fault code 0x{inp.ErrorCode:02X}
break
if inp.Mode != POSITION_MODE:
bad_joint, bad_reason = i, f"反馈模式 {inp.Mode} 不是位置模式" # Feedback mode {inp.Mode} is not position mode
break
if targets[i] < JOINT_MIN_RAD[i] or targets[i] > JOINT_MAX_RAD[i]:
bad_joint, bad_reason = i, \
f"目标 {math.degrees(float(targets[i])):.2f}° 超出限位" # Target {math.degrees(float(targets[i])):.2f}° exceeds the limit
break

if policy_dead or bad_joint >= 0:
if not self._hold:
self._hold = True
where = f"关节 {bad_joint} " if bad_joint >= 0 else "" # Joint {bad_joint}
self._notice = f"[安全门] {where}{bad_reason}, 进入保持态" # [Safety gate] {where}{bad_reason}, entering hold state
# ② Hold state: target = current actual position (Kp reduced but not 0, or gravity collapses the joint)
for i in range(NUM_JOINTS):
inp = self._joint_inputs[i]
outp = self._joint_outputs[i]
outp.Mode = POSITION_MODE
outp.TargetPosition = inp.Position
outp.Kp = SAFE_KP
outp.Kd = SAFE_KD
return

if self._hold:
self._hold = False
self._notice = "[安全门] 全部关节回到位置模式且无故障, 恢复跟踪 RL 目标" # [Safety gate] All joints are back in position mode with no fault, resuming tracking of the RL targets

# ③ All ready: send the RL targets (policy unit rad → drive unit 0.001°)
for i in range(NUM_JOINTS):
outp = self._joint_outputs[i]
outp.Mode = POSITION_MODE
outp.TargetPosition = int(math.degrees(float(targets[i])) * 1000)
outp.Kp = DEFAULT_KP
outp.Kd = DEFAULT_KD

def close(self):
self._running = False
self._thread.join(timeout=1)
del self.policy

Wire the cyclic callback​

from darra_ethercat import EtherCATMaster, EcState

# The order cannot be swapped: master → cycle → DC → OP → then take the process image.
# inputs_mapping requires the slave to be in OP; otherwise it throws "PDO input image unavailable".
master = EtherCATMaster() # construction / DENI loading: see the master initialization page
master.config.loop_cycle = 500_000 # ns, the only source of the cycle
if master.loop_cycle != 500_000:
raise RuntimeError(f"LoopCycle 设定失败: 读回 {master.loop_cycle}ns") # LoopCycle setup failed: read back {master.loop_cycle}ns

if not master.set_state(EcState.PRE_OP):
raise RuntimeError("进入 PreOp 失败 — 无法配置 DC") # Failed to enter PreOp — DC cannot be configured
# SYNC0 uses the same value as loop_cycle; returns the number of slaves that accepted DC, <0 = failure.
# 0 = no module supports DC, so the system runs FreeRun (the cycle is still loop_cycle), but you cannot claim "DC synchronized".
if master.configure_dc(500_000) < 0:
raise RuntimeError("DC Sync0 配置失败") # DC Sync0 configuration failed

if not master.set_state(EcState.OP):
raise RuntimeError("进入 OP 失败 — 没有过程映像, inputs_mapping 会抛异常") # Failed to enter OP — there is no process image, so inputs_mapping would throw

bridge = RLPolicyBridge(master, "policy.onnx", "norm.npz") # must come after OP: the constructor takes the PDO mappings
master.events.add_pdo_cyclic_sync(lambda mi: bridge.step()) # writes PDOs only, no inference
bridge.start() # 50Hz: updates the shared targets only

The callback only reads and writes fields and takes one snapshot of the shared targets (the lock is held for a single reference assignment); inference, printing and SDO access never happen inside the callback. Python's add_pdo_cyclic_sync is a latest-only worker: when the callback is slow only the last cycle is kept, so the callback must not contain side effects that "must execute once per tick" (counting, integration, edge detection) — either those rest on an assumption the bus cycle cannot guarantee, or they must be computed on a time base.

Complete example code​

This page is a scenario description (Python SDK plus the vendor-specific PDO of the joint modules; 25 joints / 4 loops is the specific configuration here). The repository has no runnable project with exactly this topology. The closest runnable references:

  • FurutaPendulum — 500 µs / 2 kHz bus cycle, target positions written every tick in the cyclic callback, control thread separated from the UI/decision layer; the cycle structure matches this page (C#).
  • RobotToolChanger — robot multi-axis plus slave loss / drive fault / following-error detection and safety interlocking, corresponding to the "ready/fault gate → hold state" handling on this page (C#).

RL policy training, ONNX inference and joint limit tuning are part of the custom scenario on this page; the reference projects have no corresponding implementation. For Python-side interfaces and enumeration names, refer to Python SDK overview.