Model motor torque across wheel speed - #1509
Closed
Zw96042 wants to merge 6 commits into
Closed
Conversation
Zw96042
marked this pull request as ready for review
August 12, 2026 20:22
Collaborator
|
We're going to keep working on the other PR, which has actual physical testing behind it. |
Author
|
Thanks. That makes sense. I couldn’t find the physical testing procedure or logged results in #1475 or #1245. The constraint in #1509 is derived directly from the DC motor equations |
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
Why
Choreo currently treats maximum wheel speed and maximum wheel torque as independent constraints. A real DC motor cannot produce its zero-speed torque at every speed: back-EMF reduces the available propulsive torque as wheel speed rises.
This is a focused replacement for #1475, which has been inactive since May 31 and now conflicts with
main. The underlying issue in #1245 remains unresolved, so this PR keeps the change centered on the torque-speed constraint and implements it for both drivetrain types.The blue REV torque curve demonstrates the behavior this PR adds: available torque decreases toward zero as the motor approaches free speed. Choreo reconstructs that ideal line from stall torque and free speed, then intersects it with the independently configured current-limited maximum torque. The power and efficiency curves are shown for context but are not modeled as separate constraints here. Source: REV Robotics NEO Vortex documentation.
Model
For each differential wheel, the normalized terminal voltage is
and is bounded to
[-1, 1]. This gives the usual linear torque-speed curve in forward and reverse while retaining the correct braking quadrants. The existing current and traction constraints remain in force, so this does not attempt to model battery sag, supply-current limits, or regenerative-energy acceptance.Swerve uses the corresponding smooth two-dimensional voltage-vector constraint. Choreo does not optimize an explicit module azimuth or traction axis, so this is an isotropic surrogate: it is exact when module force and velocity are collinear and conservative for lateral force. The formulation is rotationally invariant and matches the optimizer's existing isotropic module force model.
Compatibility
.chorand.trajfiles migrate with the curve disabled, avoiding a silent change to regenerated trajectories.Verification
cargo test --workspacecargo clippy --workspace -- -D warningsctest(31/31)Closes #1245
Supersedes #1475