-
Notifications
You must be signed in to change notification settings - Fork 677
[wpimath] Replace Speeds with Velocities #8479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2027
Are you sure you want to change the base?
[wpimath] Replace Speeds with Velocities #8479
Conversation
|
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. |
wpilibc/src/main/native/include/wpi/hardware/led/LEDPattern.hpp
Outdated
Show resolved
Hide resolved
|
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)". |
5fb4e2b to
d7e76d1
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.
d7e76d1 to
b51ca72
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 #8423.