mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilib] Move motor controllers to motorcontrol package (#3302)
Also deprecate SpeedController in favor of motorcontrol.MotorController and SpeedControllerGroup in favor of motorcontrol.MotorControllerGroup. The MotorController interface is derived from the SpeedController interface so that code such as SpeedController x = new VictorSP(1) continues to compile (just with a warning). SpeedControllerGroup and MotorControllerGroup are independent classes; both implement the MotorController interface.
This commit is contained in:
@@ -20,7 +20,7 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
/** Tests Inversion of motors using the SpeedController setInverted. */
|
||||
/** Tests Inversion of motors using the MotorController setInverted. */
|
||||
@RunWith(Parameterized.class)
|
||||
public class MotorInvertingTest extends AbstractComsSetup {
|
||||
static MotorEncoderFixture<?> fixture = null;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PDPTest extends AbstractComsSetup {
|
||||
|
||||
/** Test if the current changes when the motor is driven using a talon. */
|
||||
@Test
|
||||
public void checkStoppedCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
public void checkStoppedCurrentForMotorController() throws CANMessageNotFoundException {
|
||||
Timer.delay(0.25);
|
||||
|
||||
/* The Current should be 0 */
|
||||
@@ -83,7 +83,7 @@ public class PDPTest extends AbstractComsSetup {
|
||||
|
||||
/** Test if the current changes when the motor is driven using a talon. */
|
||||
@Test
|
||||
public void checkRunningCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
public void checkRunningCurrentForMotorController() throws CANMessageNotFoundException {
|
||||
/* Set the motor to full forward */
|
||||
me.getMotor().set(1.0);
|
||||
Timer.delay(2);
|
||||
|
||||
@@ -8,8 +8,8 @@ import edu.wpi.first.wpilibj.Counter;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
import edu.wpi.first.wpilibj.PWM;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.MotorController;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.logging.Logger;
|
||||
@@ -22,7 +22,7 @@ import java.util.logging.Logger;
|
||||
* fixture. This allows tests to be mailable so that you can easily reconfigure the physical testbed
|
||||
* without breaking the tests.
|
||||
*/
|
||||
public abstract class MotorEncoderFixture<T extends SpeedController> implements ITestFixture {
|
||||
public abstract class MotorEncoderFixture<T extends MotorController> implements ITestFixture {
|
||||
private static final Logger logger = Logger.getLogger(MotorEncoderFixture.class.getName());
|
||||
private boolean m_initialized = false;
|
||||
private boolean m_tornDown = false;
|
||||
@@ -39,12 +39,12 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
|
||||
/**
|
||||
* Where the implementer of this class should pass the speed controller Constructor should only be
|
||||
* called from outside this class if the Speed controller is not also an implementation of PWM
|
||||
* called from outside this class if the Motor controller is not also an implementation of PWM
|
||||
* interface.
|
||||
*
|
||||
* @return SpeedController
|
||||
* @return MotorController
|
||||
*/
|
||||
protected abstract T giveSpeedController();
|
||||
protected abstract T giveMotorController();
|
||||
|
||||
/**
|
||||
* Where the implementer of this class should pass one of the digital inputs.
|
||||
@@ -76,7 +76,7 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
m_counters[0] = new Counter(m_alphaSource);
|
||||
m_counters[1] = new Counter(m_betaSource);
|
||||
logger.fine("Creating the speed controller!");
|
||||
m_motor = giveSpeedController();
|
||||
m_motor = giveMotorController();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
package edu.wpi.first.wpilibj.motorcontrol;
|
||||
|
||||
public class MockSpeedController implements SpeedController {
|
||||
public class MockMotorController implements MotorController {
|
||||
private double m_speed;
|
||||
private boolean m_isInverted;
|
||||
|
||||
@@ -8,16 +8,16 @@ import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.AnalogOutput;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Jaguar;
|
||||
import edu.wpi.first.wpilibj.Relay;
|
||||
import edu.wpi.first.wpilibj.Servo;
|
||||
import edu.wpi.first.wpilibj.Talon;
|
||||
import edu.wpi.first.wpilibj.Victor;
|
||||
import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
|
||||
import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture;
|
||||
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
|
||||
import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture;
|
||||
import edu.wpi.first.wpilibj.fixtures.TiltPanCameraFixture;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Jaguar;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Talon;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Victor;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -74,7 +74,7 @@ public final class TestBench {
|
||||
public MotorEncoderFixture<Talon> getTalonPair() {
|
||||
return new MotorEncoderFixture<Talon>() {
|
||||
@Override
|
||||
protected Talon giveSpeedController() {
|
||||
protected Talon giveMotorController() {
|
||||
return new Talon(kTalonChannel);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public final class TestBench {
|
||||
public MotorEncoderFixture<Victor> getVictorPair() {
|
||||
return new MotorEncoderFixture<Victor>() {
|
||||
@Override
|
||||
protected Victor giveSpeedController() {
|
||||
protected Victor giveMotorController() {
|
||||
return new Victor(kVictorChannel);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class TestBench {
|
||||
public MotorEncoderFixture<Jaguar> getJaguarPair() {
|
||||
return new MotorEncoderFixture<Jaguar>() {
|
||||
@Override
|
||||
protected Jaguar giveSpeedController() {
|
||||
protected Jaguar giveMotorController() {
|
||||
return new Jaguar(kJaguarChannel);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user