Java CANJaguar changes

Change-Id: Icb15b1b140816e44caec36cda2466a64e5cabf1d

Change-Id: Idd6aebefe03acff5ab211a5e3e73a29563601515
This commit is contained in:
thomasclark
2014-06-24 11:50:10 -04:00
parent de96577602
commit 1bbf350811
11 changed files with 1707 additions and 1513 deletions

View File

@@ -11,7 +11,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import edu.wpi.first.wpilibj.can.CANTimeoutException;
import edu.wpi.first.wpilibj.can.CANMessageNotFoundException;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
@@ -19,14 +19,14 @@ public class PDPTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(PCMTest.class.getName());
/* The current returned when the motor is not being driven */
protected static final double kLowCurrent = 1.52;
protected static final double kCurrentTolerance = 0.1;
private static PowerDistributionPanel pdp;
private static Talon talon;
private static Victor victor;
private static Jaguar jaguar;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
pdp = new PowerDistributionPanel();
@@ -54,7 +54,7 @@ public class PDPTest extends AbstractComsSetup {
@After
public void tearDown() throws Exception {
}
/**
* Test if the current changes when the motor is driven using a talon
*/
@@ -62,27 +62,27 @@ public class PDPTest extends AbstractComsSetup {
public void CheckCurrentTalon() {
/* The Current should be kLowCurrent */
try {
assertEquals("The low current was not within the expected range.",
assertEquals("The low current was not within the expected range.",
kLowCurrent, pdp.getCurrent(TestBench.kTalonPDPChannel), kCurrentTolerance);
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Timer.delay(0.02);
/* Set the motor to full forward */
talon.set(1.0);
Timer.delay(0.02);
/* The current should now be greater than the low current */
try {
assertThat("The driven current is not greater than the resting current.",
assertThat("The driven current is not greater than the resting current.",
pdp.getCurrent(TestBench.kTalonPDPChannel), is(greaterThan(kLowCurrent)));
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Test if the current changes when the motor is driven using a victor
*/
@@ -90,27 +90,27 @@ public class PDPTest extends AbstractComsSetup {
public void CheckCurrentVictor() {
/* The Current should be kLowCurrent */
try {
assertEquals("The low current was not within the expected range.",
assertEquals("The low current was not within the expected range.",
kLowCurrent, pdp.getCurrent(TestBench.kVictorPDPChannel), kCurrentTolerance);
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Timer.delay(0.02);
/* Set the motor to full forward */
victor.set(1.0);
Timer.delay(0.02);
/* The current should now be greater than the low current */
try {
assertThat("The driven current is not greater than the resting current.",
assertThat("The driven current is not greater than the resting current.",
pdp.getCurrent(TestBench.kVictorPDPChannel), is(greaterThan(kLowCurrent)));
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Test if the current changes when the motor is driven using a jaguar
*/
@@ -118,23 +118,23 @@ public class PDPTest extends AbstractComsSetup {
public void CheckCurrentJaguar() {
/* The Current should be kLowCurrent */
try {
assertEquals("The low current was not within the expected range.",
assertEquals("The low current was not within the expected range.",
kLowCurrent, pdp.getCurrent(TestBench.kJaguarPDPChannel), kCurrentTolerance);
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Timer.delay(0.02);
/* Set the motor to full forward */
jaguar.set(1.0);
Timer.delay(0.02);
/* The current should now be greater than the low current */
try {
assertThat("The driven current is not greater than the resting current.",
assertThat("The driven current is not greater than the resting current.",
pdp.getCurrent(TestBench.kJaguarPDPChannel), is(greaterThan(kLowCurrent)));
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

View File

@@ -24,7 +24,7 @@ import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.can.CANTimeoutException;
import edu.wpi.first.wpilibj.can.CANMessageNotFoundException;
import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture;
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
@@ -47,7 +47,7 @@ public final class TestBench {
* completely stopped
*/
public static final double MOTOR_STOP_TIME = 0.20;
/* PowerDistributionPanel channels */
public static final int kJaguarPDPChannel = 7;
public static final int kVictorPDPChannel = 11;
@@ -164,7 +164,7 @@ public final class TestBench {
// have a free method
try {
canJag = new CANJaguar(1);
} catch (CANTimeoutException e) {
} catch (CANMessageNotFoundException e) {
e.printStackTrace();
}
}
@@ -230,14 +230,14 @@ public final class TestBench {
//NOTE: IF MORE DIOCROSSCONNECT PAIRS ARE ADDED ADD THEM HERE
return pairs;
}
public static AnalogCrossConnectFixture getAnalogCrossConnectFixture(){
AnalogCrossConnectFixture analogIO = new AnalogCrossConnectFixture() {
@Override
protected AnalogOutput giveAnalogOutput() {
return new AnalogOutput(0);
}
@Override
protected AnalogInput giveAnalogInput() {
return new AnalogInput(2);
@@ -245,20 +245,20 @@ public final class TestBench {
};
return analogIO;
}
public static RelayCrossConnectFxiture getRelayCrossConnectFixture(){
RelayCrossConnectFxiture relay = new RelayCrossConnectFxiture() {
@Override
protected Relay giveRelay() {
return new Relay(0);
}
@Override
protected DigitalInput giveInputTwo() {
return new DigitalInput(14);
}
@Override
protected DigitalInput giveInputOne() {
return new DigitalInput(15);