fix(dm_driver): start control loop when start_thread=True#59
Closed
nu-jliu wants to merge 2 commits into
Closed
Conversation
- i2rt/motor_drivers/dm_driver.py: initialize start_thread_flag to False in DMChainCanInterface.__init__ instead of to the start_thread argument. Setting it to True before calling start_thread() made the guard `if self.start_thread_flag: return` short-circuit, so the 250 Hz control loop never spawned on the default start_thread=True path. The failure was silent: _motor_on() already set self.state and self.running, so there was no exception or hang -- set_commands() was never flushed and read_states() returned a stale snapshot. - i2rt/motor_drivers/tests/test_dm_driver.py: add a hardware-free regression matrix (CAN + _motor_on mocked) covering every call pattern -- start_thread True/False crossed with the number of explicit start_thread() calls -- asserting the loop thread spawns exactly once where requested, stays idempotent under repeated calls, and never spawns when the caller opts out. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
if self.start_thread_flag: returnshort-circuit, so the 250 Hz control loop never spawned on the default start_thread=True path. The failure was silent: _motor_on() already set self.state and self.running, so there was no exception or hang -- set_commands() was never flushed and read_states() returned a stale snapshot.