mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update wpilibj to use new NetworkTables package and interfaces.
This may be breaking to CANSpeedController implementations.
This commit is contained in:
@@ -21,8 +21,9 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTable;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
|
||||
@@ -102,7 +103,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
public void setUp() throws Exception {
|
||||
logger.fine("Setup: " + me.getType());
|
||||
me.setup();
|
||||
m_table = NetworkTable.getTable("TEST_PID");
|
||||
m_table = NetworkTableInstance.getDefault().getTable("TEST_PID");
|
||||
m_controller = new PIDController(k_p, k_i, k_d, me.getEncoder(), me.getMotor());
|
||||
m_controller.initTable(m_table);
|
||||
}
|
||||
@@ -133,11 +134,11 @@ public class PIDTest extends AbstractComsSetup {
|
||||
assertFalse("PID did not begin disabled", m_controller.isEnabled());
|
||||
assertEquals("PID.getError() did not start at " + setpoint, setpoint,
|
||||
m_controller.getError(), 0);
|
||||
assertEquals(k_p, m_table.getNumber("p", 9999999), 0);
|
||||
assertEquals(k_i, m_table.getNumber("i", 9999999), 0);
|
||||
assertEquals(k_d, m_table.getNumber("d", 9999999), 0);
|
||||
assertEquals(setpoint, m_table.getNumber("setpoint", 9999999), 0);
|
||||
assertFalse(m_table.getBoolean("enabled", true));
|
||||
assertEquals(k_p, m_table.getEntry("p").getDouble(9999999), 0);
|
||||
assertEquals(k_i, m_table.getEntry("i").getDouble(9999999), 0);
|
||||
assertEquals(k_d, m_table.getEntry("d").getDouble(9999999), 0);
|
||||
assertEquals(setpoint, m_table.getEntry("setpoint").getDouble(9999999), 0);
|
||||
assertFalse(m_table.getEntry("enabled").getBoolean(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,11 +149,11 @@ public class PIDTest extends AbstractComsSetup {
|
||||
m_controller.setSetpoint(setpoint);
|
||||
m_controller.enable();
|
||||
Timer.delay(.5);
|
||||
assertTrue(m_table.getBoolean("enabled", false));
|
||||
assertTrue(m_table.getEntry("enabled").getBoolean(false));
|
||||
assertTrue(m_controller.isEnabled());
|
||||
assertThat(0.0, is(not(me.getMotor().get())));
|
||||
m_controller.reset();
|
||||
assertFalse(m_table.getBoolean("enabled", true));
|
||||
assertFalse(m_table.getEntry("enabled").getBoolean(true));
|
||||
assertFalse(m_controller.isEnabled());
|
||||
assertEquals(0, me.getMotor().get(), 0);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ import org.junit.Test;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.wpilibj.Relay.Direction;
|
||||
import edu.wpi.first.wpilibj.Relay.InvalidValueException;
|
||||
import edu.wpi.first.wpilibj.Relay.Value;
|
||||
import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture;
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTable;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
|
||||
@@ -30,7 +31,8 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
private static final Logger logger = Logger.getLogger(RelayCrossConnectTest.class.getName());
|
||||
private static final NetworkTable table = NetworkTable.getTable("_RELAY_CROSS_CONNECT_TEST_");
|
||||
private static final NetworkTable table =
|
||||
NetworkTableInstance.getDefault().getTable("_RELAY_CROSS_CONNECT_TEST_");
|
||||
private RelayCrossConnectFixture m_relayFixture;
|
||||
|
||||
|
||||
@@ -57,7 +59,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
assertTrue("Input two was not high when relay set both high", m_relayFixture.getInputTwo()
|
||||
.get());
|
||||
assertEquals(Value.kOn, m_relayFixture.getRelay().get());
|
||||
assertEquals("On", table.getString("Value", ""));
|
||||
assertEquals("On", table.getEntry("Value").getString(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +73,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
.getInputTwo()
|
||||
.get());
|
||||
assertEquals(Value.kForward, m_relayFixture.getRelay().get());
|
||||
assertEquals("Forward", table.getString("Value", ""));
|
||||
assertEquals("Forward", table.getEntry("Value").getString(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,7 +87,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
.getInputTwo()
|
||||
.get());
|
||||
assertEquals(Value.kReverse, m_relayFixture.getRelay().get());
|
||||
assertEquals("Reverse", table.getString("Value", ""));
|
||||
assertEquals("Reverse", table.getEntry("Value").getString(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +100,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
assertTrue("Input two was not high when relay set Value.kOn in kForward Direction",
|
||||
m_relayFixture.getInputTwo().get());
|
||||
assertEquals(Value.kOn, m_relayFixture.getRelay().get());
|
||||
assertEquals("On", table.getString("Value", ""));
|
||||
assertEquals("On", table.getEntry("Value").getString(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,7 +113,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
assertFalse("Input two was not low when relay set Value.kOn in kReverse Direction",
|
||||
m_relayFixture.getInputTwo().get());
|
||||
assertEquals(Value.kOn, m_relayFixture.getRelay().get());
|
||||
assertEquals("On", table.getString("Value", ""));
|
||||
assertEquals("On", table.getEntry("Value").getString(""));
|
||||
}
|
||||
|
||||
@Test(expected = InvalidValueException.class)
|
||||
@@ -132,7 +134,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
// Initially both outputs should be off
|
||||
assertFalse(m_relayFixture.getInputOne().get());
|
||||
assertFalse(m_relayFixture.getInputTwo().get());
|
||||
assertEquals("Off", table.getString("Value", ""));
|
||||
assertEquals("Off", table.getEntry("Value").getString(""));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user