diff --git a/wpilibc/wpilibC++Devices/include/CANJaguar.h b/wpilibc/wpilibC++Devices/include/CANJaguar.h index fcd1cba6d7..3c065927ba 100644 --- a/wpilibc/wpilibC++Devices/include/CANJaguar.h +++ b/wpilibc/wpilibC++Devices/include/CANJaguar.h @@ -125,6 +125,7 @@ public: //SpeedController overrides virtual void SetInverted(bool isInverted) override; + virtual bool GetInverted() const override; protected: // Control mode helpers void SetSpeedReference(uint8_t reference); diff --git a/wpilibc/wpilibC++Devices/include/CANTalon.h b/wpilibc/wpilibC++Devices/include/CANTalon.h index 582d2bf728..5668c1e149 100644 --- a/wpilibc/wpilibC++Devices/include/CANTalon.h +++ b/wpilibc/wpilibC++Devices/include/CANTalon.h @@ -163,7 +163,9 @@ public: void InitTable(ITable *subTable) override; ITable * GetTable() const override; + //SpeedController overrides virtual void SetInverted(bool isInverted) override; + virtual bool GetInverted() const override; private: // Values for various modes as is sent in the CAN packets for the Talon. enum TalonControlMode { diff --git a/wpilibc/wpilibC++Devices/include/Jaguar.h b/wpilibc/wpilibC++Devices/include/Jaguar.h index 81ec13b0bd..d7f8698714 100644 --- a/wpilibc/wpilibC++Devices/include/Jaguar.h +++ b/wpilibc/wpilibC++Devices/include/Jaguar.h @@ -23,6 +23,7 @@ public: virtual void PIDWrite(float output) override; virtual void SetInverted(bool isInverted) override; + virtual bool GetInverted() const override; private: void InitJaguar(); bool m_isInverted; diff --git a/wpilibc/wpilibC++Devices/include/SpeedController.h b/wpilibc/wpilibC++Devices/include/SpeedController.h index eca4035ea4..9587a15d39 100644 --- a/wpilibc/wpilibC++Devices/include/SpeedController.h +++ b/wpilibc/wpilibC++Devices/include/SpeedController.h @@ -22,19 +22,28 @@ public: * @param syncGroup The update group to add this Set() to, pending UpdateSyncGroup(). If 0, update immediately. */ virtual void Set(float speed, uint8_t syncGroup = 0) = 0; + /** * Common interface for getting the current set speed of a speed controller. * * @return The current set speed. Value is between -1.0 and 1.0. */ virtual float Get() const = 0; + /** - * common interface for inverting direction of a speed controller - * @param isInverted The state of inversion true is inverted + * 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. */ virtual void Disable() = 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; }; diff --git a/wpilibc/wpilibC++Devices/include/Talon.h b/wpilibc/wpilibC++Devices/include/Talon.h index cee3fb7d1e..a420bedd33 100644 --- a/wpilibc/wpilibC++Devices/include/Talon.h +++ b/wpilibc/wpilibC++Devices/include/Talon.h @@ -23,6 +23,7 @@ public: virtual void PIDWrite(float output) override; virtual void SetInverted(bool isInverted) override; + virtual bool GetInverted() const override; private: void InitTalon(); bool m_isInverted; diff --git a/wpilibc/wpilibC++Devices/include/TalonSRX.h b/wpilibc/wpilibC++Devices/include/TalonSRX.h index b5a5702185..d634f832f4 100644 --- a/wpilibc/wpilibC++Devices/include/TalonSRX.h +++ b/wpilibc/wpilibC++Devices/include/TalonSRX.h @@ -24,7 +24,7 @@ public: virtual void PIDWrite(float output) override; virtual void SetInverted(bool isInverted) override; - + virtual bool GetInverted() const override; private: void InitTalonSRX(); bool m_isInverted; diff --git a/wpilibc/wpilibC++Devices/include/Victor.h b/wpilibc/wpilibC++Devices/include/Victor.h index 6016022bf5..e2ad71cfa3 100644 --- a/wpilibc/wpilibC++Devices/include/Victor.h +++ b/wpilibc/wpilibC++Devices/include/Victor.h @@ -26,7 +26,8 @@ public: virtual void PIDWrite(float output) override; - virtual void SetInverted(bool isInverted); + virtual void SetInverted(bool isInverted) override; + virtual bool GetInverted() const override; private: void InitVictor(); bool m_isInverted; diff --git a/wpilibc/wpilibC++Devices/include/VictorSP.h b/wpilibc/wpilibC++Devices/include/VictorSP.h index 21851ce933..e1f5989bec 100644 --- a/wpilibc/wpilibC++Devices/include/VictorSP.h +++ b/wpilibc/wpilibC++Devices/include/VictorSP.h @@ -23,7 +23,8 @@ public: virtual void PIDWrite(float output) override; - virtual void SetInverted(bool isInverted); + virtual void SetInverted(bool isInverted) override; + virtual bool GetInverted() const override; private: void InitVictorSP(); bool m_isInverted; diff --git a/wpilibc/wpilibC++Devices/src/CANJaguar.cpp b/wpilibc/wpilibC++Devices/src/CANJaguar.cpp index baddbcad58..6f7d3fbe37 100644 --- a/wpilibc/wpilibC++Devices/src/CANJaguar.cpp +++ b/wpilibc/wpilibC++Devices/src/CANJaguar.cpp @@ -2119,14 +2119,24 @@ void CANJaguar::StopLiveWindowMode() } /** -* common interface for inverting direction of a speed controller -* Only works in PercentVbus, speed, and Voltage modes -* @param isInverted The state of inversion true is inverted +* Common interface for inverting direction of a speed controller. +* Only works in PercentVbus, speed, and Voltage modes. +* @param isInverted The state of inversion, true is inverted */ void CANJaguar::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 CANJaguar::GetInverted() const { + return m_isInverted; +} + std::string CANJaguar::GetSmartDashboardType() const { return "Speed Controller"; diff --git a/wpilibc/wpilibC++Devices/src/CANTalon.cpp b/wpilibc/wpilibC++Devices/src/CANTalon.cpp index 3c27dfdab5..1492b34705 100644 --- a/wpilibc/wpilibC++Devices/src/CANTalon.cpp +++ b/wpilibc/wpilibC++Devices/src/CANTalon.cpp @@ -1292,14 +1292,26 @@ void CANTalon::GetDescription(char *desc) const { sprintf(desc, "CANTalon ID %d", m_deviceNumber); } + /** -* common interface for inverting direction of a speed controller -* Only works in PercentVbus, speed, and Voltage modes -* @param isInverted The state of inversion true is inverted +* Common interface for inverting direction of a speed controller. +* Only works in PercentVbus, speed, and Voltage modes. +* @param isInverted The state of inversion, true is inverted. */ void CANTalon::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 CANTalon::GetInverted() const { + return m_isInverted; +} + /** * Common interface for stopping the motor * Part of the MotorSafety interface diff --git a/wpilibc/wpilibC++Devices/src/Jaguar.cpp b/wpilibc/wpilibC++Devices/src/Jaguar.cpp index e6c29c0554..5c52bfb5b0 100644 --- a/wpilibc/wpilibC++Devices/src/Jaguar.cpp +++ b/wpilibc/wpilibC++Devices/src/Jaguar.cpp @@ -77,13 +77,25 @@ void Jaguar::Disable() { SetRaw(kPwmDisabled); } + /** -* common interface for inverting direction of a speed controller -* @param isInverted The state of inversion true is inverted +* Common interface for inverting direction of a speed controller. +* @param isInverted The state of inversion, true is inverted. */ void Jaguar::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 Jaguar::GetInverted() const { + return m_isInverted; +} + /** * Write out the PID value as seen in the PIDOutput base object. * diff --git a/wpilibc/wpilibC++Devices/src/Talon.cpp b/wpilibc/wpilibC++Devices/src/Talon.cpp index 5742741964..d1c551c32c 100644 --- a/wpilibc/wpilibC++Devices/src/Talon.cpp +++ b/wpilibc/wpilibC++Devices/src/Talon.cpp @@ -78,6 +78,7 @@ void Talon::Disable() { SetRaw(kPwmDisabled); } + /** * common interface for inverting direction of a speed controller * @param isInverted The state of inversion true is inverted @@ -85,6 +86,17 @@ void Talon::Disable() void Talon::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 Talon::GetInverted() const { + return m_isInverted; +} + /** * Write out the PID value as seen in the PIDOutput base object. * diff --git a/wpilibc/wpilibC++Devices/src/TalonSRX.cpp b/wpilibc/wpilibC++Devices/src/TalonSRX.cpp index 40494b7c83..180aaf95a6 100644 --- a/wpilibc/wpilibC++Devices/src/TalonSRX.cpp +++ b/wpilibc/wpilibC++Devices/src/TalonSRX.cpp @@ -77,13 +77,25 @@ void TalonSRX::Disable() { SetRaw(kPwmDisabled); } + /** -* common interface for inverting direction of a speed controller -* @param isInverted The state of inversion true is inverted +* Common interface for inverting direction of a speed controller. +* @param isInverted The state of inversion, true is inverted. */ void TalonSRX::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 TalonSRX::GetInverted() const { + return m_isInverted; +} + /** * Write out the PID value as seen in the PIDOutput base object. * diff --git a/wpilibc/wpilibC++Devices/src/Victor.cpp b/wpilibc/wpilibC++Devices/src/Victor.cpp index d59acbed91..997783168d 100644 --- a/wpilibc/wpilibC++Devices/src/Victor.cpp +++ b/wpilibc/wpilibC++Devices/src/Victor.cpp @@ -81,12 +81,23 @@ void Victor::Disable() SetRaw(kPwmDisabled); } /** -* common interface for inverting direction of a speed controller -* @param isInverted The state of inversion true is inverted +* Common interface for inverting direction of a speed controller. +* @param isInverted The state of inversion, true is inverted. */ void Victor::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 Victor::GetInverted() const { + return m_isInverted; +} + /** * Write out the PID value as seen in the PIDOutput base object. * diff --git a/wpilibc/wpilibC++Devices/src/VictorSP.cpp b/wpilibc/wpilibC++Devices/src/VictorSP.cpp index 8a12862a80..9d4d764ebf 100644 --- a/wpilibc/wpilibC++Devices/src/VictorSP.cpp +++ b/wpilibc/wpilibC++Devices/src/VictorSP.cpp @@ -35,7 +35,7 @@ void VictorSP::InitVictorSP() { } /** - * Constructor for a VictorSP + * Constructor for a VictorSP * @param channel The PWM channel that the VictorSP is attached to. 0-9 are on-board, 10-19 are on the MXP port */ VictorSP::VictorSP(uint32_t channel) : SafePWM(channel) @@ -70,13 +70,25 @@ float VictorSP::Get() const { return GetSpeed(); } + /** -* common interface for inverting direction of a speed controller -* @param isInverted The state of inversion true is inverted -*/ + * Common interface for inverting direction of a speed controller. + * @param isInverted The state of inversion, true is inverted. + */ void VictorSP::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 VictorSP::GetInverted() const { + return m_isInverted; +} + /** * Common interface for disabling a motor. */ diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java index 69b3d43328..66a08f7443 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANJaguar.java @@ -432,6 +432,17 @@ public class CANJaguar implements MotorSafety, PIDOutput, PIDInterface, CANSpeed this.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 this.isInverted; + } + /** * Check all unverified params and make sure they're equal to their local * cached versions. If a value isn't available, it gets requested. If a value diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java index 7b3dc5f342..0806e1eb7a 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/CANTalon.java @@ -169,15 +169,26 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, PIDInterface } /** - * Inverts the direction of the motor's rotation - * Only works in PercentVbus mode + * Inverts the direction of the motor's rotation. + * Only works in PercentVbus mode. * - * @param isInverted The state of inversion true is inverted + * @param isInverted The state of inversion, true is inverted. */ @Override public void setInverted(boolean isInverted) { this.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 this.isInverted; + } /** * Sets the output of the Talon. diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Jaguar.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Jaguar.java index 88f7805dbf..27c7405afc 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Jaguar.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Jaguar.java @@ -82,15 +82,26 @@ private boolean isInverted = false; } /** - * Common interface for inverting direction of a speed controller + * Common interface for inverting direction of a speed controller. * - * @param isInverted The state of inversion true is inverted + * @param isInverted The state of inversion, true is inverted. */ @Override public void setInverted(boolean isInverted) { this.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 this.isInverted; + } + /** * Get the recently set value of the PWM. * diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SpeedController.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SpeedController.java index 33f8053a81..51f3f04977 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SpeedController.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SpeedController.java @@ -35,11 +35,23 @@ public interface SpeedController extends PIDOutput { void set(double speed); /** - * Common interface for inverting direction of a speed controller + * Common interface for inverting direction of a speed controller. * - * @param isInverted The state of inversion true is inverted + * @param isInverted The state of inversion true is inverted. */ void setInverted(boolean isInverted); + + /** + * Common interface for returning if a speed controller + * is in the inverted state or not. + * + * @return isInverted The state of the inversion true is inverted. + * + */ + boolean getInverted(); + + + /** * Disable the speed controller */ diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Talon.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Talon.java index 377013612d..29cba2ed12 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Talon.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Talon.java @@ -89,6 +89,17 @@ private boolean isInverted = false; this.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 this.isInverted; + } + /** * Get the recently set value of the PWM. * diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/TalonSRX.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/TalonSRX.java index f082b75bd8..b083bab355 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/TalonSRX.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/TalonSRX.java @@ -81,15 +81,26 @@ public class TalonSRX extends SafePWM implements SpeedController { } /** - * Common interface for inverting direction of a speed controller + * Common interface for inverting direction of a speed controller. * - * @param isInverted The state of inversion true is inverted + * @param isInverted The state of inversion, true is inverted. */ @Override public void setInverted(boolean isInverted) { this.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 this.isInverted; + } + /** * Get the recently set value of the PWM. * diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Victor.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Victor.java index f03d0344b8..054fd254c4 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Victor.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Victor.java @@ -94,6 +94,17 @@ private boolean isInverted = false; this.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 this.isInverted; + } + /** * Get the recently set value of the PWM. * diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/VictorSP.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/VictorSP.java index 2757142aa6..b7e309fab2 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/VictorSP.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/VictorSP.java @@ -89,6 +89,17 @@ private boolean isInverted = false; this.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 this.isInverted; + } + /** * Get the recently set value of the PWM. * diff --git a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java index d699b2b628..2b60466bb3 100644 --- a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java +++ b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java @@ -33,6 +33,7 @@ public class MotorInvertingTest extends AbstractComsSetup { fixture = afixture; fixture.setup(); } + @Parameterized.Parameters(name= "{index}: {0}") public static Collection[]> generateData(){ //logger.fine("Loading the MotorList"); @@ -42,11 +43,14 @@ public class MotorInvertingTest extends AbstractComsSetup { {TestBench.getInstance().getJaguarPair()} }); } + private static final Logger logger = Logger.getLogger(MotorInvertingTest.class.getName()); + @Override protected Logger getClassLogger(){ return logger; } + @Before public void setUp() { // Reset the fixture elements before every test @@ -59,8 +63,9 @@ public class MotorInvertingTest extends AbstractComsSetup { // Clean up the fixture after the test fixture.teardown(); } + @Test - public void testInvertingPositive(){ + public void testInvertingPositive(){ fixture.getMotor().setInverted(false); fixture.getMotor().set(motorspeed); Timer.delay(delaytime); @@ -71,6 +76,7 @@ public class MotorInvertingTest extends AbstractComsSetup { assertFalse("Inverting with Positive value does not change direction",fixture.getEncoder().getDirection()==initDirection); fixture.getMotor().set(0); } + @Test public void testInvertingNegative(){ fixture.getMotor().setInverted(false); @@ -83,6 +89,7 @@ public class MotorInvertingTest extends AbstractComsSetup { assertFalse("Inverting with Negative value does not change direction",fixture.getEncoder().getDirection()==initDirection); fixture.getMotor().set(0); } + @Test public void testInvertingSwitchingPosToNeg(){ fixture.getMotor().setInverted(false); @@ -95,6 +102,7 @@ public class MotorInvertingTest extends AbstractComsSetup { assertTrue("Inverting with Switching value does change direction", fixture.getEncoder().getDirection() == initDirection); fixture.getMotor().set(0); } + @Test public void testInvertingSwitchingNegToPos(){ fixture.getMotor().setInverted(false); diff --git a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java index b55ce5ddf7..8df03a4c87 100644 --- a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java +++ b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java @@ -28,7 +28,7 @@ import edu.wpi.first.wpilibj.test.AbstractTestSuite; EncoderTest.class, GyroTest.class, MotorEncoderTest.class, - MotorInvertingTest.class, + MotorInvertingTest.class, PCMTest.class, PDPTest.class, PIDTest.class,