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

@@ -8,16 +8,13 @@
#pragma once
#include <memory>
#include <string>
#include <HAL/Encoder.h>
#include "Counter.h"
#include "CounterBase.h"
#include "LiveWindow/LiveWindowSendable.h"
#include "PIDSource.h"
#include "SensorBase.h"
#include "networktables/NetworkTableEntry.h"
namespace frc {
@@ -39,10 +36,7 @@ class DigitalGlitchFilter;
* All encoders will immediately start counting - Reset() them if you need them
* to be zeroed before use.
*/
class Encoder : public SensorBase,
public CounterBase,
public PIDSource,
public LiveWindowSendable {
class Encoder : public SensorBase, public CounterBase, public PIDSource {
public:
enum IndexingType {
kResetWhileHigh,
@@ -60,7 +54,7 @@ class Encoder : public SensorBase,
bool reverseDirection = false, EncodingType encodingType = k4X);
Encoder(DigitalSource& aSource, DigitalSource& bSource,
bool reverseDirection = false, EncodingType encodingType = k4X);
virtual ~Encoder();
~Encoder() override;
// CounterBase interface
int Get() const override;
@@ -76,6 +70,7 @@ class Encoder : public SensorBase,
double GetRate() const;
void SetMinRate(double minRate);
void SetDistancePerPulse(double distancePerPulse);
double GetDistancePerPulse() const;
void SetReverseDirection(bool reverseDirection);
void SetSamplesToAverage(int samplesToAverage);
int GetSamplesToAverage() const;
@@ -85,11 +80,7 @@ class Encoder : public SensorBase,
void SetIndexSource(const DigitalSource& source,
IndexingType type = kResetOnRisingEdge);
void UpdateTable() override;
void StartLiveWindowMode() override;
void StopLiveWindowMode() override;
std::string GetSmartDashboardType() const override;
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
void InitSendable(SendableBuilder& builder) override;
int GetFPGAIndex() const;
@@ -103,9 +94,6 @@ class Encoder : public SensorBase,
std::unique_ptr<DigitalSource> m_indexSource = nullptr;
HAL_EncoderHandle m_encoder = HAL_kInvalidHandle;
nt::NetworkTableEntry m_speedEntry;
nt::NetworkTableEntry m_distanceEntry;
nt::NetworkTableEntry m_distancePerTickEntry;
friend class DigitalGlitchFilter;
};