[wpimath] Replace Speeds with Velocities#8479
Open
calcmogul wants to merge 1 commit intowpilibsuite:2027from
Open
[wpimath] Replace Speeds with Velocities#8479calcmogul wants to merge 1 commit intowpilibsuite:2027from
calcmogul wants to merge 1 commit intowpilibsuite:2027from
Conversation
Member
|
I think the instances that refer to PWM output should be changed to something else- speed doesn't make sense, but velocity doesn't either. |
auscompgeek
reviewed
Dec 14, 2025
wpilibc/src/main/native/include/wpi/hardware/led/LEDPattern.hpp
Outdated
Show resolved
Hide resolved
Member
Author
|
This function in PWMMotorController seems to say it's a pulse time in microseconds whose range is normalized to [-1, 1]. /**
* Takes a speed from -1 to 1, and outputs it in the microsecond format.
*
* @param speed the speed to output
*/
protected final void setSpeed(double speed) {
if (Double.isFinite(speed)) {
speed = Math.clamp(speed, -1.0, 1.0);
} else {
speed = 0.0;
}
if (m_simSpeed != null) {
m_simSpeed.set(speed);
}
int rawValue;
if (speed == 0.0) {
rawValue = m_centerPwm;
} else if (speed > 0.0) {
rawValue = (int) Math.round(speed * getPositiveScaleFactor()) + getMinPositivePwm();
} else {
rawValue = (int) Math.round(speed * getNegativeScaleFactor()) + getMaxNegativePwm();
}
m_pwm.setPulseTimeMicroseconds(rawValue);
}Should it be time-related? I thought of duty cycle, but that doesn't quite make sense because it can be negative. EDIT: I went with "duty cycle between -1 and 1 (sign indicates direction)". |
d7e76d1 to
b51ca72
Compare
bhall-ctre
reviewed
Dec 18, 2025
auscompgeek
reviewed
Dec 20, 2025
wpilibcExamples/src/main/cpp/examples/FlywheelBangBangController/cpp/Robot.cpp
Outdated
Show resolved
Hide resolved
5d5e58a to
323e03b
Compare
988d1d3 to
cb31058
Compare
6813487 to
0e70180
Compare
0e70180 to
4136f67
Compare
Member
|
Some conflicts to resolve. |
a92cf1e to
408924c
Compare
I left "free speed" alone since that's the technical term for it. In general, velocity is a vector quantity, and speed is a magnitude (i.e., a strictly positive value). This PR also replaces the speed verbiage in MotorController with duty cycle. Fixes wpilibsuite#8423.
408924c to
f2e2784
Compare
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.
I left "free speed" alone since that's the technical term for it. In general, velocity is a vector quantity, and speed is a magnitude (i.e., a strictly positive value).
This PR also replaces the speed verbiage in MotorController with duty cycle.
Fixes #8423.