cmvr-es/protos/cmvr/api/head_joint_command.proto
xtkuang 567ae938ef feat(head): add USB eRPC head control and expression gRPC
Add a head-local USB serial/eRPC backend through the existing device factory,
configuration, BioHeadService, logging and control arbiter. Support typed joint
commands, custom five-joint expressions and six frozen upper-computer presets
with 20 ms transitions, validation, ACK baselines and cancellation.

Retain existing ESP32 behavior and API field numbers. Publish only USB head
registration; preserve the machine-local AGV disable override in the worktree.

Validation: cmvr_es build; four head test targets (17 backend and 14 gRPC cases,
plus protocol and serial tests); live USB connection and gRPC state query.
The user additionally confirmed physical testing passed.
2026-11-11 14:58:50 +08:00

199 lines
5.6 KiB
Protocol Buffer
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package cmvr.api;
import "cmvr/api/common.proto";
// 头部关节运动模式。
enum HeadJointMotionMode {
HEAD_JOINT_MOTION_IMMEDIATE = 0;
HEAD_JOINT_MOTION_S_CURVE = 1;
HEAD_JOINT_MOTION_FOLLOW = 2;
}
// 最近一次设备命令的处理结果。
enum HeadJointCommandOutcome {
HEAD_JOINT_COMMAND_NONE = 0;
HEAD_JOINT_COMMAND_ACKNOWLEDGED = 1;
HEAD_JOINT_COMMAND_REJECTED = 2;
HEAD_JOINT_COMMAND_UNKNOWN = 3;
}
// 一个关节的目标位置。
message HeadJointTarget {
string id = 1;
// 单位:rad。
// 区分“没有填写目标”和“明确要求移动到 0 rad”。
oneof target {
double position_rad = 2;
}
}
// 从设备配置中取得的关节信息。
message HeadJointInfo {
string id = 1;
double min_position_rad = 2;
double max_position_rad = 3;
double home_position_rad = 4;
}
// 最近一次获得固件 ACK 的目标缓存。
// 这里保存的是命令目标,不是机械位置测量值。
message HeadJointTargetState {
string id = 1;
double target_position_rad = 2;
bool target_valid = 3;
}
// 头部关节控制命令。
message HeadJointCommand {
// 单路或多路目标控制。
message Move {
// 本次未列出的通道不参与目标下发。
// 驱动会拒绝重复的通道 ID。
repeated HeadJointTarget targets = 1;
}
// 显式移动到配置中的 home 位置。
message Home {}
// Reopen and probe service 1 without sending any position target.
message Reconnect {}
// Cancel later host-side expression frames; this is not a hardware stop.
message CancelExpression {}
// 设置设备运动模式。
message Mode {
// 区分未填写和明确选择 IMMEDIATE。
oneof value {
HeadJointMotionMode mode = 1;
}
}
// 设置指定关节的运动约束。
message Constraints {
string id = 1;
double max_velocity_rad_s = 2;
double max_acceleration_rad_s2 = 3;
double max_jerk_rad_s3 = 4;
}
// 设置指定关节的位置增益。
message PositionGain {
string id = 1;
// 0 是合法增益,需要与未填写区分。
oneof value {
double gain = 2;
}
}
// 设置设备更新周期,单位:ms。
message UpdatePeriod {
uint32 period_ms = 1;
}
message Request {
CommandHeader.Request header = 1;
// 一条请求明确执行一项操作。
oneof operation {
Move move = 2;
Home home = 3;
Mode mode = 4;
Constraints constraints = 5;
PositionGain position_gain = 6;
UpdatePeriod update_period = 7;
Reconnect reconnect = 8;
CancelExpression cancel_expression = 9;
}
}
message Feedback {
// Move/configuration: success means firmware ACK, not mechanical arrival.
// Reconnect: success means open + service-1 probe, without automatic motion.
// CancelExpression: success means cancellation was requested for later host
// frames, not that firmware trajectory/PWM or the mechanism was stopped.
// A timed-out write may already have taken effect; do not blindly retry.
CommandHeader.Feedback header = 1;
}
}
// 查询头部驱动的配置和缓存状态。
message GetHeadJointStateCommand {
message Request {
CommandHeader.Request header = 1;
}
message Feedback {
// success=true 表示成功取得驱动状态。
// 设备连接和命令结果仍需检查下面的对应字段。
CommandHeader.Feedback header = 1;
// 表示串口传输连接状态,不是持续的硬件健康检测。
bool connected = 2;
// 配置中的关节信息,不是从控制板读取的标定。
repeated HeadJointInfo joint_info = 3;
// 最近一次获得 ACK 的目标及其有效性。
repeated HeadJointTargetState targets = 4;
HeadJointCommandOutcome last_command_outcome = 5;
string last_error = 6;
// 当前 eRPC 服务 1 不提供真实关节位置测量反馈。
bool position_feedback_available = 7;
// Presets come from configuration, not measured hardware poses.
repeated HeadExpressionInfo expressions = 8;
bool expression_baseline_ready = 9;
bool hardware_emergency_stop_available = 10;
}
}
// One configured expression, with a stable ID and an exact display name.
message HeadExpressionInfo {
string expression_id = 1;
string expression_name = 2;
repeated HeadJointTarget targets = 3;
}
// Synchronously send a complete five-joint expression through a bounded host
// transition. Omitted joints and partial expressions are rejected.
message SetHeadExpressionCommand {
message Request {
CommandHeader.Request header = 1;
repeated HeadJointTarget targets = 2;
// Finite duration in [0.2, 5.0] seconds; 0 or omission is rejected.
double transition_duration_s = 3;
}
message Feedback {
// Every transmitted frame, including the final target, was acknowledged.
// This is not proof of mechanical arrival; late intermediate frames may be skipped.
CommandHeader.Feedback header = 1;
}
}
// Select one configured expression by exact stable ID or exact name.
// Unknown selectors and ambiguous names are rejected without fallback.
message PlayHeadExpressionCommand {
message Request {
CommandHeader.Request header = 1;
oneof expression {
string expression_id = 2;
string expression_name = 3;
}
// Finite duration in [0.2, 5.0] seconds; 0 or omission is rejected.
double transition_duration_s = 4;
}
message Feedback {
// Every transmitted frame, including the final target, was acknowledged.
// This is not proof of mechanical arrival; late intermediate frames may be skipped.
CommandHeader.Feedback header = 1;
string expression_id = 2;
string expression_name = 3;
}
}