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

@@ -10,7 +10,7 @@
#include <HAL/Accelerometer.h>
#include <HAL/HAL.h>
#include "LiveWindow/LiveWindow.h"
#include "SmartDashboard/SendableBuilder.h"
#include "WPIErrors.h"
using namespace frc;
@@ -25,7 +25,7 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
HAL_Report(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
"Built-in accelerometer");
LiveWindow::GetInstance()->AddSensor((std::string) "BuiltInAccel", 0, this);
SetName("BuiltInAccel", 0);
}
void BuiltInAccelerometer::SetRange(Range range) {
@@ -54,26 +54,9 @@ double BuiltInAccelerometer::GetY() { return HAL_GetAccelerometerY(); }
*/
double BuiltInAccelerometer::GetZ() { return HAL_GetAccelerometerZ(); }
std::string BuiltInAccelerometer::GetSmartDashboardType() const {
return "3AxisAccelerometer";
}
void BuiltInAccelerometer::InitTable(
std::shared_ptr<nt::NetworkTable> subtable) {
if (subtable != nullptr) {
m_xEntry = subtable->GetEntry("X");
m_yEntry = subtable->GetEntry("Y");
m_zEntry = subtable->GetEntry("Z");
UpdateTable();
} else {
m_xEntry = nt::NetworkTableEntry();
m_yEntry = nt::NetworkTableEntry();
m_zEntry = nt::NetworkTableEntry();
}
}
void BuiltInAccelerometer::UpdateTable() {
if (m_xEntry) m_xEntry.SetDouble(GetX());
if (m_yEntry) m_yEntry.SetDouble(GetY());
if (m_zEntry) m_zEntry.SetDouble(GetZ());
void BuiltInAccelerometer::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("3AxisAccelerometer");
builder.AddDoubleProperty("X", [=]() { return GetX(); }, nullptr);
builder.AddDoubleProperty("Y", [=]() { return GetY(); }, nullptr);
builder.AddDoubleProperty("Z", [=]() { return GetZ(); }, nullptr);
}