Added tests for motor inversions.

This commit squashes all of Patrick's eleven commits into one
so that things are a bit more sane. The original commit messages
and change ids (for gerrit) can be found below.

Testing Motor Inversion Feature (Java tests only so far)

Change-Id: I44cd9b5a3fe066e1071316831dde14bff5ec3bd9

Test 2 of java testing for Motor Inverting

Change-Id: I96cc0534bb1d28a70d10c582f0b40ea3a2d83cab

Added another test to try to track down issue with InvertingMotor jaguar and Talon

Change-Id: I9b5292315c93ec0d568d53a6bcdac5b998a6d857

More Testing on the Inverting motors with jaguars and talons.

Change-Id: I896210a54903e3c0af68e8c41360c165cf9c3122

Added C++ integration Tests for the motor inversion.

Change-Id: I81af5d4aab78d755340d99608b838046bf7ddda1

C++ tests for Motor Inversion now without crashing

Change-Id: Ifdecdbfc1aeb18aafb2b4c63709b27636074a274

More testing of inverted motors (now with c++ tests)
Talon seems not to be working on test rig
Also added a CANJaguartest file in java since was missing
Currently porting the CANJaguar tests from c++ to java

Change-Id: Ib578d6ee1256ac31ddf20603aa6f24adde08065b

Another attempt at adding java tests for can jaguar inversion.

Change-Id: I971a886a4e555ada5bd15a814094da2a1eb5c8e1

Minor changes and attempt to rerun tests after yesterday's jenkins crash.

Change-Id: I7ed0904d4243499c3246e9c39e5493d0d9c962c5

All motor inversion tests should be working now. Talon on the test rig has been fixed.

Change-Id: I20bd6d7486b758ce1ce47ac799150475b3152b6f

Updated Inversion tests again. Should work this time. (worked on the test rig prior)

Change-Id: Ifdf222d5e5733fe802f29e7d939b72e84972e8da

Added tests for motor inversions.

This commit squashes all of Patrick's eleven commits into one
so that things are a bit more sane. The original commit messages
and change ids (for gerrit) can be found below.

Testing Motor Inversion Feature (Java tests only so far)

Change-Id: I44cd9b5a3fe066e1071316831dde14bff5ec3bd9

Test 2 of java testing for Motor Inverting

Change-Id: I96cc0534bb1d28a70d10c582f0b40ea3a2d83cab

Added another test to try to track down issue with InvertingMotor jaguar and Talon

Change-Id: I9b5292315c93ec0d568d53a6bcdac5b998a6d857

More Testing on the Inverting motors with jaguars and talons.

Change-Id: I896210a54903e3c0af68e8c41360c165cf9c3122

Added C++ integration Tests for the motor inversion.

Change-Id: I81af5d4aab78d755340d99608b838046bf7ddda1

C++ tests for Motor Inversion now without crashing

Change-Id: Ifdecdbfc1aeb18aafb2b4c63709b27636074a274

More testing of inverted motors (now with c++ tests)
Talon seems not to be working on test rig
Also added a CANJaguartest file in java since was missing
Currently porting the CANJaguar tests from c++ to java

Change-Id: Ib578d6ee1256ac31ddf20603aa6f24adde08065b

Another attempt at adding java tests for can jaguar inversion.

Change-Id: I971a886a4e555ada5bd15a814094da2a1eb5c8e1

Minor changes and attempt to rerun tests after yesterday's jenkins crash.

Change-Id: I7ed0904d4243499c3246e9c39e5493d0d9c962c5

All motor inversion tests should be working now. Talon on the test rig has been fixed.

Change-Id: I20bd6d7486b758ce1ce47ac799150475b3152b6f

Updated Inversion tests again. Should work this time. (worked on the test rig prior)

Change-Id: Ifdf222d5e5733fe802f29e7d939b72e84972e8da
This commit is contained in:
Patrick
2015-03-24 15:01:17 -04:00
committed by James Kuszmaul
parent 2d71c1c1c7
commit 0122086d23
34 changed files with 593 additions and 116 deletions

View File

