mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
Made SpeedController class organization consistent between languages (#568)
This commit is contained in:
committed by
Peter Johnson
parent
97437ee58b
commit
822ea6abc8
@@ -20,14 +20,13 @@ class PWMSpeedController : public SafePWM, public SpeedController {
|
||||
virtual ~PWMSpeedController() = default;
|
||||
void Set(double value) override;
|
||||
double Get() const override;
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
void Disable() override;
|
||||
void StopMotor() override;
|
||||
|
||||
void PIDWrite(double output) override;
|
||||
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
|
||||
protected:
|
||||
explicit PWMSpeedController(int channel);
|
||||
|
||||
|
||||
@@ -36,36 +36,19 @@ void PWMSpeedController::Set(double speed) {
|
||||
*/
|
||||
double PWMSpeedController::Get() const { return GetSpeed(); }
|
||||
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
*/
|
||||
void PWMSpeedController::Disable() { SetDisabled(); }
|
||||
|
||||
/**
|
||||
* Common interface for inverting direction of a speed controller.
|
||||
*
|
||||
* @param isInverted The state of inversion, true is inverted.
|
||||
*/
|
||||
void PWMSpeedController::SetInverted(bool isInverted) {
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common interface for the inverting direction of a speed controller.
|
||||
*
|
||||
* @return isInverted The state of inversion, true is inverted.
|
||||
*
|
||||
*/
|
||||
bool PWMSpeedController::GetInverted() const { return m_isInverted; }
|
||||
|
||||
void PWMSpeedController::Disable() { SetDisabled(); }
|
||||
|
||||
void PWMSpeedController::StopMotor() { SafePWM::StopMotor(); }
|
||||
|
||||
/**
|
||||
* Write out the PID value as seen in the PIDOutput base object.
|
||||
*
|
||||
* @param output Write out the PWM value as was found in the PIDController
|
||||
*/
|
||||
void PWMSpeedController::PIDWrite(double output) { Set(output); }
|
||||
|
||||
/**
|
||||
* Common interface to stop the motor until Set is called again.
|
||||
*/
|
||||
void PWMSpeedController::StopMotor() { this->SafePWM::StopMotor(); }
|
||||
|
||||
@@ -32,22 +32,24 @@ class SpeedController : public PIDOutput {
|
||||
virtual double Get() const = 0;
|
||||
|
||||
/**
|
||||
* Common interface for inverting direction of a speed controller.
|
||||
* @param isInverted The state of inversion, true is inverted.
|
||||
*/
|
||||
virtual void SetInverted(bool isInverted) = 0;
|
||||
/**
|
||||
|
||||
* Common interface for disabling a motor.
|
||||
* Common interface for inverting direction of a speed controller.
|
||||
*
|
||||
* @param isInverted The state of inversion, true is inverted.
|
||||
*/
|
||||
virtual void Disable() = 0;
|
||||
virtual void SetInverted(bool isInverted) = 0;
|
||||
|
||||
/**
|
||||
* Common interface for returning the inversion state of a speed controller.
|
||||
*
|
||||
* @return isInverted The state of inversion, true is inverted.
|
||||
*/
|
||||
virtual bool GetInverted() const = 0;
|
||||
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
*/
|
||||
virtual void Disable() = 0;
|
||||
|
||||
/**
|
||||
* Common interface to stop the motor until Set is called again.
|
||||
*/
|
||||
@@ -37,26 +37,6 @@ public abstract class PWMSpeedController extends SafePWM implements SpeedControl
|
||||
feed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Common interface for inverting direction of a speed controller.
|
||||
*
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
@Override
|
||||
public void setInverted(boolean isInverted) {
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common interface for the inverting direction of a speed controller.
|
||||
*
|
||||
* @return isInverted The state of inversion, true is inverted.
|
||||
*/
|
||||
@Override
|
||||
public boolean getInverted() {
|
||||
return m_isInverted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the recently set value of the PWM.
|
||||
*
|
||||
@@ -67,6 +47,16 @@ public abstract class PWMSpeedController extends SafePWM implements SpeedControl
|
||||
return getSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean isInverted) {
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getInverted() {
|
||||
return m_isInverted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out the PID value as seen in the PIDOutput base object.
|
||||
*
|
||||
|
||||
@@ -11,6 +11,12 @@ package edu.wpi.first.wpilibj;
|
||||
* Interface for speed controlling devices.
|
||||
*/
|
||||
public interface SpeedController extends PIDOutput {
|
||||
/**
|
||||
* Common interface for setting the speed of a speed controller.
|
||||
*
|
||||
* @param speed The speed to set. Value should be between -1.0 and 1.0.
|
||||
*/
|
||||
void set(double speed);
|
||||
|
||||
/**
|
||||
* Common interface for getting the current set speed of a speed controller.
|
||||
@@ -19,13 +25,6 @@ public interface SpeedController extends PIDOutput {
|
||||
*/
|
||||
double get();
|
||||
|
||||
/**
|
||||
* Common interface for setting the speed of a speed controller.
|
||||
*
|
||||
* @param speed The speed to set. Value should be between -1.0 and 1.0.
|
||||
*/
|
||||
void set(double speed);
|
||||
|
||||
/**
|
||||
* Common interface for inverting direction of a speed controller.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user