Skip to content

fix(foc utils): restore the FLT_MIN guard in _atan2() - #583

Open
stijncarelsbergh wants to merge 1 commit into
simplefoc:devfrom
stijncarelsbergh:fix/atan2-guard
Open

stijncarelsbergh wants to merge 1 commit into
simplefoc:devfrom
stijncarelsbergh:fix/atan2-guard

Conversation

@stijncarelsbergh

Copy link
Copy Markdown

fix(foc utils): restore the FLT_MIN guard in _atan2()

The comment says 'inject FLT_MIN in denominator to avoid division by zero' but the
term is missing (it was dropped from the ODrive original), so _atan2(0,0) is 0/0
and returns NaN instead of 0. Restores the original guard, which only affects the
degenerate (0,0) case.


Split out of #571 at your request: one fix per PR, against dev. The branch contains
nothing else, so it can be reviewed, amended or dropped on its own.

The CI board matrix runs automatically; I did not run any hardware test, so the behavioural
claims are from reading the code plus the compiler. Happy to adjust the wording, split it
differently or drop it - no attachment to this one.

The comment says 'inject FLT_MIN in denominator to avoid division by zero' but the
term is missing (it was dropped from the ODrive original), so _atan2(0,0) is 0/0
and returns NaN instead of 0. Restores the original guard, which only affects the
degenerate (0,0) case.
Copilot AI balanced review requested due to automatic review settings October 7, 2026 22:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants