Update LiveWindow to provide continuous telemetry. (#771)

LiveWindow.updateValues() is now called from IterativeRobotBase on every
loop iteration.  Telemetry for all WPILib classes is enabled by default;
it can be disabled for specific classes using LiveWindow.disableTelemetry(),
or all telemetry can be disabled using LiveWindow.disableAllTelemetry().

This necessitated changing the hook methodology into other classes to
be more property-based rather than each class providing multiple functions.
This had the benefit of reducing boilerplate and increasing consistency.

- Remove NamedSendable, add name to Sendable.

- Provide SendableBase abstract class.

- Deprecate LiveWindow addSensor/addActuator interfaces.

- Add LiveWindow support to drive classes.

- Add addChild() helper functions to Subsystem.

- Fix inheritance hierarchy.  Now only sensors inherit from SensorBase.
  Other devices inherit from some combination of SendableBase, ErrorBase, or
  nothing.
This commit is contained in:
Peter Johnson
2017-12-04 23:28:33 -08:00
committed by GitHub
parent 3befc7015b
commit f9bece2ffb
213 changed files with 3704 additions and 3758 deletions

View File

@@ -24,6 +24,7 @@ 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.smartdashboard.SendableBuilderImpl;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
@@ -43,6 +44,7 @@ import static org.junit.Assert.assertTrue;
public class PIDTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(PIDTest.class.getName());
private NetworkTable m_table;
private SendableBuilderImpl m_builder;
private static final double absoluteTolerance = 50;
private static final double outputRange = 0.25;
@@ -104,8 +106,10 @@ public class PIDTest extends AbstractComsSetup {
logger.fine("Setup: " + me.getType());
me.setup();
m_table = NetworkTableInstance.getDefault().getTable("TEST_PID");
m_builder = new SendableBuilderImpl();
m_builder.setTable(m_table);
m_controller = new PIDController(k_p, k_i, k_d, me.getEncoder(), me.getMotor());
m_controller.initTable(m_table);
m_controller.initSendable(m_builder);
}
@After
@@ -134,6 +138,7 @@ 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);
m_builder.updateTable();
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);
@@ -148,11 +153,12 @@ public class PIDTest extends AbstractComsSetup {
double setpoint = 2500.0;
m_controller.setSetpoint(setpoint);
m_controller.enable();
Timer.delay(.5);
m_builder.updateTable();
assertTrue(m_table.getEntry("enabled").getBoolean(false));
assertTrue(m_controller.isEnabled());
assertThat(0.0, is(not(me.getMotor().get())));
m_controller.reset();
m_builder.updateTable();
assertFalse(m_table.getEntry("enabled").getBoolean(true));
assertFalse(m_controller.isEnabled());
assertEquals(0, me.getMotor().get(), 0);