Repository navigation
fix: read fresh status before motion and gate the grasp handover - #62
Merged
Merged
Conversation
The motor answers every control frame with a status frame. Reading one frame per call left the rest queued, and the age was stamped when a frame was read, so an old position looked fresh. On 2026-11-18 a ramp after a force hold started from the hold's first pose (78 mm) while the jaws were at 26 mm: the first frame demanded ~0.7 rad of error and the drive left at 23 rad/s out of a 20 mm/s move. poll() now drains the queue (bounded at kMaxDrainFrames) and lets the newest frame define the state. poll_until() checks the target's rx_count instead of the motor returned by the drain, so another registered motor's frame cannot hide the update. CanTransport now implements the CanIo interface so a queue-backed fake can drive the controller in tests.
fresh_state() requests a status frame (0xCC) before every motion and refuses to plan when no frame answers. A cached snapshot -- even one younger than kStaleAfterS -- is not enough: at 20 mm/s, half a second of silence is 10 mm of unknown. The final reach check and every hold slice use it too. The force-approach handover also requires the window's average speed to be below MotionConfig::stall_speed_mm_s (2 mm/s). A force-budgeted approach that crawls (~8 mm/s on this bench) is not contact; handing it to the torque-only hold accelerates the jaws across the free stroke. A mid-hold CommError now drops the torque and returns ok=false instead of leaving the last torque on the bus, and an abort=True release reads the cached position -- a zero-gain frame needs no fresh pose and an E-stop must not wait for a status answer.
Add the force-approach speed floor to both READMEs: the grasp row, the slow-creep failure combination, and the MotionConfig table.
|
🎉 This PR is included in version 1.1.2 🎉 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
Ports the stale-state and true-stop hand-over fixes from the Python SDK (nexform-tech/litegrip-python#86) to the C++ CAN controller and action engine.
Changes
MotorController::poll()drains every queued status frame, bounded atkMaxDrainFrames, and lets the newest one define the state. Reading one frame per call left older answers queued, and the age was stamped when a frame was read, so an old position looked fresh.poll_until()decides on the target'srx_count, not on the motor returned by the drain, so another registered motor's frame cannot hide the update.CanTransportnow implements theCanIointerface, so a queue-backed test transport can drive the controller.MotionEngine::fresh_state()requests a status frame (0xCC) before every motion, the final reach check and every hold slice, and refuses withCommErrorwhen no frame answers.MotionConfig::stall_speed_mm_s(2 mm/s); the field is validated at construction.CommErrordrops the torque and returnsok = falsewithcycles = 0, instead of leaving the last torque on the bus.abort = truerelease reads the cached position: a zero-gain frame needs no fresh pose, and an E-stop must not wait for a status answer.Testing
cmake --build build -jthenctest --test-dir build:npx --yes markdownlint-cli2@0.23.3 README.md: 0 issues.New coverage:
test_can_poll_drain(newest frame wins, foreign frames do not stop the drain, multi-motorpoll_until, bounded drain) and eighttest_motioncases (slow creep is not handed over, creep without contact never enters the hold, idle-bus refresh, stale-cache refusal, final-reach refresh, mid-holdCommError, abort without a fresh frame, config validation).Issues
Refs nexform-tech/litegrip-python#86
Checklist
.zh-CN.mdand open with the language switcher.Closesis used only when the pull request fully resolves the issue.