mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilib] Replace unit .to<double>() with .value() (#8548)
This is consistent with the rest of the library. I left instances alone which intended a specific typecast.
This commit is contained in:
@@ -99,7 +99,7 @@ void ExpansionHubMotor::SetPercentagePower(double power) {
|
||||
|
||||
void ExpansionHubMotor::SetVoltage(wpi::units::volt_t voltage) {
|
||||
m_modePublisher.Set(kVoltageMode);
|
||||
m_setpointPublisher.Set(voltage.to<double>());
|
||||
m_setpointPublisher.Set(voltage.value());
|
||||
}
|
||||
|
||||
void ExpansionHubMotor::SetPositionSetpoint(double setpoint) {
|
||||
|
||||
@@ -76,7 +76,7 @@ void ExpansionHubServo::SetAngle(wpi::units::degree_t angle) {
|
||||
}
|
||||
|
||||
void ExpansionHubServo::SetPulseWidth(wpi::units::microsecond_t pulseWidth) {
|
||||
m_pulseWidthPublisher.Set(pulseWidth.to<double>());
|
||||
m_pulseWidthPublisher.Set(pulseWidth.value());
|
||||
}
|
||||
|
||||
void ExpansionHubServo::SetEnabled(bool enabled) {
|
||||
@@ -84,7 +84,7 @@ void ExpansionHubServo::SetEnabled(bool enabled) {
|
||||
}
|
||||
|
||||
void ExpansionHubServo::SetFramePeriod(wpi::units::microsecond_t framePeriod) {
|
||||
m_framePeriodPublisher.Set(framePeriod.to<double>());
|
||||
m_framePeriodPublisher.Set(framePeriod.value());
|
||||
}
|
||||
|
||||
wpi::units::microsecond_t ExpansionHubServo::GetFullRangeScaleFactor() {
|
||||
|
||||
@@ -148,12 +148,12 @@ void PWMMotorController::SetSpeed(double speed) {
|
||||
if (speed == 0.0) {
|
||||
rawValue = m_centerPwm;
|
||||
} else if (speed > 0.0) {
|
||||
rawValue = wpi::units::microsecond_t{static_cast<double>(std::lround(
|
||||
(speed * GetPositiveScaleFactor()).to<double>()))} +
|
||||
rawValue = wpi::units::microsecond_t{static_cast<double>(
|
||||
std::lround((speed * GetPositiveScaleFactor()).value()))} +
|
||||
GetMinPositivePwm();
|
||||
} else {
|
||||
rawValue = wpi::units::microsecond_t{static_cast<double>(std::lround(
|
||||
(speed * GetNegativeScaleFactor()).to<double>()))} +
|
||||
rawValue = wpi::units::microsecond_t{static_cast<double>(
|
||||
std::lround((speed * GetNegativeScaleFactor()).value()))} +
|
||||
GetMaxNegativePwm();
|
||||
}
|
||||
|
||||
@@ -171,10 +171,10 @@ double PWMMotorController::GetSpeed() const {
|
||||
return -1.0;
|
||||
} else if (rawValue > GetMinPositivePwm()) {
|
||||
return ((rawValue - GetMinPositivePwm()) / GetPositiveScaleFactor())
|
||||
.to<double>();
|
||||
.value();
|
||||
} else if (rawValue < GetMaxNegativePwm()) {
|
||||
return ((rawValue - GetMaxNegativePwm()) / GetNegativeScaleFactor())
|
||||
.to<double>();
|
||||
.value();
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user