feat(basicmicro): position PID get/set for both channels (commands 61-64) - #756
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Adds full Basicmicro position-loop PID configuration support (commands 61–64) for both motor channels, including correct 1024x gain scaling and payload ordering.
Changes:
- Introduces position PID scale constant and command enum values for set/read on M1 and M2.
- Adds
set_position_pid_*andread_position_pid_*APIs plus shared helpers handling wire-order asymmetry. - Extends host golden-frame tests and updates README feature list.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| components/basicmicro/test/basicmicro_host_test.cpp | Adds command ID checks and golden packet/CRC coverage for command 61 position PID payload. |
| components/basicmicro/include/detail/basicmicro_core.hpp | Adds kBasicmicroPositionPidScale and defines commands 61–64 in BasicmicroCommand. |
| components/basicmicro/include/basicmicro.hpp | Adds public position PID get/set APIs for both channels and shared 61–64 encoding/decoding helpers. |
| components/basicmicro/README.md | Documents the new position PID capability in the feature list. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
✅Static analysis result - no issues found! ✅ |
bff92b4 to
70c1d7f
Compare
|
Addressed the review comments:
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
…-64) The component implemented the velocity PID (28/29, 55/56) but not the position PID, so closed-loop position moves could not be configured. Add set_position_pid_m1/m2 (commands 61/62) and read_position_pid_m1/m2 (63/64), covering the full seven-constant position loop: P/I/D gains (scaled by 1024, the position-loop convention -- distinct from the velocity loop's 16.16), MaxI windup limit, deadzone, and the MinPos/ MaxPos clamp. The factory default for every position constant is zero, which clamps all position targets to [0, 0]; these setters are what a CANopen or packet-serial master uses to make position mode usable. Note the documented wire asymmetry: command 61/62 send D, P, I while 63/64 reply P, I, D -- handled inside the shared helpers. Host golden- frame test and README updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153z8MvyCu6YT47myGDn4rK
70c1d7f to
0738d35
Compare
|
Second round addressed:
|
|
Self-reviewed the full diff — no further issues. |
Summary
The component implemented the velocity PID (28/29, 55/56) but not the position PID, so closed-loop position moves could not be configured. This adds the full position-loop support for both channels:
set_position_pid_m1/set_position_pid_m2(commands 61/62)read_position_pid_m1/read_position_pid_m2(commands 63/64)Each covers the seven-constant position loop: P/I/D gains,
MaxI(integral windup limit),Deadzone(encoder counts), and theMinPos/MaxPosclamp.Details
kBasicmicroPositionPidScalealongside the existingkBasicmicroPidScale.D, P, Iwhile 63/64 replyP, I, D(per the manual) — handled inside the sharedset_position_pid/read_position_pidhelpers and documented.[0, 0]; these setters are what a master (packet-serial or a CANopen bridge to the same registers) uses to make position mode usable.Testing
test/basicmicro_host_test.cpp): the command enum values and a command-61 payload (D/P/I ×1024 + raw MaxI/Deadzone/MinPos/MaxPos, 28 data bytes) with CRC —ALL PASSED.🤖 Generated with Claude Code