跳到主要内容

Low Level API

#include <latentos/sdk/low_level/low_level_client.h>
find_package(latentos_sdk_low_level CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE latentos::sdk_low_level)

类:latentos::sdk::low_level::LowLevelClient

explicit LowLevelClient(core::Session& session);

void SubscribeJointState(JointStateCallback callback);
std::optional<JointState> GetLatestJointState() const;
void SendJointCommand(const JointCommand& command);

JointState

JointState 使用同索引的并行数组描述各关节。

字段类型说明
send_time_nsstd::int64_t消息发送时间,ns
joint_numstd::int32_t关节数量
namestd::vector<std::string>关节名称
positionstd::vector<double>关节位置
velocitystd::vector<double>关节速度
effortstd::vector<double>关节力矩/作用力
motor_temp / pcb_tempstd::vector<std::int16_t>电机与驱动板温度
state_num / err_numstd::vector<std::int16_t>状态码与错误码
heartstd::vector<std::int16_t>心跳值

读取数组前应以实际数组长度为准,不要只信任 joint_num

JointCommand

字段类型说明
namestd::vector<std::string>关节名称
positionstd::vector<double>目标位置
velocitystd::vector<double>目标速度
effortstd::vector<double>前馈力矩/作用力
stiffnessstd::vector<double>刚度增益
dampingstd::vector<double>阻尼增益
max_effortstd::vector<double>最大输出限制
heartstd::vector<std::int16_t>心跳值

所有并行数组应具有相同长度;SDK 使用 position.size() 作为关节数。

危险

SendJointCommand() 直接发送关节目标,不经过运动控制仲裁。使用前必须让机器人进入直接关节模式(例如 joint_test),停止冲突的控制源,并准备吊架和急停。错误命令可能导致机器人突然运动或摔倒。