How real-stanford/arx5-sdk works
Purpose and Entry Points
ARX5 SDK is a ROS-free C++ control library with Python bindings for ARX5/X5/L5/X7 robot arms. It drives arm motors over CAN/EtherCAT-CAN, offering background joint control and Cartesian end-effector control. Primary user entry points are Python examples under python/examples/, C++ examples under examples/, and the pybind module python/arx5_pybind.cpp.
Controller Core
The controller layer owns robot lifecycle, state/target management, safety limits, and the high-rate control loop. ControllerBase provides shared behavior; joint and Cartesian controllers specialize command interpretation.
• include/app/controller_base.h
• src/app/controller_base.cpp
• include/app/joint_controller.h
• src/app/cartesian_controller.cpp
Control inputs are converted into bounded joint-level targets; configured joint position, velocity, and torque limits are the internal safety boundary, but callers must apply additional application-level checks, particularly near singularities or with noisy inputs.
Kinematics and Cartesian Control
Cartesian control maps desired end-effector motion/poses to joint commands through the solver and a selected robot URDF. This separates application-space command generation from actuator-space execution.
• include/app/cartesian_controller.h
• include/app/solver.h
• models/X5.urdf
• models/L5.urdf
Multiple arm/model variants are represented by distinct URDFs, including X5, L5, and left/right X7 variants.
Hardware Transport Boundary
The hardware layer abstracts motor communication through CAN frames and SocketCAN. Linux network/CAN interfaces are the operational boundary: USB-CAN adapters expose can* devices, while EtherCAT-CAN requires raw/network capabilities on the process.
• include/hardware/arx_can.h
• include/libcan/SocketCAN.h
• include/libcan/CANFrame.h
The library depends on physical ARX motor hardware and Linux SocketCAN/Ethernet networking; it is not a simulator or web service.
Python SDK and Interprocess Options
Pybind exposes the C++ controllers/configuration to Python, with type declarations for IDE/static-analysis consumers. Python applications can directly control one or multiple arms; examples cover joint control, waypoint scheduling, teleoperation, calibration, torque control, and bimanual use.
• python/arx5_pybind.cpp
• python/arx5_interface.pyi
• python/examples/test_joint_control.py
Optional ZeroMQ client/server modules provide a process/network control boundary. Shared-memory queues, ring buffers, and ndarrays support local high-throughput peripheral/control pipelines.
• python/communication/zmq_client.py
• python/communication/zmq_server.py
• python/shared_memory/shared_memory_ring_buffer.py
Operator Input and Replay Flows
Keyboard and SpaceMouse inputs feed Cartesian commands; teach/replay records or reuses robot trajectories. SpaceMouse support depends on the host spacenav service/library.
• python/examples/keyboard_teleop.py
• python/examples/spacemouse_teleop.py
• python/examples/teach_replay.py
Build, Binary Distribution, and Runtimes
CMake builds the native library, examples, and Python extension. Conda environments support source builds across Python 3.8–3.12; wheel packaging distributes prebuilt x86_64 and aarch64 binaries for pip installation, including bundled architecture-specific libraries.
• CMakeLists.txt
• python/CMakeLists.txt
• wheels/setup.py
• wheels/Dockerfile.x86_64
Main entry points: arx5_pybind.cpp Pybind module · controller_base.h ControllerBase · cartesian_controller.cpp Cartesian controller · SocketCAN.h SocketCAN
Components 19
Native Control Core
- C++ examples
- ControllerBase · Owns state, targets, and bounded joint safety limits.
include/app/controller_base.h - Joint controller
include/app/joint_controller.h - Cartesian controller
src/app/cartesian_controller.cpp - Kinematics solver
include/app/solver.h - Robot URDFs · Selects X5, L5, or other arm variants for Cartesian control.
models/X5.urdf
Hardware Transport
- ARX CAN layer
include/hardware/arx_can.h - SocketCAN
include/libcan/SocketCAN.h - CAN frames
include/libcan/CANFrame.h - ARX motors & CAN network · USB-CAN or EtherCAT-CAN requires Linux network capabilities.
Python SDK & Flows
- Pybind module
python/arx5_pybind.cpp - Python API declarations
python/arx5_interface.pyi - Python control examples · Includes direct joint control, waypoints, torque, calibration, and bimanual use.
python/examples/test_joint_control.py - Keyboard & SpaceMouse teleop · Converts operator input into Cartesian commands.
python/examples/keyboard_teleop.py - Teach/replay · Records or reuses robot trajectories.
python/examples/teach_replay.py - ZeroMQ client/server
python/communication/zmq_client.py - Shared-memory ring buffer
python/shared_memory/shared_memory_ring_buffer.py
Build & Distribution
- CMake build · Builds the library, examples, and Python extension.
CMakeLists.txt - Wheel packaging · Produces x86_64 and aarch64 pip binaries.
wheels/setup.py
Connections 21
- C++ examples → ControllerBase: uses
- Joint controller → ControllerBase: specializes
- Cartesian controller → ControllerBase: specializes
- Cartesian controller → Kinematics solver: solves Cartesian targets
- Kinematics solver → Robot URDFs: uses selected model
- ControllerBase → ARX CAN layer: sends bounded joint targets
- ARX CAN layer → SocketCAN: transports over
- SocketCAN → CAN frames: encodes
- SocketCAN → ARX motors & CAN network: uses can* interface
- Pybind module → ControllerBase: exposes
- Pybind module → Joint controller: exposes
- Pybind module → Cartesian controller: exposes
- Python API declarations → Pybind module: declares types for
- Python control examples → Pybind module: controls through
- Keyboard & SpaceMouse teleop → Cartesian controller: feeds Cartesian commands
- Teach/replay → Pybind module: records and replays through
- ZeroMQ client/server → Pybind module: optional remote control
- Shared-memory ring buffer → ZeroMQ client/server: supports local pipelines
- CMake build → Pybind module: builds
- CMake build → C++ examples: builds
- Wheel packaging → Pybind module: distributes