@@ -177,10 +177,10 @@ public class MotorEncoderTest extends AbstractComsSetup {
pid.setSetpoint(2500);
pid.enable();
Timer.delay(5.0);
Timer.delay(10.0);
pid.disable();
assertTrue("PID loop did not reach setpoint within 5 seconds. The error was: " + pid.getError(),
assertTrue("PID loop did not reach setpoint within 10 seconds. The error was: " + pid.getError(),
pid.onTarget());
pid.free();

View File

@@ -0,0 +1,110 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
/**
* Tests Inversion of motors using the SpeedController setInverted
*/
@RunWith(Parameterized.class)
public class MotorInvertingTest extends AbstractComsSetup {
static MotorEncoderFixture<?> fixture = null;
private static final double motorspeed = 0.35;
private static final double delaytime = 0.3;
public MotorInvertingTest(MotorEncoderFixture<?> afixture){
logger.fine("Constructor with: " + afixture.getType());
if(fixture != null && !fixture.equals(afixture)) fixture.teardown();
fixture = afixture;
fixture.setup();
}
@Parameterized.Parameters(name= "{index}: {0}")
public static Collection<MotorEncoderFixture<?>[]> generateData(){
//logger.fine("Loading the MotorList");
return Arrays.asList(new MotorEncoderFixture<?>[][]{
{TestBench.getInstance().getTalonPair()},
{TestBench.getInstance().getVictorPair()},
{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
fixture.reset();
}
@AfterClass
public static void tearDown() {
fixture.getMotor().setInverted(false);
// Clean up the fixture after the test
fixture.teardown();
}
@Test
public void testInvertingPositive(){
fixture.getMotor().setInverted(false);
fixture.getMotor().set(motorspeed);
Timer.delay(delaytime);
boolean initDirection = fixture.getEncoder().getDirection();
fixture.getMotor().setInverted(true);
fixture.getMotor().set(motorspeed);
Timer.delay(delaytime);
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);
fixture.getMotor().set(-motorspeed);
Timer.delay(delaytime);
boolean initDirection = fixture.getEncoder().getDirection();
fixture.getMotor().setInverted(true);
fixture.getMotor().set(-motorspeed);
Timer.delay(delaytime);
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);
fixture.getMotor().set(motorspeed);
Timer.delay(delaytime);
boolean initDirection = fixture.getEncoder().getDirection();
fixture.getMotor().setInverted(true);
fixture.getMotor().set(-motorspeed);
Timer.delay(delaytime);
assertTrue("Inverting with Switching value does change direction", fixture.getEncoder().getDirection() == initDirection);
fixture.getMotor().set(0);
}
@Test
public void testInvertingSwitchingNegToPos(){
fixture.getMotor().setInverted(false);
fixture.getMotor().set(-motorspeed);
Timer.delay(delaytime);
boolean initDirection = fixture.getEncoder().getDirection();
fixture.getMotor().setInverted(true);
fixture.getMotor().set(motorspeed);
Timer.delay(delaytime);
assertTrue("Inverting with Switching value does change direction", fixture.getEncoder().getDirection() == initDirection);
fixture.getMotor().set(0);
}
}

View File

@@ -28,6 +28,7 @@ import edu.wpi.first.wpilibj.test.AbstractTestSuite;
EncoderTest.class,
GyroTest.class,
MotorEncoderTest.class,
MotorInvertingTest.class,
PCMTest.class,
PDPTest.class,
PIDTest.class,

View File

@@ -0,0 +1,75 @@
package edu.wpi.first.wpilibj.can;
import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.Timer;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import java.util.logging.Logger;
/**
* Created by Patrick Murphy on 3/30/15.
*/
public class CANJaguarInversionTest extends AbstractCANTest{
private static final Logger logger = Logger.getLogger(CANJaguarInversionTest.class.getName());
private static final double motorVoltage = 5.0;
private static final double motorPercent = 0.5;
private static final double motorSpeed = 100;
private static final double delayTime = 0.75;
private static final double speedModeDelayTime = 2.0;
@Override
protected Logger getClassLogger() {
return logger;
}
@Test
public void testInvertingVoltageMode(){
getME().getMotor().setVoltageMode(CANJaguar.kQuadEncoder, 360);
InversionTest(motorVoltage, delayTime);
}
@Test
public void testInvertingPercentMode(){
getME().getMotor().setPercentMode(CANJaguar.kQuadEncoder, 360);
InversionTest(motorPercent, delayTime);
}
@Test
public void testInvertingSpeedMode(){
getME().getMotor().setSpeedMode(CANJaguar.kQuadEncoder, 360, 0.1, 0.003, 0.01);
InversionTest(motorSpeed, speedModeDelayTime);
}
/**
* Runs an inversion test
* To use set the jaguar to the proper mode(PercentVbus, voltage, speed)
* @param setpoint the speed/voltage/percent to set the motor to
* @param delayTime the amount of time to delay between starting a motor and checking the encoder
*/
private void InversionTest(double setpoint, double delayTime) {
CANJaguar jag = this.getME().getMotor();
jag.enableControl();
jag.setInverted(false);
jag.set(setpoint);
Timer.delay(delayTime);
double initialSpeed = jag.getSpeed();
jag.set(0.0);
jag.setInverted(true);
jag.set(setpoint);
Timer.delay(delayTime);
jag.set(0.0);
double finalSpeed = jag.getSpeed();
assertTrue("Inverting with Positive value does not invert direction",
Math.signum(initialSpeed)!=
Math.signum(finalSpeed)
);
jag.set(-setpoint);
Timer.delay(delayTime);
initialSpeed = jag.getSpeed();
jag.set(0.0);
jag.setInverted(false);
jag.set(-setpoint);
Timer.delay(delayTime);
finalSpeed = jag.getSpeed();
jag.set(0.0);
assertTrue("Inverting with Negative value does not invert direction",
Math.signum(initialSpeed)!=
Math.signum(finalSpeed)
);
}
}

View File

@@ -19,6 +19,7 @@ import edu.wpi.first.wpilibj.test.AbstractTestSuite;
@RunWith(Suite.class)
@SuiteClasses({ CANCurrentQuadEncoderModeTest.class,
CANDefaultTest.class,
CANJaguarInversionTest.class,
CANPercentQuadEncoderModeTest.class,
CANPositionPotentiometerModeTest.class,
CANPositionQuadEncoderModeTest.class,

View File

@@ -124,7 +124,7 @@ public abstract class MotorEncoderFixture <T extends SpeedController> implements
* Checks to see if the speed of the motor is within some range of a given value.
* This is used instead of equals() because doubles can have inaccuracies.
* @param value The value to compare against
* @param acuracy The accuracy range to check against to see if the
* @param accuracy The accuracy range to check against to see if the
* @return true if the range of values between motors speed accuracy contains the 'value'.
*/
public boolean isMotorSpeedWithinRange(double value, double accuracy){
@@ -136,7 +136,7 @@ public abstract class MotorEncoderFixture <T extends SpeedController> implements
public boolean reset(){
initialize();
boolean wasReset = true;
motor.setInverted(false);
motor.set(0);
Timer.delay(TestBench.MOTOR_STOP_TIME); //DEFINED IN THE TestBench
encoder.reset();