feat(joint-follow): host-side entry for CMD_JOINT_FOLLOW (0x08) - #14
Merged
Merged
Conversation
Arm.joint_follow(q, dq, kp, kd) sends 16N bytes with no tau; the firmware computes the feedforward itself. Registered in COMMAND_COVERAGE so the cross-repo contract test keeps both sides honest, and the two new error codes (payload short, non finite values) plus the three return codes the accept function shares with move_mit_all are in ERR_TEXT. The contract tests caught all four omissions on their own -- the coverage list, the exercised manifest, the symbolic site manifest and its pinned count -- which is exactly what they are for.
审查缺口:0x08 的载荷布局(q_target | dq_ref | K | B 各 N 个 f32 = 16N 字节)
此前**没有任何判据**。test_full_coverage 只断言"这条命令发出去过",不看载荷
内容 ⇒ 只改一端(SDK 打包或固件解析)不会被任何用例发现。
新判据两头都钉:
① 从固件 usb_cmd.h 的声明里正则提取分段顺序(顺序/长度改了先红)
② 用互不相同的哨兵值发出**真实帧**,逐段核对解出的值 —— 不复述 arm.py 的
表达式:期望值与实现同源的话判据会随实现一起错(本仓栽过:ACK/ERR 常量
写错而测试自洽地全绿)。
判别力已双向反验:
· 改固件声明顺序(用临时目录副本,不动真文件)⇒ 红
· 改 SDK 打包顺序(临时改 arm.py 后还原)⇒ 红
654 passed / 2 skipped(新增 1 条)。
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the host-side entry point for
CMD_JOINT_FOLLOW(0x08) and pins its payloadlayout against the firmware, so a caller can drive the slave arm's follow loop
without the SDK re-deriving the frame by hand.
The command is the one the isomorphic teleop stack uses on the slave. Its payload
carries four groups — target position, target velocity,
kp,kd— and notau;the firmware computes the gravity feedforward and the limit wall itself, which is
what makes the frame round-trip cheaper than the older
send_mit_allpath. Nothingin the payload is self-describing, so a drifted layout is silent until the arm
misbehaves on hardware. The new test closes that gap.
No consumer breaks. The command is additive: an arm without it answers
ERRwithcmd = 0x08, which the existing capability check already treats as "not supported".Changes
src/litearm/_protocol.py— registerCMD_JOINT_FOLLOW = 0x08alongside theother command codes.
src/litearm/arm.py—Arm.joint_follow(q, dq, kp, kd)sends the frame. Thefour groups are packed in firmware order and the call is a single round trip.
src/litearm/errors.py— map the command's error code so a rejected framereports which command was refused rather than an anonymous failure.
tests/test_protocol_sync.py— extract the field order from the firmware headerusb_cmd.hwith a regex, then send a real frame with a distinct sentinel in everyslot and read the bytes back segment by segment. A reordering or a dropped field
fails the test rather than shipping.
tests/test_error_codes.py,tests/test_full_coverage.py— extend the existingtables to cover the new command code.
Testing
The two skips are the live-hardware cases in
tests/test_live.py, gated onLITEARM_LIVE=1; they are skipped by design on a machine without an arm attached,not a pre-existing failure.
The payload-layout test was mutation-checked both ways: reordering two segments in
the expected order, and dropping one, each turn it red.
Issues
None. No issue was opened for this work, so there is nothing to close.