unitree_sdk2_rs 0.1.0

Unitree SDK2 的 Rust 封装:msg 驱动的 DDS 类型生成 + CDR 序列化 + 订阅/发布/RPC
docs.rs failed to build unitree_sdk2_rs-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

unitree_sdk2_rs

Unitree SDK2 的 Rust 封装。

  • msg 驱动:从 msgs/*.msg 自动生成 Rust 类型(CDR 布局与 C++ 一致)
  • CDR 序列化:用 cdr crate,与 Cyclone DDS 逐字节兼容
  • 订阅/发布subscribe::<T>(topic) / Publisher::<T> 泛型 API
  • RPCrpc::RpcClient / rpc::RpcServer

依赖的 SDK

构建时从 git 获取 unitree_sdk2([package.metadata] 配置,可用 feature 或环境变量切换):

# 消费方 Cargo.toml
unitree_sdk2_rs = { path = "...", features = ["internal"] }   # internal / custom / 默认 GitHub
source URL
default https://github.com/unitreerobotics/unitree_sdk2.git
internal internal url
custom 配合 env UNITREE_SDK2_URL

环境变量可覆盖:UNITREE_SDK2_SOURCE / UNITREE_SDK2_URL / UNITREE_SDK2_DIR

快速开始

use unitree_sdk2_rs::{init_dds, subscribe, Publisher};
use unitree_sdk2_rs::unitree_hg::msg::dds_::BmsState;

init_dds(0, "eth0", "");
let (_sub, rx) = subscribe::<BmsState>("rt/lf/bmsstate");

结构

unitree_sdk2_rs/
  src/
    lib.rs            # 库入口:subscribe / Publisher / init_dds / RPC
    rpc.rs            # RpcClient / RpcServer
    gen/              # build.rs 从 msg 生成(gen_types / gen_ffi / gen_topics)
  cpp/
    dds_bridge.{h,cpp}  # Subscriber/Publisher 模板 + CDR 序列化
    rpc_bridge.{h,cpp}  # RPC 桥
  msgs/               # msg 源文件(unitree_hg/unitree_go/unitree_api)
  build.rs            # msg→Rust/C++ 代码生成 + SDK 获取 + cxx 编译